clean up header

This commit is contained in:
Maximilian Keßler 2023-08-04 16:55:41 +02:00
parent 7bcb018244
commit 362d121930
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 41 additions and 43 deletions

View file

@ -47,20 +47,9 @@ struct Card {
rank_t rank; rank_t rank;
uint8_t copy; uint8_t copy;
Card& operator++() { Card& operator++();
rank++; Card successor() const;
return *this; const Card operator++(int);
}
Card successor() {
return {suit, static_cast<rank_t>(rank + 1)};
}
const Card operator++(int) {
Card ret = *this;
rank++;
return ret;
}
auto operator<=>(const Card&) const = default; auto operator<=>(const Card&) const = default;
}; };
@ -93,28 +82,7 @@ template<std::size_t num_suits>
using Stacks = std::array<rank_t, num_suits>; using Stacks = std::array<rank_t, num_suits>;
template<std::size_t num_suits> template<std::size_t num_suits>
std::ostream& operator<<(std::ostream& os, const Stacks<num_suits>& stacks) { std::ostream& operator<<(std::ostream& os, const Stacks<num_suits>& stacks);
for (size_t i = 0; i < stacks.size() - 1; i++) {
os << +stacks[i] << ", ";
}
os << +stacks.back();
return os;
}
template <std::size_t num_suits>
struct CardSetSpecification {
using AdditionalCardsFlags = std::bitset<num_suits * (starting_card_rank - 1)>;
Stacks<num_suits> stacks {};
AdditionalCardsFlags additional_cards_flags {};
};
template <std::size_t num_suits, std::size_t num_players, std::size_t hand_size>
struct PartialHanabiInstance {
std::array<boost::container::static_vector<Card, hand_size>, num_players> initial_cards;
CardSetSpecification<num_suits> initial_state;
};
struct CardMultiplicity { struct CardMultiplicity {
Card card; Card card;
@ -126,13 +94,9 @@ struct CardMultiplicity {
template<std::size_t num_suits> template<std::size_t num_suits>
struct CardPositions { struct CardPositions {
const player_t & operator[](const Card& card) const { const player_t & operator[](const Card& card) const;
return _card_positions[card.suit][card.rank][card.copy];
};
player_t & operator[](const Card& card) { player_t & operator[](const Card& card);
return _card_positions[card.suit][card.rank][card.copy];
};
auto operator<=>(const CardPositions&) const = default; auto operator<=>(const CardPositions&) const = default;
@ -189,7 +153,7 @@ public:
}; };
template <std::size_t num_suits, std::size_t num_players, std::size_t hand_size, std::uint8_t max_draw_pile_size> template <std::size_t num_suits, std::size_t num_players, std::size_t hand_size, std::uint8_t max_draw_pile_size>
std::ostream& operator<<(std::ostream& os, const HanabiState<num_suits, num_players, hand_size, max_draw_pile_size> hanabi_state); std::ostream& operator<<(std::ostream& os, HanabiState<num_suits, num_players, hand_size, max_draw_pile_size> hanabi_state);
#include "game_state.hpp" #include "game_state.hpp"

View file

@ -3,6 +3,40 @@
#include <iterator> #include <iterator>
Card& Card::operator++() {
rank++;
return *this;
}
Card Card::successor() const {
return {suit, static_cast<rank_t>(rank + 1)};
}
const Card Card::operator++(int) {
Card ret = *this;
rank++;
return ret;
}
template<std::size_t num_suits>
std::ostream& operator<<(std::ostream& os, const Stacks<num_suits>& stacks) {
for (size_t i = 0; i < stacks.size() - 1; i++) {
os << +stacks[i] << ", ";
}
os << +stacks.back();
return os;
}
template<std::size_t num_suits>
const player_t & CardPositions<num_suits>::operator[](const Card& card) const {
return _card_positions[card.suit][card.rank][card.copy];
};
template<std::size_t num_suits>
player_t & CardPositions<num_suits>::operator[](const Card& card) {
return _card_positions[card.suit][card.rank][card.copy];
};
template <size_t num_suits, size_t num_players, size_t hand_size, uint8_t max_draw_pile_size> template <size_t num_suits, size_t num_players, size_t hand_size, uint8_t max_draw_pile_size>
Action HanabiState<num_suits, num_players, hand_size, max_draw_pile_size>::clue() { Action HanabiState<num_suits, num_players, hand_size, max_draw_pile_size>::clue() {
assert(_num_clues > 0); assert(_num_clues > 0);