55 if (!state.
cards[card].players[question.
player])
return false;
61 if (*set == 0) *set = 1;
64 state_copy.
cards[card].players = std::vector<bool>(settings.
NUM_PLAYERS,
false);
65 state_copy.
cards[card].players[question.
player] =
true;
67 if (!
valid_state(settings, state_copy))
return false;
92 std::cerr <<
"Player is out of bounds." << std::endl;
97 std::cerr <<
"Set is out of bounds." << std::endl;
102 std::cerr <<
"Card is out of bounds." << std::endl;
107 std::cerr <<
"You cannot ask yourself a question." << std::endl;
112 std::cerr <<
"You cannot ask a card from a quartet." << std::endl;
117 std::cerr <<
"Player " << question.
player <<
" does not have any cards." << std::endl;
121 bool *valid_answers =
new bool[2];
123 valid_answers[0] =
valid_answer(settings, state, question,
false);
124 valid_answers[1] =
valid_answer(settings, state, question,
true);
126 return !valid_answers[0] && !valid_answers[1] ? NULL : valid_answers;
This file defines print operator headers for custom structs and a template for printing a vector....
bool graph_possible(const Settings &settings, const State &state)
Check if it is possible to create a graph.
Graph graph_create(const Settings &settings, const State &state)
Create a biparite graph which has a matching if the state is valid.
This file defines the graph type and a creation function header.
std::vector< std::vector< bool > > Graph
A bipartite graph where true booleans represent edges between a left node denoted as the row and a ri...
bool match_exists(const Graph &graph)
Check if there exists a matching for all cards.
This file defines maximum matching algorithm function headers.
This file defines the structs for a question and typedef of an answer.
bool Answer
An answer returned by a player. The answer is either true or false denoting he/she has or does not ha...
This file defines the settings struct.
State copy_state(const State &state)
Copy the old state to a new state.
int info_num_cards(const Settings &settings, const State &state, int player)
Get the number of cards the player has without counting the cards from quartets, so the actual number...
This file defines the structs for a card, player and a game state, plus a state initialize and copy f...
A question asked by a player. The player asks another player for a specific card from a certain set.
int set
The set the card which is asked belongs to.
int player
The player the question is asked to.
int card
The card in the set which is asked for.
The settings which characterize a game.
const int NUM_SETS
The number of sets.
const int SET_SIZE
The size of one set, aka the number of cards in one set.
const int NUM_PLAYERS
The number of players playing the game.
std::vector< Player > players
The information on all the players.
std::vector< Card > cards
The information on all the cards.
int onturn
The player who is on turn.
std::vector< int > quartets
The information of who has a certain quartet.
void update_state(const Settings &settings, State &state, const Question &question, const Answer &answer)
Update the state of the game according to the question asked and the answer which is given.
This file defines the state update function headers.
bool valid_state(const Settings &settings, const State &state)
Check if there exists a matching for the given state.
bool valid_answer(const Settings &settings, const State &state, const Question &question, const Answer &answer)
Check if the question asked and the answer given are valid.
bool * valid_question(const Settings &settings, const State &state, const Question &question)
Check if the question asked is valid.
This file defines function headers for functions that can check if a question or state is valid.