2 * Helper to test game_do_move function.
3 * Copyright © 2022-2023 Nick Bowler
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.
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.
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/>.
23 #include "game-notime.h"
25 static const char *progname;
27 void show_board(uint_fast32_t shape)
31 for (i = 0; i < 5; i++) {
32 unsigned row = (shape >> 5*i) & 0x1f;
34 for (j = 0; j < 5; j++) {
35 printf("%c", row & 1 ? '@' : '.');
42 static void print_usage(FILE *f)
44 fprintf(f, "Usage: %s sequence\n", progname);
47 static int get_seq(char c)
49 if (c >= '0' && c <= '4') {
54 fprintf(stderr, "%s: unexpected end of sequence\n", progname);
56 fprintf(stderr, "%s: invalid character %c\n", progname, c);
61 int main(int argc, char **argv)
76 board.x = get_seq(seq[i++]);
77 board.y = get_seq(seq[i++]);
79 board.game[0] = GAME_MASK ^ board_position(board.x, board.y);
80 board.game[1] = board.game[2] = board.game[3] = board.game[0];
85 show_board(board.game[0]);
86 for (j = 1; j < 4; j++) {
87 if (board.game[j] != board.game[0]) {
88 fprintf(stderr, "%s: plane %d mismatch\n",
90 board.game[j] = board.game[0];
95 x = get_seq(seq[i++]);
96 y = get_seq(seq[i++]);
97 game_do_move(&board, x, y);