Skip to content

LandonThePancake/Dualfish

Repository files navigation

Dualfish Interpreter

Written by LandonThePancake in Python v3.12.0

dufi

NOTE: v2.0 of this project is currently being developed!! This will include many changes and additions to the interpreter, so it may break some things!!

Info

Dualfish is an esoteric programming language heavily inspired by the language "deadfish". Dualfish aims to add more to deadfish, while having the goal of making it slightly more interesting (whilst also making no god-damn sense). It gets its name from having two INT registers to work with (unlike deadfish, which only has one), hence the name "Dualfish".
To get started writing code in dualfish, type 'help' into the interpreter to get a list of commands. You can also continue reading this readme for more detailed explanations.

Resources

- The Live Interpreter (the main thing)
- Num To Alph/Symbol Table (used to print text & symbols)
- Python 3.12.0 (not needed for the .exe builds)

How to use dualfish

(If you want to run your code in .dufi files, type g into your interpreter and give it the file name. Keep in mind that dualfish ignores spaces and line breaks, so format it however you'd like.)

Dualfish has two INT registers that can be modified to your liking. You can switch between them with the "<" and ">" commands, and clear both of them with "r" (remember "r". it's very useful).
We will start off with the functions that modify the value of said registers, and then move on to the other stuff.

Math Functions

Our first set of functions are used to add and subtract 1 from a register. "i" increments a register by 1 and "d" decrements a register. Simple.

Incrementing a register
INPUT: iii
(register 1 is now equal to 3)

Decrementing a register
INPUT: ddd
(register 1 is now equal to -3)

Next, we have "s" and "c", which squares and cubes a register respectively.

Squaring a register
INPUT: iiis
(register 1 is now equal to 9)

Cubing a register
INPUT: iiic
(register 1 is now equal to 27)

There is also a "*" function that multiplies our register by 2.

Doubling a register
INPUT: iii*
(register 1 is now equal to 6)

How to code efficiently with math functions

The thing that "s","c" and "*" have in common, is that they can all be used to make our code WAY more efficient. Let's say we want register 1 to equal 26. Sure, we could just type "i" 26 times, or we could do something like this:

INPUT: iii***ii
(register 1 is now equal to 26)

or:

INPUT: iiiiisi
(register 1 is now equal to 26)

or even:

INPUT: iiicd
(register 1 is now equal to 26)

Writing code like this is a much faster and better way to get what you want, and is practically required for when you are outputting out a word. Speaking of output, I think it's a good time to go over that.

How to output numbers

Number output is pretty easy in dualfish, I don't think I need to explain this one too much.

"o" outputs the value of your current register
"0" outputs the value of both registers side by side.

Output with o
INPUT: iii*do
OUTPUT: 5

Output with 0
INPUT: iii*d0
OUTPUT: [5, 0]

How to output letters and symbols

You're gonna need this.
The "a" function outputs an alphabetical letter that corresponds to a registers current value.
So, 1 = a, 2 = b, 3 = c, etc.
Its also worth noting that when you go past 26 (or z), you can find UPPERCASE letters. Just don't go past 52, because that will throw an error.

Alphabet Output with a
INPUT: ii**aia
OUTPUT: hi

"a" is also used to output symbols. If you use the "^" command, you will go into "symbol-mode", where you have access symbols instead of letters. Its also worth bringing up that "v" will bring you back to "alphabet-mode"

Symbol Output with a
INPUT: ^ii*ada
OUTPUT: @!

How to use the 2nd register

So this entire time, we've been talking in the context of using a single register, but using the 2nd register can be very useful in many situations, like outputting long text strings.

The ">" will switch the selected register to register 2, while "<" will switch it back to register 1
INPUT: ii>iiiio<o
OUTPUT: 42

Adding and subtracting registers

Now that we know how to assign values to each register, we can use "+" and "-" to add and subtract our registers together. The selected register is the one that will be added/subtracted from.

Adding Registers
INPUT: iiiii>ii<+0
OUTPUT: [7, 2]
(note that reg2 holds its value, even after adding it to reg1)

Subtracting Registers
INPUT: iiiii>ii<-0
OUTPUT: [3, 2]
(note that reg2 holds its value, even after subrtacting it from reg1)

Other functions and info

":" is used to take in a user input (int), but due to the limitations of the language, it's very situational. But you can still make things like basic calculators.

Taking and using user input
INPUT: :>:<+o
(asks for input1)
(asks for input2)
(combines them and displays the value)

"r" resets BOTH registers back to 0. This can be used as a shortcut back to the starting point of the register.

Resetting a register
INPUT: iii*>ii*r0
Output: [0, 0]

"=" is used as the start and end of a comment, it's very useful when you are coding in a file instead of the interpreter

Comments
INPUT: iii>i<=dualfish is better than javascript=*0
Output: [6, 1]

The last function is the "e" function. it simply closes the application when called.

Exiting The Interpreter
INPUT: e
(closes the application)