peter1591/hearthstone-ai

Make sure ActionAnalyzer is aligned with BoardView

Closed this issue · 2 comments

Currently the usage graph is like:

  • mcts::ActionAnalyzer uses state::State and FlowControl::ValidActionGetter
  • mcts::BoardView uses state::State and FlowControl::ValidActionGetter

Ideally, mcts::ActionAnalyzer should only rely on the information of mcts::BoardView, rather than the full information of state::State

One proposal is to make the usage graph like:

  • mcts::BoardView uses state::State and FlowControl::ValidActionGetter
  • mcts::ActionAnalyzer uses mcts::BoardView

But, in current implemention, mcts::BoardView needs a 'copy' of the data members of BoardView.

So, it would be better to implement a mcts::BoardRefView, which

  1. Construct with a reference to state::State
  2. Contains members like RefSelfMinions, RefHandCards, and so on...

Then, the mcts::ActionAnalyzer can uses mcts::BoardRefView to construct action analyzer without unnecessary copy.

The dependency graph will be like:

  • mcts::BoardRefView uses FlowControl::ValidActionGetter
  • mcts::BoardView uses mcts::BoardRefView
  • mcts::ActionAnalyzer uses mcts::BoardRefView

To simplify mcts::BoardRefView, we can just provide some needed online version interfaces for mcts::ActionAnalyzer, and provide traversal bridge interface for mcts::BoardView. In this way, we can eliminate the classes like RefSelfMinions, RefHandCards, etc.

One proposal:

state::PlayerStateView

  • Deck: only report 'count'
  • Opponent Hand Card: only report 'hold_from_turn', 'count'
  • Opponent Secret: report 'class type'
  • Should act like an online filter. Do not store data on members

FlowControl::ValidActionGetter

  • Use only state::PlayerStateView

mcts::BoardView

  • uses only state::PlayerStateView

mcts::ActionAnalyzer

  • uses only state::PlayerStateView

Fixed.