~lucymcphail/tic-tac-toe

cfdae10d7ee4c93042f8860443dce78444765b51 — Lucy McPhail 2 months ago 1c35ce3
Add some simple pruning
2 files changed, 5 insertions(+), 1 deletions(-)

M src/engine.c
M src/main.c
M src/engine.c => src/engine.c +3 -0
@@ 99,6 99,9 @@ int eval_board(Board board, State player)
    int max_score = -2;
    for (size_t i = 0; i < legal_moves_size; ++i) {
	int score = eval_move(board, player, legal_moves[i]);
	/* if we see a score of 1 we can stop looking */
	if (score == 1)
	    return 1;
	if (score > max_score)
	    max_score = score;
    }

M src/main.c => src/main.c +2 -1
@@ 4,6 4,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define FONT_SIZE 72
#define PIECE_FONT_SIZE 200


@@ 133,7 134,7 @@ int main(void)
    SetTargetFPS(60);

    /* seed rng */
    srand(GetTime());
    srand(time(NULL));

    while (!WindowShouldClose()) {
        State winner = check_winner(board);