7 static const char *progname;
9 void show_board(uint_fast32_t shape)
13 for (i = 0; i < 5; i++) {
14 unsigned row = (shape >> 5*i) & 0x1f;
16 for (j = 0; j < 5; j++) {
17 printf("%c", row & 1 ? '@' : '.');
24 static void print_usage(FILE *f)
26 fprintf(f, "Usage: %s sequence\n", progname);
29 static int get_seq(char c)
31 if (c >= '0' && c <= '4') {
36 fprintf(stderr, "%s: unexpected end of sequence\n", progname);
38 fprintf(stderr, "%s: invalid character %c\n", progname, c);
43 int main(int argc, char **argv)
58 board.x = get_seq(seq[i++]);
59 board.y = get_seq(seq[i++]);
61 board.game[0] = 0x1ffffff ^ board_position(board.x, board.y);
62 board.game[1] = board.game[2] = board.game[3] = board.game[0];
67 show_board(board.game[0]);
68 for (j = 1; j < 4; j++) {
69 if (board.game[j] != board.game[0]) {
70 fprintf(stderr, "%s: plane %d mismatch\n",
72 board.game[j] = board.game[0];
77 x = get_seq(seq[i++]);
78 y = get_seq(seq[i++]);
79 game_do_move(&board, x, y);