aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-29 14:11:42 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-29 14:11:42 +0300
commit1ce760e73a10da34ef1360f64202d4d03492f859 (patch)
tree602fbc54d257895dcfeb559700cd5623f53ec37e /src/main.c
parentb77e0ab18c4531c45394951bccc8d5d5b8181ee2 (diff)
downloadcarcassonne-engine-c-1ce760e73a10da34ef1360f64202d4d03492f859.tar.gz
feat: allow read/write board to file
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 65567b8..d74335c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}