Last active
September 18, 2018 15:09
-
-
Save Sinthorion/c54aa7e52333733c0475729b36e76853 to your computer and use it in GitHub Desktop.
Brainfuck Tic Tac Toe - Hotseat Version (BFC syntax)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
BF Tic Tac Toe - Hotseat Version | |
================================ | |
Memory structure: | |
00: mode, col, row, zflag, tmp | |
04: flag, cell_A1, flag, cell_A2, flag, cell_A3, | |
0A: flag, cell_B1, flag, cell_B2, flag, cell_B3, | |
10: flag, cell_C1, flag, cell_C2, flag, cell_C3, | |
Mode: (+1/"X", -1/"O") | |
Cells: ASCII char (" ", "X", "O") | |
Flags: (0, +1) | |
] | |
+ Set mode in (0) | |
6> set all cells to SPACE | |
20+>>20+>>20+>> | |
20+>>20+>>20+>> | |
20+>>20+>>20+>> | |
18< move back to mode | |
[ while mode is not zero | |
>,31- read col | |
>,31- read row | |
>A-[A+,A-] continue reading until newline; drop | |
<<[>3+<-]> calculate index in row | |
[>3+<3-] move row to first flag | |
>+ set zflag | |
>>[[>>+<<-]-]+ set flag at cell(row) | |
-[+<<-] return to zflag | |
3< go to mode | |
>+< | |
+ | |
[>-<-- if flag positive; toggle | |
3>+ set zflag | |
>>-[+>>-] move to flagged cell | |
>58+ set cell char | |
<-[+<<-] return to zflag | |
3< | |
]>[<+ if flag negative; toggle | |
3>+ set zflag | |
>>-[+>>-] move to flagged cell | |
>4F+ set cell char | |
<-[+<<-] return to zflag | |
3< | |
>]< | |
TODO: check win conditions | |
6> print board | |
.>>.>>.>20+.[-]> | |
.>>.>>.>20+.[-]> | |
.>>.>>.>20+.[-]> | |
19< | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment