Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :"TIC TAC TOE in KLONG"
- board::{:#x}'45+&9 :"array of 9 0c-"
- wins::[[0 1 2][3 4 5][6 7 8][0 3 6]
- [1 4 7][2 5 8][0 4 8][2 4 6]]
- turn::0
- pb::{.sys("clear");pt3(3:#x);.p("")} :"prints the game's board"
- w::{.d(x);.p(" WINS");0}
- check::{[k];k::y?x;
- 2<|/#'{isect(k;x)}'wins}
- winnerp::{pb(x);
- :[check(0cX;x); w("X")
- :|check(0cO;x); w("O")
- ;1]}
- ttt::{[p b];b::x;:[turn::~turn;p::0cX;p::0cO];
- nextmove::{[t];pb(b);.d(p,"'s move: ");
- t::1:$.rl();
- :[:_t;.f()
- :|0cX~b@t;.f()
- :|0cO~b@t;.f()
- ;t]};
- b:=p,nextmove()}
- main::{winnerp ttt:~board}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement