diff --git a/game_state.h b/game_state.h index a306624..586a1e0 100644 --- a/game_state.h +++ b/game_state.h @@ -47,20 +47,9 @@ struct Card { rank_t rank; uint8_t copy; - Card& operator++() { - rank++; - return *this; - } - - Card successor() { - return {suit, static_cast(rank + 1)}; - } - - const Card operator++(int) { - Card ret = *this; - rank++; - return ret; - } + Card& operator++(); + Card successor() const; + const Card operator++(int); auto operator<=>(const Card&) const = default; }; @@ -93,28 +82,7 @@ template using Stacks = std::array; template -std::ostream& operator<<(std::ostream& os, const Stacks& stacks) { - for (size_t i = 0; i < stacks.size() - 1; i++) { - os << +stacks[i] << ", "; - } - os << +stacks.back(); - return os; -} - -template -struct CardSetSpecification { - using AdditionalCardsFlags = std::bitset; - - Stacks stacks {}; - AdditionalCardsFlags additional_cards_flags {}; -}; - - -template -struct PartialHanabiInstance { - std::array, num_players> initial_cards; - CardSetSpecification initial_state; -}; +std::ostream& operator<<(std::ostream& os, const Stacks& stacks); struct CardMultiplicity { Card card; @@ -126,13 +94,9 @@ struct CardMultiplicity { template struct CardPositions { - const player_t & operator[](const Card& card) const { - return _card_positions[card.suit][card.rank][card.copy]; - }; + const player_t & operator[](const Card& card) const; - player_t & operator[](const Card& card) { - return _card_positions[card.suit][card.rank][card.copy]; - }; + player_t & operator[](const Card& card); auto operator<=>(const CardPositions&) const = default; @@ -189,7 +153,7 @@ public: }; template -std::ostream& operator<<(std::ostream& os, const HanabiState hanabi_state); +std::ostream& operator<<(std::ostream& os, HanabiState hanabi_state); #include "game_state.hpp" diff --git a/game_state.hpp b/game_state.hpp index e7b2196..36b3180 100644 --- a/game_state.hpp +++ b/game_state.hpp @@ -3,6 +3,40 @@ #include +Card& Card::operator++() { + rank++; + return *this; +} + +Card Card::successor() const { + return {suit, static_cast(rank + 1)}; +} + +const Card Card::operator++(int) { + Card ret = *this; + rank++; + return ret; +} + +template +std::ostream& operator<<(std::ostream& os, const Stacks& stacks) { + for (size_t i = 0; i < stacks.size() - 1; i++) { + os << +stacks[i] << ", "; + } + os << +stacks.back(); + return os; +} + +template +const player_t & CardPositions::operator[](const Card& card) const { + return _card_positions[card.suit][card.rank][card.copy]; +}; + +template +player_t & CardPositions::operator[](const Card& card) { + return _card_positions[card.suit][card.rank][card.copy]; +}; + template Action HanabiState::clue() { assert(_num_clues > 0);