Class: HighestPayingNextMovePlayer

Inherits:
Threesmodel::BaseGameAutomation show all
Defined in:
lib/solvers/highest_paying_next_move_player.rb

Instance Method Summary collapse

Methods inherited from Threesmodel::BaseGameAutomation

#initialize, #play_many, #score_filename, #update_highest_value_histogram

Constructor Details

This class inherits a constructor from Threesmodel::BaseGameAutomation

Instance Method Details

#playObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/solvers/highest_paying_next_move_player.rb', line 4

def play
  while (not @game[:game_over]) do
    possible_moves = [:fold_right, :fold_left, :fold_up, :fold_down]
    possible_moves.select! do |move|
      @game_board_folder.send("can_#{move.to_s}?".to_sym, @game[:game])
    end

    scored_moves = possible_moves.map do |move|
      [move, @score_calculator.score_for(@game_board_folder.send(move, @game[:game]))]
    end
    new_move = scored_moves.max{ |a, b| a[1] <=> b[1] }[0]
    @game = @game_controller.send(new_move, @game[:id])
  end
  @game[:score]
end