Minimax.h 750 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef CHESSY_MINIMAX_H
  2. #define CHESSY_MINIMAX_H
  3. #include "MoveGeneration.h"
  4. namespace chessy
  5. {
  6. class MiniMax;
  7. }
  8. class chessy::MiniMax
  9. {
  10. ChessGame& game;
  11. struct BestMove {
  12. Move move;
  13. float value;
  14. inline void overwriteIfBetter(BestMove other)
  15. {
  16. if (other.value > value)
  17. *this = other;
  18. }
  19. inline BestMove operator - (void) const
  20. {
  21. return { move, -value };
  22. }
  23. };
  24. public:
  25. inline MiniMax(ChessGame& game) :
  26. game{ game } {}
  27. Move calculateBest(int depth);
  28. template<Side side>
  29. float evaluate(void) const;
  30. private:
  31. template<Side side>
  32. BestMove minimax(int depth);
  33. };
  34. #endif // CHESSY_MINIMAX_H