diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -49,16 +49,42 @@ int place_tile(char* tile, int position, char* board) { return 1; } +void traverse_structure(char id, int byte, char* board, char* structures) { + structures[byte] = id; + for (int i = 0; i < 4; i++) { + int new_byte = byte + neighbor_increments[i]; + if (board[new_byte] == board[byte] && structures[new_byte] == EMPTY) { + traverse_structure(id, new_byte, board, structures); + } + } +} + +void create_structure_mask(char* board, char* structures) { + char structure_id = '1'; + for (int i = 0; i < BOARD_BYTES; i++) { + if (structures[i] == EMPTY && board[i] != EMPTY && board[i] != 'F') { + traverse_structure(structure_id, i, board, structures); + structure_id += 1; + } + } +} + int main() { char board[BOARD_BYTES]; + char structures[BOARD_BYTES]; + initialize_board(board); + initialize_board(structures); place_tile("RFRFR", 6, board); place_tile("RCCRR", 8, board); place_tile("RRFRF", 18, board); - place_tile("CFFFC", 16, board); + place_tile("CFFCC", 16, board); + create_structure_mask(board, structures); print_board(board); + printf("\n\n"); + print_board(structures); return 0; } |