Unitile is a game for two players, Red and Blue, on a 5×5 board. Every cell but one holds a red tile or a blue tile. The board has twelve red tiles and twelve blue tiles. The one unoccupied cell is called the bubble.
In the starting position, the bubble is the center cell. The 24 tiles fill the other cells in reading order, from left to right within each row, and row by row from the top. The colors of the tiles alternate in that order. The first tile, in the top left corner, is blue. Figure 1 shows the starting position.
The players alternate sliding tiles, one slide per turn, starting with Red. On your turn, you choose a tile of either color that is orthogonally adjacent to the bubble and slide it into the bubble. The cell that the tile has left becomes the new bubble.
A group is a maximal set of orthogonally interconnected, same-colored tiles. A color is united when all of its tiles form a single group. The game ends as soon as a move unites a color. The player of that color wins. A move can unite the opponent’s color, and a player who makes such a move loses.
Each color has a value, the average number of random slides needed to unite the tiles of that color, starting from the current position. Every move must lower the total of the two values, except a move that unites a color. Such a move ends the game and is always legal. This rule guarantees that the player to move always has a legal move, that no position can repeat, and that every game ends with a winner.
The values cannot be worked out by hand, so this app puts a green dot on every tile that can legally slide. In Figure 2, Red has slid the red tile above the bubble down, and a white ring marks it. Three tiles can now slide, and each of them has a green dot. Sliding the red tile back up would return to the starting position, and that slide is not legal.
The values, the rule, and the proof that the rule always leaves a legal move are explained in Unitile_rules.pdf at marksteeregames.com.
Feel free to publish these rules and to program the game of Unitile. No licensing fee or royalties are expected. However, please don’t change the name or the rules, and please attribute the game to me, Mark Steere. My other games can be found at marksteeregames.com.
The app knows every legal move from a table computed in advance from the values. A second table, also computed in advance, tells which player wins every position with perfect play. With perfect play, Blue, the second player, wins.
Six computer levels. Level 1 slides at random. Levels 2 to 5 use Monte Carlo tree search. Before each move, they play out random games from the current position, steering more of the games through the slides that are doing well. Levels 2 and 3 play 3 games per move, level 4 plays 16, and level 5 plays 300. Levels 3 to 5 play the slide their search tried most. Level 2 picks a slide in proportion to how often its search tried it, which keeps it only a little stronger than random play. Levels 2 to 5 always take a slide that unites their own color when there is one. Level 6, Unbeatable, always plays perfectly. When it can win, it takes the fastest win. When it cannot, it drags the game out as long as it can, to give you more chances to go wrong. Against level 6, a player who takes Red cannot win.
With Confirm moves on, a tap on a legal tile marks it with a dashed gold outline and shows it faintly in the bubble. Confirm slides it, and so does a second tap on the tile. A tap on another legal tile chooses that tile instead. A tap anywhere else, or on the Undo button, cancels the choice. With Confirm moves off, a tap slides the tile at once. On the menu, each color can be a human or a computer level, so you can play either color, play another person, or set both colors to the computer and watch the game play out. Once a tile has slid, Undo takes back your last move, together with the computer’s reply. In a two-player game, it takes back one move. Undo is greyed out when there is nothing to take back. New game asks before it discards an unfinished game.
The line above the board counts the groups of each color. When marking is on, a green dot marks every tile that can slide, as in Figure 2. A white ring marks the tile that slid last. Hint marks the tile that level 6 would slide. Record shows the game as text that you can copy.