- unsigned x = i/5, y = i%5;
- uint_fast32_t position;
-
- position = board_position(x, y);
- if (tiles[i] != TILE_EMPTY) {
- if (tiles[i] & 1)
- board->game[0] |= position;
- if (tiles[i] & 2)
- board->game[1] |= position;
- if (tiles[i] & 4)
- board->game[2] |= position;
- } else {
- board->game[3] = 0x1ffffff ^ position;
- board->x = x;
- board->y = y;
+ assign_tile(board->game, tiles[i], i);
+
+ if (tiles[i] == TILE_EMPTY) {
+ board->game[3] = (1ul<<i);
+ board->x = i%5;
+ board->y = i/5;
+ }
+ }
+
+/* Uncomment to make every game stupidly easy -- winnable in 1 move */
+#if 0
+ /* Force empty space to the border */
+ if (board_position(board->x, board->y) & GOAL_MASK) {
+ switch (rng_uniform_int(4)) {
+ case 0: game_do_move(board, board->x, 0); break;
+ case 1: game_do_move(board, board->x, 4); break;
+ case 2: game_do_move(board, 0, board->y); break;
+ case 3: game_do_move(board, 4, board->y); break;