35 for (
int player = 0; player < settings.
NUM_PLAYERS; player++)
70 for (
int card = set * settings.
SET_SIZE; card < (set + 1) * settings.
SET_SIZE; card++) {
72 for (
int hand_entry = 0; hand_entry < state.
players[player].num_cards; hand_entry++)
73 graph_restricted[hand_offset + hand_entry][card] =
false;
79 for (
int card = set * settings.
SET_SIZE; card < (set + 1) * settings.
SET_SIZE; card++) {
81 state.
cards[card].players[player] =
true;
106 bool newquartet =
false;
108 for (
int player = 0; player < settings.
NUM_PLAYERS; player++) {
111 std::vector<int> sets(settings.
NUM_SETS, 0);
112 for (
int card = 0; card < state.
players[player].num_cards; card++)
113 sets[match[hand_offset + card] / settings.
SET_SIZE]++;
116 for (
int set = 0; set < settings.
NUM_SETS; set++)
118 if (
update_quartet(settings, state, graph, hand_offset, player, set))
121 hand_offset += state.
players[player].num_cards;
161 if (*set == 0) *set = 1;
167 if (*set > 0) *set -= 1;
182 state.
cards[card].players[question.
player] =
false;
bool graph_possible(const Settings &settings, const State &state)
Check if it is possible to create a graph.
Graph graph_copy(const Graph graph)
Create a copy of the given 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...
std::vector< int > match_find(const Graph &graph)
Find a match of the given graph.
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.
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_onturn(const Settings &settings, State &state, const Question &question)
Update the player onturn such that he has cards for sure.
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.
void update_quartets(const Settings &settings, State &state, const Question &question)
Find if there are new quartets and update the state accordingly.
bool update_quartet(const Settings &settings, State &state, const Graph &graph, int hand_offset, int player, int set)
Update the state such that the given player has the provided set.
This file defines the state update function headers.