From 1231e4da920c530ac51c83d241d57926e462abfc Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Thu, 6 Feb 2025 15:57:21 +0100 Subject: [PATCH] added the less than operator to store the objects in maps --- cpp/src/board.hpp | 5 +++++ cpp/src/move.hpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cpp/src/board.hpp b/cpp/src/board.hpp index e58ccb9..b2d8e0d 100644 --- a/cpp/src/board.hpp +++ b/cpp/src/board.hpp @@ -57,3 +57,8 @@ struct Board { return colour_at(xy.to_index()); } }; + +inline bool operator<(const Board& m1, const Board& m2) { + return m1.to_fen() < m2.to_fen( + ); // TODO: make this the comparison between the hash of the board +} diff --git a/cpp/src/move.hpp b/cpp/src/move.hpp index 1e1b0f7..0f358b6 100644 --- a/cpp/src/move.hpp +++ b/cpp/src/move.hpp @@ -39,6 +39,10 @@ struct Move { } }; +inline bool operator<(const Move& m1, const Move& m2) { + return m1.to_string() < m2.to_string(); +} + inline std::ostream& operator<<(std::ostream& os, const Move& m) { os << m.to_string(); return os;