Last active
December 3, 2020 13:50
-
-
Save danielcristofani/6513ac24d6b5855dc5ed2d63c379221b to your computer and use it in GitHub Desktop.
Tic-tac-toe player
This file contains hidden or 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
--->--->>>>->->->>>>>-->>>>>>>>>>>>>>>>>>+>>++++++++++[ initialization | |
<<++[ output board | |
--<+<<+<<+>>>>[ | |
>[<->>+++>>[-]<<<+[<++>>+>>-<<<--]]+>+++++[>>++++++++++<<-] | |
>>-.[-]>>+[<<<<+>>+>>-]<<<<<<[>+<-]<< | |
]++++++++++.[-]>++ | |
]-->>[-->[-]>]<<[ if game not over | |
>>--[ while stack isn't empty | |
-[ | |
-[ fn 0: get move from user | |
-----[>+>+++++++<<+]-->>-.----->,[<->-]<[[<]+[->>]<-]<[<<,[-]]>>>> | |
]> | |
]<[ fn 1: initial assessment of position for win or draw | |
>-[+<+++]+<+++[+[---->]+<<<<<<[>>]<[-]] | |
>[<+[---->]++[<]<[>]>[[>]+>+++++++++<<-[<]]]>[>>>>] | |
]<[ fn 2: check different moves to evaluate nonterminal position | |
-[[>+>+<<-]>[<+>-]++>+>>]<[<<++[-->>[-]]>[[-]>[<<+>>-]>]] | |
]<[ fn 3: check if move is blocked (nonempty space) | |
[[<<]-[>>]<+<-]>[-<+]<<[<<]-<[>[+>>]>[>]>[-]] | |
>[[+>>]<-->>[>]+>>>] | |
]<[ fn 4: return value to previous 2 | |
-[ | |
--[+<<<<--[+>[-]>[<<+>+>-]<<[>>+<<-]]++[>]] | |
<<[>+>+<<-]>--[<+>-]++>>> | |
]<[<<<[-]+++>[-]>[<+>>>+<<-]+>>>] | |
]<[ fn 5: place or withdraw move | |
+[[<]<<[<<]-<->>+>[>>]>[>]<-]<[<]<<+<++[[>+<-]++<[<<->>+]<++]< | |
b m t l \ c r / | |
<<<<<< +> > >+> > >+[ | |
<<< ->+>+>+[ | |
<<<<<<< +>->+> > >->->+[ | |
<<<<< ->+>+> >+>+[ | |
<<<< ->->+>->+[ | |
<<<<<<<<+>-> >+> > >->+>+[ | |
<<<<< -> >+> >->+[ | |
<<<< +>->+> >+]]]]]]] | |
+++[[>+<-]<+++]--->>[[<->-]<+++>>]++[[<->-]>>]>[>] | |
]< | |
] | |
]< | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment