A little app to simulate every possible move in Connect Four.
1#include "win_test.h"
2#include "../core.h"
3
4#include <stdio.h>
5
6bool win_test(Game games[10], bool fail_on_win /* = false */)
7{
8 init_core();
9
10 for (uint8_t i = 0; i < 10; ++i)
11 {
12 BoardState state;
13 init_board(state);
14 uint8_t player = 0;
15
16 int8_t row;
17 for (uint8_t j = 0; j < games[i].num_moves; ++j)
18 {
19 row = make_move(player, games[i].moves[j], state);
20 player = 1 - player;
21 }
22
23 if (fail_on_win == check_for_win(state, 1 - player, row, games[i].moves[games[i].num_moves - 1]))
24 {
25 printf("Failed on game %d\n", i);
26 print_board(state);
27 return false;
28 }
29 }
30
31 return true;
32}