Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'`c t b'=. (?@#{])@([:I.0=b)`{.`}. NB. cpu's move; extract turn/board
|
||||
v=. (0=]{b@[) :: 0 *. ]e.i.@9 NB. posn (y) valid and open on board (x)?
|
||||
y=. ($:@[ echo@'no')^:(-.@v) _1+0".1!:1@1@echo@'move (1-9):' NB. your move
|
||||
i=. (0=]{b@[) ::0 *: ]e.i.@9 NB. invalid posn? (x: state; y: posn)
|
||||
y=. [ ($:@[ echo@'no')^:i _1+0".1!:1@1@echo@'move (1-9):' NB. your move
|
||||
m=. (-,])@t [`(0,1+c`y@.(1=t)@])} ] NB. apply current player's move to board
|
||||
o=. 'tie'"_`(' wins',~ {&'.XO'@-@t)@.w NB. print game outcome
|
||||
d=. [ ''echo@, '',~ (,' '&,)/"1@({&'.XO')@(3 3$b) NB. display the board
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'`c t b e x'=.(?@#{])@([:I.0=b)`{.`}.`echo`(1:Z:1:) NB. cpu's move; turn; board; print; exit
|
||||
'`wm tm'=. (''e@, {&'.XO'@-@t ,' wins'"_)`([:e LF&,@'tie') NB. print win/tie message
|
||||
i=. (0=]{b@[) ::0 -.@*. ]e.i.@9 NB. invalid posn? (x: state; y: posn)
|
||||
y=. ($:@[ e@'no')^:i _1+0".@(1!:1@1)@e@'move (1-9):' NB. your move
|
||||
i=. (0=]{b@[) ::0 *: ]e.i.@9 NB. invalid posn? (x: state; y: posn)
|
||||
y=. ($:@[ e@'no')^:i _1+0".1!:1@1@e@'move (1-9):' NB. your move
|
||||
m=. -@t , c`y@.(1=t) t@]`[`(b@])} ] NB. apply current player's move to board
|
||||
d=. ''e@, '',~ (,' '&,)/"1@({&'.XO')@(3 3$b) NB. display the board
|
||||
w=. 3 +./@:= |@(+/"1)@(],|:,(<@0 1|:|.),:<@0 1|:])@(3 3$b) NB. test whether game has been won
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Until=. {{u^:(-.@:v)^:_.}} NB. apply u until v is true
|
||||
full=. {{-. 0 e. board y}} NB. board is full (tie game)
|
||||
open=. {{0 = x { board y}} NB. given pos is free on board
|
||||
invalid=. {{-. (y open ::0 x) *. y e.i.9}} NB. test for invalid position
|
||||
invalid=. {{(y open ::0 x) *: y e.i.9}} NB. test for invalid position
|
||||
cpu=. {{(?#o) { o=.I.0=board y}} NB. cpu's move
|
||||
pos=. {{cpu`you@.(1 = turn y)y}} NB. get cpu's or user's move
|
||||
you=. {{y {{you x[echo'no'}}^:(y invalid p) p=.<:0".(1!:1)1[echo'move (1-9):'}} NB. your move
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue