#include "web_match.h" #include "match.h" #include #include #include struct match_state *state; struct match_opts *match_opts; void free_state() { state->legs[1]->n_visits += state->boat_undone; // avoid memory leak leg_free(state->legs[0]); leg_free(state->legs[1]); free(state); state = NULL; } void match_opts_free() { free(match_opts); match_opts = NULL; } int match_num_players() { if (state->mode == M_P) return 1; return 2; } int match_winning_player() { for (int i = 0; i < match_num_players(); ++i) { if (state->legs[i]->rem == 0) return i + 1; } return -1; } bool match_is_over() { return match_winning_player() != -1; } struct leg *state_active_leg() { return state->legs[state->active_player - 1]; }