Tic-tac-toe: Difference between revisions
Content deleted Content added
Line 979: | Line 979: | ||
To subsequent j poster: replacing this entry is fine by me. |
To subsequent j poster: replacing this entry is fine by me. |
||
<lang J> |
<lang J> |
||
⚫ | |||
NB. use: 'XO' ttt 'abcdefghijklmnop' |
NB. use: 'XO' ttt 'abcdefghijklmnop' |
||
⚫ | |||
while=: conjunction def 'u ^: v ^:_' NB. j needs to know while is a conjunction |
|||
⚫ | |||
⚫ | |||
outcome=: {&(>;:'kitty VICTORY')@:won |
outcome=: {&(>;:'kitty VICTORY')@:won |
||
move=: post locate |
move=: post locate |
||
undecided=: won nor filled |
|||
prepare=: , 9&{. |
prepare=: , 9&{. NB. form the state vector |
||
display=: show [: (1 1,:5 5)&(];.0)@:": [: <"0 fold |
display=: show [: (1 1,:5 5)&(];.0)@:": [: <"0 fold |
||
Line 1,019: | Line 1,022: | ||
Note 'wrapped example to better fit wide display' |
Note 'wrapped example to better fit wide display' |
||
The state vector is 11 items long with |
|||
mark of the next player, mark of other player, 9 characters representing the board |
|||
NB. play the game -->cell for -? -->cell for -? |
NB. play the game -->cell for -? -->cell for -? |