VictorXjoeY / Minimax

Generic Minimax algorithm for 2 player games
2 stars 0 forks source link

Use polymorphism instead of templated functions and classes #3

Open VictorXjoeY opened 3 years ago

VictorXjoeY commented 3 years ago

It would make the code much simpler to use smart pointers and polymorphism instead of all the crazy template parameters that are passed everywhere. We can also use inheritance for nested classes: KonaneGame::State would inherit from Game::State and KonaneGame::Move would inherit from Game::Move.

Game::State could have pure virtual methods: virtual size_t hash() const = 0 and virtual bool operator== (const Game::State& gs) const = 0. Then we could specialize std::hash<Game::State> to call Game::State::hash().

Note: I currently don't now of a way to enforce that classes that inherit from Game implement the two nested classes Game::State and Game::Move.