![]() |
Cluedo Solver v1.0
Cluedo game solver making deductions.
|
The solver of a Cluedo game. More...
#include <Solver.hpp>
Classes | |
struct | Suggestion |
A struct that contains the data of a suggestion. More... | |
Public Types | |
using | SolutionProbabilityPair = std::pair<std::tuple<Card, Card, Card>, float> |
A pair that contains a solution (a suspect, a weapon and a room) and its probability. | |
Public Member Functions | |
std::size_t | player_count () const |
Player const & | player (std::size_t player_index) const |
Player & | player (std::size_t player_index) |
void | learn_player_card_state (std::size_t player_index, Card card, bool has_card, bool infer_new_info=true) |
void | learn_player_has_any_of_cards (std::size_t player_index, CardSet const &card_set, bool infer_new_info=true) |
void | learn_from_suggestion (Suggestion const &suggestion, bool infer_new_info=true) |
bool | are_constraints_satisfied () const |
Checks if the constraints of the game are satisfied. | |
std::vector< SolutionProbabilityPair > | find_most_likely_solutions () const |
Static Public Member Functions | |
static Result< Solver, Error > | create (std::vector< PlayerData > const &players_data) |
The solver of a Cluedo game.
This class is the heart of the application. It contains the data of the game and takes information to learn new things about the game. It can also find the most likely solutions for the game.
|
static |
Creates a new Solver object given the data of the players.
players_data | The data of the players. |
std::vector< Solver::SolutionProbabilityPair > Cluedo::Solver::find_most_likely_solutions | ( | ) | const |
Finds the most likely solutions for the game.
void Cluedo::Solver::learn_from_suggestion | ( | Suggestion const & | suggestion, |
bool | infer_new_info = true ) |
Learns from a suggestion.
suggestion | The suggestion made in the game. |
infer_new_info | true if new information should be inferred, false otherwise. |
void Cluedo::Solver::learn_player_card_state | ( | std::size_t | player_index, |
Card | card, | ||
bool | has_card, | ||
bool | infer_new_info = true ) |
Learns that a player has a card or not.
player_index | The index of the player. |
card | The card in question. |
has_card | true if the player has the card, false otherwise. |
infer_new_info | true if new information should be inferred, false otherwise. |
void Cluedo::Solver::learn_player_has_any_of_cards | ( | std::size_t | player_index, |
CardSet const & | card_set, | ||
bool | infer_new_info = true ) |
Learns that a player has any of the cards in the given set.
player_index | The index of the player. |
card_set | The set of cards in question. |
infer_new_info | true if new information should be inferred, false otherwise. |
|
inline |
Returns the player at the given index.
player_index | The index of the player. |
|
inline |
Returns the player at the given index.
player_index | The index of the player. |
|
inline |
Returns the number of players in the game.