brainfuck-2048

brainfuck implementation of the well-known 2048 game
git clone https://tongong.net/git/brainfuck-2048.git
Log | Files | Refs | README

commit c76ebac6f80527c82995dcce12a9f957f29dd6bc
Author: tongong <tongong@gmx.net>
Date:   Wed, 15 Apr 2020 16:33:08 +0200

first commit

Diffstat:
A2048.bf | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AREADME.md | 30++++++++++++++++++++++++++++++
2 files changed, 173 insertions(+), 0 deletions(-)

diff --git a/2048.bf b/2048.bf @@ -0,0 +1,143 @@ + 2048 in brainfuck ~ by @tongong [https://github.com/tongong] +++++++>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+[->>>>>>>>>>>>>>>>+>++>>>++++++ +++++++++++[<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<< +<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>> +>>>>>>]>[[-]<<<+<-[+<-]+>+>-[+>-]>>>]<<-[->+<]>]<<<<<<<<<<<<<<<<<<<<-> +------------------>+<[[-]>-]>[<<++++++++++++++++[<[-]>-[-<+>]<]>>>>>>> +>>>>>>>>>>>->++++++++++[>+++++++>++++++++++>+++++++++++>++++++++++>+++ +>++++++++>++++++++++++>++++++++++>+++++++++++>+++>++++++>++++>+++>++++ +++++>+++++++++++>++++++++++++>+++>++++++++++>++++++++++>++++++++++>+++ +++++++++>+++++++++++>+++>+<<<<<<<<<<<<<<<<<<<<<<<<-]>+>--->->+>++>->-- +>+>++++>++>-->>++>++++>++++>+>++>--->+++>--->----->>+++>+++<<<<<<<<<<< +<<<<<<<<<<<<.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.[[-]<]]<<<< +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+[-<[-]<[-]<+[->>+>+<<<]>> +>[-<<<+>>>]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<<<<<<<<<<<<--[++<--]++<]>>-[ ++>-]--[++<--]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++[>++++[< +<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<<<<<<]>>>>> +>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>]>+>>+<<[ +>>[>]+[<]<-]>>[>]<<[-<]>>>>>>>>>>>>>>>[++++++[->++++++++<]>.-------.[- +]<[-]]<[+++++[->++++++++<]>++++.----.[-]<[-]]<[+++++[->++++++++<]>++.- +-.[-]<[-]]<[+++++[->++++++++<]>+.-.[-]<[-]]<[+++[->++++++++<]>.<++[->+ ++++++++<]>+++++.[-]<[-]]<[+++[->++++++++<]>.<++[->++++++++<]>++.[-]<[- +]]<[+++[->++++++++<]>.<++[->++++++++<]>+.[-]<[-]]<[+++[->++++++++<]>.. +[-]<[-]]<[+++[->++++++++<]>..[-]<[-]]<[+++[->++++++++<]>..[-]<[-]]<[++ ++[->++++++++<]>..[-]<[-]]<[+++[->++++++++<]>..[-]<[-]]<[+++[->++++++++ +<]>..[-]<[-]]<[+++[->++++++++<]>..[-]<[-]]++++[->++++++++<]>....[-]<[- +]<<<<<<<<-[->+<]>]+++[->++++<]>+.[-]<[-]<<<<++++[<<<<<<<<<<<<<<<<<[->> +>>>>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>[-<< +<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>]>+>>+<<[>>[>]+[<]<-]>>[>]<<[ +-<]>>>>>>>>>>>>>>>[++++++[->++++++++<]>+.-------.[-]<[-]]<[++++++[->++ +++++++<]>+.---.[-]<[-]]<[+++++[->++++++++<]>++++.++++.[-]<[-]]<[+++++[ +->++++++++<]>++.++.[-]<[-]]<[+++++[->++++++++<]>+.+.[-]<[-]]<[+++++[-> +++++++++<]>+++++.+.[-]<[-]]<[+++++[->++++++++<]>++.++++++.[-]<[-]]<[++ ++++[->++++++++<]>++++++.--.[-]<[-]]<[+++++[->++++++++<]>+++.-.[-]<[-]] +<[+++++[->++++++++<]>+.+++++.[-]<[-]]<[+++[->++++++++<]>.<++[->+++++++ ++<]>++++++++.[-]<[-]]<[+++[->++++++++<]>.<++[->++++++++<]>++++.[-]<[-] +]<[+++[->++++++++<]>.<++[->++++++++<]>++.[-]<[-]]<[+++[->++++++++<]>.+ +++++++++++++.[-]<[-]]++++[->++++++++<]>....[-]<[-]<<<<<<<<-[->+<]>]+++ +[->++++<]>+..[-]<[-]<<<<<-[->>>>+<<<<]>>>>]<<<<<<<<<<<<<<<<+++++++++++ ++++++>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<[<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<<]>>>> +>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>]>+<<[->>[>]+[<]< +]>>[>]<<[-<]>[-]>[>-[+>-]+>++<<-[+<-]]>[>-[+>-]+>++++<<-[+<-]]>[>-[+>- +]+>++++++++<<-[+<-]]>[>-[+>-]+>++++++>+<<<-[+<-]]>[>-[+>-]+>++>+++<<<- +[+<-]]>[>-[+>-]+>++++>++++++<<<-[+<-]]>[>-[+>-]+>++++++++>++>+<<<<-[+< +-]]>[>-[+>-]+>++++++>+++++>++<<<<-[+<-]]>[>-[+>-]+>++>+>+++++<<<<-[+<- +]]>[>-[+>-]+>++++>++>>+<<<<<-[+<-]]>[>-[+>-]+>++++++++>++++>>++<<<<<-[ ++<-]]>[>-[+>-]+>++++++>+++++++++>>++++<<<<<-[+<-]]>[>-[+>-]+>++>++++++ ++++>+>++++++++<<<<<-[+<-]]<<<<<<<<<<<<<<<<-[->+<]>]>>>>>>>>>>>>>>>>>>> +>-<<<<++++[>>>>>[->>>>>--------->>+<<[++++++++++>]>>[<<<<<<+>>>>>>>]<- +<<<<<<<]>>>>>[-<<<<<+>>>>>]<<<<<<<<<<-[->+<]>]>>>>>>++++++++++[>++++++ +++>++++++++++>+++++++++++>+++++++++++>++++++++++>++++++>+++<<<<<<<-]>+ +++>->+>++++>+>-->++<<<<<<.>.>.>.>.>.>.[[-]<]>++++++[-<++++++++>]<[-<+< ++<+<+<+>>>>>]<[.[-]<]+++++++++++++.[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<++++++++++[>++++++++>+++++++++++>++++++++++>++++++++++>+++++++++++ ++>++++++++++>+++>++++++++++>+++++++++++>++++++++++++>++++++++++>++++++ ++++++>+++>++++++++++>+++>++++++++++>+++++++++++>+++++++++++>++++++++++ +>++++++++++>++++++++++++>+++++++++++>+++++++++++>+++++++++++>+++>++++> ++++++++++>+++++++>++++++++>+++++++>++++>+++>+<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<-]>>-->+>--->----->+>++>+>>---->+>++++>++>--->++>>----->++++>+ +>->---->----->+>>++>>--->----->+++>-->+>+++>+++[<]>.>.>.>.>.>.>.>.>.>. +>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.[[-]<]>>>>>>>>>>>>>--[++ +,>++++++++[-<-------->]<[->>[>]+[<]<]>>[>]<<[-<]<++>>[<<<<<+>>>>>-]>>> +[<<<<<<+>>>>>>-]>>>>>>>>>>>>>>>[+<--[++<--]++<<+>>>--[++>--]]>>>>[+<-- +[++<--]++<<<<+>>>>>--[++>--]]>>>>>>>>>>[+<--[++<--]++<<<+>>>>--[++>--] +]>>>[+<--[++<--]++<+>>--[++>--]]>>>>>>>>>>>>>>>[+<--[++<--]++<<+>>>--[ +++>--]]>>>>[+<--[++<--]++<<<<+>>>>>--[++>--]]--[++<--]++<<<<<<<<<++++[ +>>>>>[-<<<<<<<<<+>+>>>>>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<<<<< +<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<<]>>>>>>>>>>>>>>>>>-[->+<]>]>>>>>>>>>>>>>[->>>>>>+<<<<<<]>[- +>>>>+<<<<]>[->>+<<]++++++++++++++++<<<<<<<<<<<<<<+++[>+>>>>>>>>>>>>>>+ +[->>>>>>>+>>[>]+[<]<<<<<<<<]>>>>>>>-[-<<<<<<<+>>>>>>>]+>>[>]<<[-<]>[-< +<-<<<<<<[-<+>]<<+[->>>>>>>+>>[>]+[<]<<<<<<<<]>>>>>>>-[-<<<<<<<+>>>>>>> +]+>>[>]<<[-<]>]-[+>-]-[+<-]<<<<<<<[->>>>>>+>+<<<<<<<]>[->>>>>>>+>+<<<< +<<<<]>>>>>>[-<<<<<<<+>>>>>>>]>[-<<<<<<<+>>>>>>>]<<[->>>-<<<]>+>>++++++ +++++++++++++++++++++++++++++++[->>[>]+[<]<]>>[>]<<[-<]>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>[<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]< +++++++++++++++++<<<<<++>>>>>>>>>>>>>>>>>>>>>]>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>-[+<-]-[+<-]<<<<<<<<<<<<<<<<<<-[+<-]<-[->+<]>]>>>>>>>>>>+<< +<<-[+[>>>>>---------------<<<<<--]>-]>---------------->>[-<<+>>]>[-<<< +<+>>>>]>[-<<<<<<+>>>>>>]<<<<<<<++++[>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]<-[->+<]>]<<<<<<<<<<<<<<<<<<<<< +-[->>>>+<<<<]>>>>]<<<<<<<<<<<<<]+++++++++++++.[-]<<<<<<<<<<<<<<<<<<<+] diff --git a/README.md b/README.md @@ -0,0 +1,30 @@ +# brainfuck-2048 + +This is a brainfuck implementation of the well-known 2048 game. + +I wrote this without using any transcompilers and maybe I will publish the source code in the future as proof (At the moment it's pretty poorly commented so it wouldn't be of use). + +## Control + +When the program asks you to do so, you can move the tiles with + +- **w** upwards + +- **a** to the left + +- **s** downwards + +- **d** to the right + +## Testing + +The program should work on any interactive interpreter (since you need to control the game while it's running). I wrote it for 8-Bit-sized memory, but it may also work on greater sized cells. + +For testing I recommend using these interpreters: + +- [https://mitxela.com/other/brainfuck](https://mitxela.com/other/brainfuck) +- [http://www.bf.doleczek.pl](http://www.bf.doleczek.pl) + +Since these interactive interpreters are quite slow I might try to program one myself in the future. + +#