Sha256: f917f37f3a3ee4f836ad0018e29e8ff9f80b17323c4fe607eb81519581f98fd2
Contents?: true
Size: 932 Bytes
Versions: 2
Compression:
Stored size: 932 Bytes
Contents
module MCTS class Root < Node def initialize(game_state) super game_state, nil, nil end def root? true end def best_child children.max_by &:win_percentage end def best_move best_child.move end def explore_tree selected_node = select playout_node = if selected_node.leaf? selected_node else selected_node.expand end won = playout_node.rollout playout_node.backpropagate(won) end def update_won(won) # logic reversed as the node accumulates its children and has no move # of its own if won self.lost else self.won end end private def select node = self until node.untried_moves? || node.leaf? do node = node.uct_select_child end node end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubykon-0.3.1 | lib/mcts/root.rb |
rubykon-0.3.0 | lib/mcts/root.rb |