]> git.draconx.ca Git - rrace.git/blob - t/checkgoal.c
Mix in PID with initial seed.
[rrace.git] / t / checkgoal.c
1 /*
2  * Helper to test game_check_goal function.
3  * Copyright © 2022-2023 Nick Bowler
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #include <config.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <inttypes.h>
24 #include <errno.h>
25 #include "game-notime.h"
26
27 #define X3(x) x x x
28
29 static const char *progname = "checkgoal";
30
31 int main(int argc, char **argv)
32 {
33         struct board board;
34         int rc;
35
36         if (argc > 0)
37                 progname = argv[0];
38
39         while ((rc = scanf(X3("%" SCNxLEAST32) X3("%" SCNxLEAST16),
40                               &board.game[0], &board.game[1],
41                               &board.game[2], &board.goal[0],
42                               &board.goal[1], &board.goal[2])) == 6)
43         {
44                 printf("%.5" PRIxFAST32 "\n", game_check_goal(&board));
45         }
46
47         if (rc == EOF) {
48                 if (ferror(stdin)) {
49                         fprintf(stderr, "%s: read error: %s\n", progname,
50                                         strerror(errno));
51                         return EXIT_FAILURE;
52                 }
53
54                 return EXIT_SUCCESS;
55         }
56
57         fprintf(stderr, "%s: invalid input sequence\n", progname);
58         return EXIT_FAILURE;
59 }