LucidTaZ / minimax

MiniMax engine for game decision making
MIT License
4 stars 0 forks source link

Cyclic dependency between GameState and Decision #3

Closed LucidTaZ closed 7 years ago

LucidTaZ commented 7 years ago

Currently GameState knows about Decision and vice versa. This is not really good design and should be eliminated. When solved, it will make the program easier to reason about. Also, it doesn't force a bad practice onto interface implementers.

GameState's knowledge lies in GameState::getDecisions(): Decision[] and Decision's knowledge lies in Decision::apply(GameState): GameState.

One possible solution is to move apply from Decision to GameState. It could also help to think about extracting a Board class from GameState and making only that known to Decision. However, care should be taken to keep the interface as simple as needed.

LucidTaZ commented 7 years ago

Note: if we go with the GameState::applyDecision(Decision): GameState approach, we will probably get into trouble with type invariance.

LucidTaZ commented 7 years ago

Solved by removing Decision and moving its concern into GameState. #5