Computer Analysis of the UFO PuzzleJohn Rausch IntroductionUFO was created by Hiroshi Yamamoto and presented by Nob Yoshigahara in February 1998 at the Third Gathering for Gardner in Atlanta, Georgia. The handout had sample problems using a 9 x 9 board that turned out to be much larger than necessary for reasonably difficult problems. Nob subsequently reduced the board to 5 x 5. Papers with 40 or more sample problems for the 5 x 5 board have been circulating in the puzzle collecting community since the presentation. Binary Arts will introduce a commercial version called Lunar Lockout in early 2000. Description of the UFO PuzzleThe standard UFO puzzle uses a 5 x 5 board, exiting pieces and nonexiting pieces. Here, exiting pieces are labeled X, Y and Z and will be referred to as letter pieces. Nonexiting pieces are labeled 1 through 6 and will be referred to as number pieces. Thousands of problems are possible by placing the pieces on the board in different configurations. The primary objective is to move all of the letter pieces to the center. A secondary objective is to do so in a specified minimum number of moves. Letter pieces never begin in the center and are removed whenever they stop there. Number pieces can begin or stop in the center, but are never removed. A move, which is the same for letter and number pieces, is made in steps. For each step, a piece travels left, right, up or down towards another piece, stopping in the next to the piece moved towards. Travel is stopped only by another piece and must always be towards another piece. After stopping, there are 3 possible outcomes: (1) The move ends if a letter piece stops on the center. It must be removed from the board immediately and if it is the last, or only, letter piece, the problem has been solved. However, a letter piece may travel through the center.(2) The move may end and another piece may move. (3) The move may continue by turning the piece 90 degrees and traveling towards another piece. In the sample problem in figure 1, there are 3 possible moves for piece X. It can move down to 42 [1 step], down to 42 and right to 43 [2 steps] or down to 42, right to 43 and up to 23 [3 steps]. Piece 4 can move up to 32. These are the only possible first moves. Note that piece X passes through the center in move 1 of the solution, but is not removed until move 3 when it stops there.
Fig. 1. Sample Problem. Problem AnalysisAnalysis was done for all problems on the 5 x 5 board having 1 letter piece with 1 to 6 number pieces, 2 letter pieces with 1 to 5 number pieces and 3 letter pieces with 1 to 4 number pieces. Experiments with other board shapes and sizes were also done. One of the best was the 7 x 7 English Cross style peg solitaire board. Analysis was done for all problems on this solitaire board having 1 letter piece with 1 to 5 number pieces, 2 letter pieces with 1 to 4 number pieces and 3 letter pieces with 1 to 3 number pieces. Limited analysis was done for more complex problems on both boards. The analysis programs are written in the PL/I programming language using the professional version of IBM’s PL/I compiler for the Windows operating system. This compiler generates very efficient machine language making it a good choice for compute intensive programs. The analysis was run on an IBM PC compatible with a 333mhz Pentium II processor. The longest running problem group (i.e., combinations of letter and number pieces) was group 3-3 for the solitaire board, taking 6 hours. With problem groups having more letter or number pieces than those completely analyzed, the number of problems increases greatly. Individual problems become so complex (thousands of problems with more than 500 million positions!) that many take several minutes to analyze. For example, it takes several days to solve the problems for a single placement of pieces X, Y and Z in problem group 3-5 for either board. A faster processor would make a difference, but not enough. Furthermore, the problems in these groups tend to be so difficult that most humans would never solve them, and it seems a bit odd to use a computer to create problems that only a computer can solve. Some have been included in the sample problems shown in figures 10 and 11. The basic analysis is done in two steps. The first step creates all of the problems for a problem group. To reduce the number of problems analyzed, rotations and reflections are eliminated. Additional measures further reduce the number of problems. All problems where no move is possible are omitted. Next some simple checks determine if any letter piece is stranded. A letter piece is stranded when it is impossible to maneuver it and another piece into squares opposite the center. The second step attempts to solve all problems for a problem group. The solver program uses a modified depth-first search. It finds all minimum-move, minimum-step solutions. For many problems, solutions exist where one or more of the number pieces are insignificant. That is, they do not move and do not stop other pieces from moving. In figure 2, problem 1a from problem group 1-2 is solved by simply moving piece X down. Piece 1, is insignificant. Excluding rotations and reflections, in this problem there are 12 insignificant placements for piece 1. If the insignificant piece in problem 1a is ignored, problem 1b from problem group 1-1 is identical. Problem 2a has 2 solutions with 4 moves and 6 steps. One (2-D 1-R 4-LU X-RD) uses all of the number pieces. The other (3-L 2-D 4-LU X-RD) does not use piece 1. Therefore, if the insignificant piece in the second solution for problem 2a is ignored, problem 2b from problem group 1-4 is identical. For the human solver, insignificant pieces generally make it easier to meet the primary objective of moving all of the letter pieces to the center, while making it harder to meet the secondary objective to do so in a specified minimum number of moves. A good collection of problems will always include some with insignificant pieces to enhance the human solver’s experience. However, because this analysis is dealing with optimum solutions, problems with insignificant pieces are not included in the solution counts in tables 1 and 2.
Fig. 2. Problems with insignificant number pieces For all problems with solutions, the solver program writes text files of the solutions for visual browsing and a compact binary solution file for further analysis. Tables 1 and 2 show a summary of the solver program results.
Table 1. 5 x 5 board. ^{1}Letter and number piece count.
Table 2. Solitaire board. ^{1}Letter and number piece count. Solution AnalysisTwo additional programs were used to analyze the solutions. One is used to select and sort solutions meeting different criteria. For example, all problems having solutions with a minimum or maximum number of moves or steps can be selected. In addition to moves, steps and position of the pieces, it can use, as selection criteria, the sum of moves and steps, the difference between moves and steps, and moves as a percentage of steps. The other program is used to analyze number-piece configurations. It processes all of the solutions from the solver program, ignoring letter piece placement. Rotations and reflections of the number-piece configurations are normalized into a single form and looked up a table where an occurrence count is kept. After all solutions have been processed, the table is sorted in ascending or descending sequence to determine the number-piece configurations with the least or most occurrences. The results of the analysis suggest some challenging new problems presented in the following sections. Configurations with the Most Solvable ProblemsWhen solutions with insignificant number pieces are included, there are several number-piece configurations where piece X can be placed in any vacant square except the center and all of the resulting problems are solvable. For the 5 x 5 board, there are 215 from problem group 1-5 and 3,239 from problem group 1-6. For the solitaire board, there is 1 from problem group 1-4 and 6 from problem group 1-5. These are the only analyzed problems groups, for either board, with number-piece configurations where all problems are solvable. A few of the number-piece configurations with the most solvable problems where all number pieces are significant are shown in figures 3, 4 and 5. Remember that letter pieces never begin in the center. Answers are at the end of the article. Configuration 1 in figure 3, from problem group 1-4, has 16 solvable problems where all number pieces are significant. This is the most of any analyzed problem group for the 5 x 5 board. Can you find the 4 problems where no solution is possible? Configurations 2 and 3 in figure 3, from problem group 1-5, each have 15 solvable problems where all number pieces are significant. The other 4 problems for each configuration are solvable, but have insignificant number pieces. Can you find them? Configuration 4 in figure 3, from problem group 1-6, has 13 solvable problems where all number pieces are significant. This is the most for this problem group. The other 6 problems are solvable, but have insignificant number pieces. Can you find them?
Fig. 3. Place X in any vacant square and solve the resulting problem. Configurations 1, 2 and 3 in figure 4, from problem group 1-5, all have 23 solvable problems where all number pieces are significant. Each configuration also has 3 unsolvable problems and 2 solvable with insignificant number pieces. Can you find them?
Fig. 4. Place X in any vacant square and solve the resulting problem. Configuration 1 in figure 5, from problem group 2-5, has 146 solvable problems where all number pieces are significant. The other 25 problems are solvable, but have insignificant number pieces. Can you find them? Configuration 2 in figure 5, from problem group 2-4, has 155 solvable problems where all number pieces are significant This is the most of any analyzed problem group for the 5 x 5 board. Only one of the remaining 35 problems is solvable, but has insignificant number pieces. Can you find it? Can you find the 34 unsolvable problems?
Fig. 5. Place pieces X and Y in any vacant squares and solve the resulting problem. Configurations with One Solvable ProblemThere are numerous number-piece configurations where only one letter piece placement is solvable. Finding the placement is challenging for the simplest problems. For more complex problems, it can be very difficult. Figure 6 shows 4 of the 59 number-piece configurations from problem group 1-5 where only one placement of piece X is solvable and all number pieces are significant. Can you find it?
Fig. 6. Find the only placement for piece X with a solution. Figure 7 shows 3 of the 458 number-piece configurations from problem group 1-5 where only one placement of piece X is solvable and all number pieces are significant. Can you find it?
Fig. 7. Find the only placement for piece X with a solution. Figure 8 shows 4 of the 11 number-piece configurations from problem group 2-5 where only one possible placement for pieces X and Y is solvable and all number pieces are significant. Can you find it?
Fig. 8. Find the only placement for pieces X and Y with a solution. Figure 9 shows 3 of the 55 number-piece configurations from problem group 2-4 where only one possible placement for pieces X and Y is solvable and all number pieces are significant. Can you find it?
Fig. 9. Find the only placement for pieces X and Y with a solution. ConclusionsThe UFO puzzle is one of the most interesting new puzzles of its type. While this article has shown that problems exist for the 5 ´ 5 and solitaire boards that are, perhaps, too difficult to be fun, the problems with around 5 to 7 moves seem to be fun and challenging for most people. When released by Binary Arts, Lunar Lockout will have 40 problem cards, 1 exiting piece and 5 nonexiting pieces. Only 3 of the problems require 6 or more moves. Hiroshi Yamamoto selected the 40 problems from computer-produced solutions by Nob Yoshigahara. Harry Nelson served as problem tester and critic. Other members of the NOBrain Corps and the Har-e-brain Corps also tested problems. If Lunar Lockout is successful, at least one additional card set, including an additional exiting piece will follow. Sample ProblemsThese sample problems vary from simple to extremely difficult. They are not all necessarily representative of those that are fun for most human solvers. Problems 5 to 8 in figure 11 are from problem groups with incomplete analysis.
Fig. 10. Sample 5 x 5 problems.
Fig. 11. Sample solitaire problems. Answers
AcknowledgmentsI would like to thank Harry Nelson for his helpful review of analysis results, his thorough review of this article and his valuable suggestions--analyzing number-piece configurations being, by far, the best one. |