Omnimaga

General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Scipi on September 20, 2012, 03:41:15 pm

Title: Mindf*ck - A new dialect/extension of Brainf*ck
Post by: Scipi on September 20, 2012, 03:41:15 pm
Cross post from here (http://ourl.ca/13385) where I originally announced this

Spoiler For Spoiler:
Ok, so after nearly a year, I actually have something to show for this (Holy crap!)

Introducing Mindf*ck:

A dialect of BF that on top of the original BF command set and principles, adds functionality for using addresses, splitting threads, moving throughout the code (read: subroutines), and the ability to insert values in the code itself easier.

The command list is as follows:
//////////////////////
//BrainF*ck Commands
//////////////////////
>   Shift right
<   Shift left
+   Inc
-   Dec
[   Start while if nonzero
]   End while - break if zero (Jump to address if nonzero)
.   Read char
,   Get char
/////////////////////
//MindF*ck Commands
/////////////////////
#   Get Int
$   Read Int
(   Store address
)   Pop address
{   Copy value to address
}   Retrieve value at address
""   Insert string - overwrites its length
::   Insert binary num   
^   Jump to address
|   Split thread at code address
!   Ends process

The main difference is the addition of a stack used for addresses as well as storing values. Think like what Z80 has. You are also able to move around the code itself to execute sections of code.

"<string>" allows for strings of chars to be inserted into the value array, it will overwrite its length in chars.
:<Number>: this will insert an int expressed in binary at this point in the value array

Another difference is that instead of chars, the array is composed of ints. I did this in order to support jumps using values in the value array.

Things to do:

Fix the split thread command. Weird stuff is happening and I'm not sure why.

More bug testing

Source:

https://sourceforge.net/projects/mindfck/ (https://sourceforge.net/projects/mindfck/)

Edit: I forgot to mention, I still need to write up the full documentation for how each command works and what exactly they read from/effect. Some of the address commands either affect the value array iterator or code iterator, for instance.

This will be the official thread for MF releases, info, and ideas. The idea of the language is to extend BF to where it is feasible to create programs and games within the language, while still providing a fun challenge to the programmer, maintaining esoteric status.

These are the supported commands. I will be updating as new releases become available.

Spoiler For Command List:
//////////////////////
//BrainF*ck Commands
//////////////////////
>   Shift right
<   Shift left
+   Inc
-   Dec
[   Start while if nonzero
]   End while - break if zero (Jump to address if nonzero)
.   Read char
,   Get char
/////////////////////
//MindF*ck Commands
/////////////////////
#   Get Int
$   Read Int
(   Store address
)   Pop address
{   Copy value to address
}   Retrieve value at address
""   Insert string - overwrites its length
::   Insert binary num   
^   Jump to code address
|   Split thread at code address
!   Ends process

///////
//1.1
///////
_   Insert memory address in memory
@   Insert code address in memory
&   Jump to memory address

The largest and most significant addition is that of a stack used to store information as well as addresses. This allows for subroutines to be written as such.

Code: [Select]
:Ret Address: ( /*:param: ( :etc:*/ :Subroutine Address: (^
/*Subroutine*/
/*Extract params using )*//*Subroutine code*/
) // Pop return address
/*Store return values with (*/
( //Store return address
^ // Return

So an example would be a simple addition routine

Code: [Select]
:00011011:(#(#(:00011110:(^)$!)>)[<+>-])<(>(^
This will read two ints and output their sum. Here's the dissection:

Code: [Select]
:00011011:( // Inserts an int and stores it on the stack, this is where we will return to
#(#( // Reads two ints and stores them on the stack
:00011110:( // Inserts an int and stores it on the stack, this is the subroutine address
^)$! // This is the jump and afterwards it displays the first value on our stack and terminates the program
)>)[<+>-])<(>(^ // This is our subroutine. Takes two params, adds them, stores the result, and returns

Todo:

-Write documentation of each instruction and what they do exactly
-Bug test
-Add drawing to the screen/image support (Already know how I'll do this)
-Write IDE for MF
-Prove Turing Completeness (if it has one)
-Write compiler for MF

How to use:

On windows, write your MF code in any text editor, and drag/drop onto the exe.

To use from CMD:

Code: [Select]
<MF_Dir>MindF_ck.exe <File_Dir>
To download, please go to the sourceforge page:

https://sourceforge.net/projects/mindfck/ (https://sourceforge.net/projects/mindfck/)
Title: Re: Mindf*ck - A new dialect/extension of Brainf*ck
Post by: Juju on September 20, 2012, 03:48:16 pm
Nice :D
Title: Re: Mindf*ck - A new dialect/extension of Brainf*ck
Post by: ben_g on September 20, 2012, 04:04:41 pm
Brainf*ck was created as a very limited programming language so it would have the smallest interpreter, it was not created to actually do something useful. I'ts now only used for watching the look on your friends' faces when you show then a brainf*ck program. While your extension does add some instructions which can be usefull to make real programs with it, it is still very hard to read and still so limited that even the simple things would require huge routines, which would make it way to slow to make stuff like graphical games. Also, it still can't read or write from/to files, which is a very basic function that almost every program has.

Also, everyone who programs in brainf*ck probably does it for the challenge, and some may think your extension takes a part of the challenge away.

But anyway, it might be an easyer start for anyone willing to try brainf*ck, so good work.


^The above was not meant tu be rude or anything, but I doubt a bit that it would be very usefull. Brainf*ck is the programming language of a nightmare, and it may be best to keep it like that.
Title: Re: Mindf*ck - A new dialect/extension of Brainf*ck
Post by: Scipi on September 20, 2012, 04:21:30 pm
Brainf*ck was created as a very limited programming language so it would have the smallest interpreter, it was not created to actually do something useful. I'ts now only used for watching the look on your friends' faces when you show then a brainf*ck program. While your extension does add some instructions which can be usefull to make real programs with it, it is still very hard to read and still so limited that even the simple things would require huge routines, which would make it way to slow to make stuff like graphical games. Also, it still can't read or write from/to files, which is a very basic function that almost every program has.

Also, everyone who programs in brainf*ck probably does it for the challenge, and some may think your extension takes a part of the challenge away.

But anyway, it might be an easyer start for anyone willing to try brainf*ck, so good work.


^The above was not meant tu be rude or anything, but I doubt a bit that it would be very usefull. Brainf*ck is the programming language of a nightmare, and it may be best to keep it like that.

This interpreter supports vanilla brainf*ck, so anyone who wants to use that, may certainly do so.

I plan on file loading support through use of an IDE, that would "compile" the data into one MF file. If people want though, I could try to see if I can add that kind of support maybe using the /\ characters and a separate memblock just for files. Though, I'd rather not quite have to do that. But it's feasible.

The actual point is not really to be more difficult than BF (if you want difficulty, use BF) I want a language that can feasibly be used to create useful programs while using limited commands. It's kind of something between BF and ASM, perhaps.