21 Graph graph_clone(graph.size(), std::vector<bool>(graph.size()));
22 for (
size_t i = 0; i < graph.size(); i++)
23 for (
size_t j = 0; j < graph[i].size(); j++)
24 graph_clone[i][j] = graph[i][j];
53 int minimum = state.
players[player].sets[set];
54 while (minimum-- > 0) {
55 int card_start = set * settings.
SET_SIZE;
56 for (
int card = card_start; card < card_start + settings.
SET_SIZE; card++)
57 if (state.
cards[card].players[player])
58 graph[hand_offset + hand_entry][card] =
true;
77 for (
int set = 0; set < settings.
NUM_SETS; set++) {
78 graph_set(settings, state, graph, player, set, hand_offset, hand_entry);
79 hand_entry += state.
players[player].sets[set];
83 while (hand_entry < state.
players[player].num_cards) {
85 if (state.
cards[card].players[player])
86 graph[hand_offset + hand_entry][card] =
true;
107 Graph graph(NUM_CARDS, std::vector<bool>(NUM_CARDS,
false));
111 for (
int player = 0; player < settings.
NUM_PLAYERS; player++) {
112 graph_player(settings, state, graph, player, hand_offset);
113 hand_offset += state.
players[player].num_cards;
void graph_set(const Settings &settings, const State &state, Graph &graph, int player, int set, int hand_offset, int hand_entry)
Add all the edges representing the set constraints for a player.
bool graph_possible(const Settings &settings, const State &state)
Check if it is possible to create a graph.
void graph_player(const Settings &settings, const State &state, Graph &graph, int player, int hand_offset)
Add all the edges representing the given player.
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...
This file defines the settings struct.
This file defines the structs for a card, player and a game state, plus a state initialize and copy f...
The information connected to a player.
std::vector< int > sets
The number of cards the player at least has from a certain set.
int num_cards
The number of cards this player has.
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.