Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. :"TIC TAC TOE in KLONG"
  2.  
  3. board::{:#x}'45+&9 :"array of 9 0c-"
  4. wins::[[0 1 2][3 4 5][6 7 8][0 3 6]
  5. [1 4 7][2 5 8][0 4 8][2 4 6]]
  6. turn::0
  7.  
  8. pb::{.sys("clear");pt3(3:#x);.p("")} :"prints the game's board"
  9.  
  10. w::{.d(x);.p(" WINS");0}
  11.  
  12. check::{[k];k::y?x;
  13. 2<|/#'{isect(k;x)}'wins}
  14.  
  15. winnerp::{pb(x);
  16. :[check(0cX;x); w("X")
  17. :|check(0cO;x); w("O")
  18. ;1]}
  19.  
  20. ttt::{[p b];b::x;:[turn::~turn;p::0cX;p::0cO];
  21. nextmove::{[t];pb(b);.d(p,"'s move: ");
  22. t::1:$.rl();
  23. :[:_t;.f()
  24. :|0cX~b@t;.f()
  25. :|0cO~b@t;.f()
  26. ;t]};
  27. b:=p,nextmove()}
  28.  
  29. main::{winnerp ttt:~board}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement