diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-29 14:11:42 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-29 14:11:42 +0300 |
commit | 1ce760e73a10da34ef1360f64202d4d03492f859 (patch) | |
tree | 602fbc54d257895dcfeb559700cd5623f53ec37e /src/main.c | |
parent | b77e0ab18c4531c45394951bccc8d5d5b8181ee2 (diff) | |
download | carcassonne-engine-c-1ce760e73a10da34ef1360f64202d4d03492f859.tar.gz |
feat: allow read/write board to file
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -101,25 +101,33 @@ int evaluate_structure(int index, char* board, char* structures) { return value; } +void write_board(char* board, char* filename) { + FILE* file = fopen(filename, "w"); + fprintf(file, "%s\n", board); + fclose(file); +} + +void read_board(char* board, char* filename) { + FILE* file = fopen(filename, "r"); + fgets(board, BOARD_BYTES, file); + fclose(file); +} + int main() { char board[BOARD_BYTES]; char structures[BOARD_BYTES]; initialize_board(board); - initialize_board(structures); + place_tile("RFRCR", translate_coordinate(24), board); + write_board(board, "board.txt"); - place_tile("RFRFR", translate_coordinate(0), board); - place_tile("RCCRR", translate_coordinate(1), board); - place_tile("CFFCC", translate_coordinate(2), board); - place_tile("RRFRF", translate_coordinate(3), board); + initialize_board(structures); create_structure_mask(board, structures); - print_board(board); printf("\n\n"); print_board(structures); - evaluate_structure(translate_coordinate(0), board, structures); - + evaluate_structure(translate_coordinate(24), board, structures); return 0; } |