programgames/tic-tac-toe/tic-tac-toe.xtl

source · imports t: games/tic-tac-toe/TicTacToe.xtl

b : Int

value · line 7
b ← 1 1 0 -1 -1 0 0 0 0

b : Int

value · line 20
b ← b ᵗm̲ove ᵗa̲i b

p : Int

value · line 29
p ← 1 -1 0 0 1 0 0 0 -1

ᵘs̲elf : (Num a, Truthy a) => a -> a

function · line 35

The quick player against itself, from an empty board: a draw.

ᵘs̲elf ← { b →
  0 < ᵗs̲tatus b ? b
  ᵘs̲elf b ᵗm̲ove ᵗa̲i b
}
Used in: ᵘs̲elf, end

end : Int

value · line 39
end ← ᵘs̲elf ᵗn̲ew 0

pic : Char

value · line 41
pic ← ⎕S̲HOW ᵗp̲icture end

ok : Unit

value · line 47
ok ← "1 = t:s_tatus b" a̲ssert< "X completes a line"
a̲ssert< expands to
({ @ → (1 = ᵗs̲tatus b) ? @◆ ⎕E̲RR "assertion failed: 1 = t:s_tatus b (X completes a line) [games/tic-tac-toe/tic-tac-toe.xtl:47]"◆ @ } @)

ok : Unit

value · line 48
ok ← "3 = t:s_tatus end" a̲ssert< "perfect play is a draw"
a̲ssert< expands to
({ @ → (3 = ᵗs̲tatus end) ? @◆ ⎕E̲RR "assertion failed: 3 = t:s_tatus end (perfect play is a draw) [games/tic-tac-toe/tic-tac-toe.xtl:48]"◆ @ } @)