49 Player const&
player(std::size_t player_index)
const {
return m_players.at(player_index); }
55 Player&
player(std::size_t player_index) {
return m_players.at(player_index); }
104 static constexpr std::size_t MAX_ITERATIONS = 1'000'000;
106 explicit Solver(std::vector<Player>&& players)
107 : m_players(std::move(players)) {}
109 std::size_t solution_player_index()
const {
return m_players.size() - 1; }
111 void infer_new_information();
112 bool assign_cards_to_players(std::vector<Card>
const& cards);
113 bool are_constraints_satisfied_for_solution_search()
const;
115 std::vector<Player> m_players;
The file that contains the definition of the Cluedo::CardSet class.
Card
All the cards in Cluedo.
Definition Card.hpp:66
This file contains the list of errors that can occur in the application.
The file that contains the definition of the Cluedo::Player class.
The file that defines the Result class and the TRY and MUST macros.
A set of cards.
Definition CardSet.hpp:20
The player of a game.
Definition Player.hpp:27
static constexpr std::size_t MAX_PLAYER_COUNT
The maximum number of players that can play a game.
Definition Solver.hpp:27
std::vector< SolutionProbabilityPair > find_most_likely_solutions() const
Definition Solver.cpp:249
Player & player(std::size_t player_index)
Definition Solver.hpp:55
void learn_player_has_any_of_cards(std::size_t player_index, CardSet const &card_set, bool infer_new_info=true)
Definition Solver.cpp:51
bool are_constraints_satisfied() const
Checks if the constraints of the game are satisfied.
Definition Solver.cpp:98
static constexpr std::size_t SOLUTION_CARD_COUNT
The number of cards that make a solution (a suspect, a weapon and a room).
Definition Solver.hpp:28
void learn_player_card_state(std::size_t player_index, Card card, bool has_card, bool infer_new_info=true)
Definition Solver.cpp:34
static constexpr std::size_t MIN_PLAYER_COUNT
The minimum number of players that can play a game.
Definition Solver.hpp:26
Player const & player(std::size_t player_index) const
Definition Solver.hpp:49
std::pair< std::tuple< Card, Card, Card >, float > SolutionProbabilityPair
A pair that contains a solution (a suspect, a weapon and a room) and its probability.
Definition Solver.hpp:96
std::size_t player_count() const
Definition Solver.hpp:42
void learn_from_suggestion(Suggestion const &suggestion, bool infer_new_info=true)
Definition Solver.cpp:74
static Result< Solver, Error > create(std::vector< PlayerData > const &players_data)
Definition Solver.cpp:16
A class that represents a result that can either be a value or an error.
Definition Result.hpp:28
A struct that contains the data of a player.
Definition Solver.hpp:14
std::string name
The name of the player.
Definition Solver.hpp:15
std::size_t card_count
The number of cards held by the player.
Definition Solver.hpp:16
A struct that contains the data of a suggestion.
Definition Solver.hpp:75
std::size_t suggesting_player_index
The index of the player who made the suggestion.
Definition Solver.hpp:76
Card suspect
The suspect suggested.
Definition Solver.hpp:77
std::optional< std::size_t > responding_player_index
The index of the player who responded, if any.
Definition Solver.hpp:80
std::optional< Card > response_card
The card with which the player responded, if known.
Definition Solver.hpp:81
Card weapon
The weapon suggested.
Definition Solver.hpp:78
Card room
The room suggested.
Definition Solver.hpp:79