Class: MCTS::Playout

Inherits:
Object
  • Object
show all
Defined in:
lib/mcts/playout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game_state) ⇒ Playout

Returns a new instance of Playout.



6
7
8
# File 'lib/mcts/playout.rb', line 6

def initialize(game_state)
  @game_state = game_state.dup
end

Instance Attribute Details

#game_stateObject (readonly)

Returns the value of attribute game_state.



4
5
6
# File 'lib/mcts/playout.rb', line 4

def game_state
  @game_state
end

Instance Method Details

#playObject



10
11
12
13
14
# File 'lib/mcts/playout.rb', line 10

def play
  my_color = @game_state.last_turn_color
  playout
  @game_state.won?(my_color)
end

#playoutObject



16
17
18
19
20
# File 'lib/mcts/playout.rb', line 16

def playout
  until @game_state.finished?
    @game_state.set_move @game_state.generate_move
  end
end