summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-09-05 04:11:10 +0300
committereug-vs <eugene@eug-vs.xyz>2022-09-05 04:11:10 +0300
commit12117d2ae40ca1d0db503bf0cb5e0e99ac986762 (patch)
tree933f5e3f0ef53e4084554d68f29254899bf19cb4
parent9e2ecdff65a73cc4e38b8cb35503363097acb863 (diff)
downloadc-chess-12117d2ae40ca1d0db503bf0cb5e0e99ac986762.tar.gz
feat: write game moves to file
-rw-r--r--src/main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index c1c7ee8..3468405 100644
--- a/src/main.c
+++ b/src/main.c
@@ -174,13 +174,6 @@ void index_to_notation(int index, char notation[2]) {
notation[1] = (index >> 4) + '1';
}
-void print_move(Move move) {
- char move_in_notation[] = "xy XY";
- index_to_notation(move.origin, move_in_notation);
- index_to_notation(move.destination, move_in_notation + 3);
- printf("%s\n", move_in_notation);
-};
-
Move input_move() {
Move move;
char file;
@@ -637,6 +630,8 @@ Move minimax_search(int* board, int color, int depth, int alpha, int beta, int*
}
int main() {
+ FILE* record;
+
int board[128];
parse_FEN(DEFAULT_FEN, board);
@@ -651,6 +646,7 @@ int main() {
}
Move move;
+ char move_in_notation[] = "xyXY";
print_board(board);
@@ -663,6 +659,8 @@ int main() {
if (color == PLAYER) {
printf("Enter a move for %s:\n", COLORS[color]);
move = input_move();
+ index_to_notation(move.origin, move_in_notation);
+ index_to_notation(move.destination, move_in_notation + 2);
} else {
printf("Evaluating move for %s...\n", COLORS[color]);
clock_t start, end;
@@ -673,9 +671,8 @@ int main() {
printf("[%i positions analyzed in %f seconds]\n", metrics, (double)(end - start) / CLOCKS_PER_SEC);
printf("[Transposition table cardinality: %i]\n", TRANSPOSITION_TABLE_CARDINALITY);
- char move_in_notation[] = "xy XY";
index_to_notation(move.origin, move_in_notation);
- index_to_notation(move.destination, move_in_notation + 3);
+ index_to_notation(move.destination, move_in_notation + 2);
printf("%s: %s with evaluation %c=%.2f on Ply %i\n", COLORS[color], move_in_notation, color == WHITE ? '>' : '<', (double)move.value / 10, ply + MAX_DEPTH);
}
@@ -688,9 +685,12 @@ int main() {
} else {
hash = hash_after_move(move, board, zobrist_seed, hash);
make_move(move, board);
-
print_board(board);
+ record = fopen("record.txt", "a");
+ fprintf(record, "%s ", move_in_notation);
+ fclose(record);
+
ply++;
}
}