#include "meeple.h" void initialize_available_meeples(int* available_meeples) { for (int i = 0; i < PLAYERS; i++) available_meeples[i] = PLAYER_MEEPLES; } void refresh_meeple_map(BoardUnit* board, int* meeple_map) { for (int i = 0; i < MAX_STRUCTURES * PLAYERS; i++) meeple_map[i] = 0; for (int i = 0; i < BOARD_UNITS; i++) { if (board[i].meeple) { meeple_map[board[i].structure_group * PLAYERS + (board[i].meeple - 1)]++; } } } int is_allowed_meeple(int meeple, int index, BoardUnit* board, int* meeple_map) { if (board[index].meeple || board[index].feature == 'F' || board[index].feature == ANY || board[index].feature == SEPARATOR ) return 0; int dominator = get_structure_dominator(board[index].structure_group, meeple_map); return dominator == meeple || dominator == 0; } int get_structure_dominator(int structure_group, int* meeple_map) { int dominator = 0; int dominator_meeples = 0; for (int player = 0; player < PLAYERS; player++) { int meeples = meeple_map[structure_group * PLAYERS + player]; if (meeples > dominator_meeples) { dominator_meeples = meeples; dominator = player + 1; } } return dominator; }