Class: XO::AI::MinGameState

Inherits:
GameState show all
Defined in:
lib/xo/ai/minimax.rb

Instance Attribute Summary

Attributes inherited from GameState

#grid, #move, #next_states, #player

Instance Method Summary collapse

Methods inherited from GameState

#initialize, #is_terminal?, #result, #score, #scores

Constructor Details

This class inherits a constructor from XO::AI::GameState

Instance Method Details

#next_game_state(next_grid, other_player, move) ⇒ Object



104
105
106
# File 'lib/xo/ai/minimax.rb', line 104

def next_game_state(next_grid, other_player, move)
  MaxGameState.new(next_grid, other_player, move)
end

#non_terminal_scoreObject



119
120
121
# File 'lib/xo/ai/minimax.rb', line 119

def non_terminal_score
  scores.min
end

#terminal_scoreObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/xo/ai/minimax.rb', line 108

def terminal_score
  case result[:type]
  when :winner
    -1
  when :loser
    1
  when :squashed
    0
  end
end