peter1591 / hearthstone-ai

A Hearthstone AI based on Monte Carlo tree search and neural nets written in modern C++.
302 stars 49 forks source link

Make sure ActionAnalyzer is aligned with BoardView #57

Closed peter1591 closed 7 years ago

peter1591 commented 7 years ago

Currently the usage graph is like:

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:

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:

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.

peter1591 commented 7 years ago

One proposal:

state::PlayerStateView

FlowControl::ValidActionGetter

mcts::BoardView

mcts::ActionAnalyzer

peter1591 commented 7 years ago

Fixed.