 
 game = new TicTacToeState
 agent = new MinimaxAgent 3
+lastAction = null
 
 # Agent :: {
 #   nextAction : (State) -> Action


humanPlays = (position) ->
  if position in game.openPositions()
    game = game.play game.makeAction position
    log 'You played ' + position
  else
    log chalk.red.bold 'Invalid position ' + position

computerPlays = ->
  [action, game] = playTurn agent, game
  log 'I played ' + action

printHeader()
prompt()


Board::toString = ->
  sep = chalk.dim '|'
  p = (i) =>
    if @ps[i] is _
      chalk.dim i
    else if lastAction is i
      chalk.inverse.bold @ps[i]
    else
      chalk.bold @ps[i]
  """#{sep}#{p 0}#{sep}#{p 1}#{sep}#{p 2}#{sep}
     #{sep}#{p 3}#{sep}#{p 4}#{sep}#{p 5}#{sep}
     #{sep}#{p 6}#{sep}#{p 7}#{sep}#{p 8}#{sep}"""
