GAMESMAN a Finite, Two-Person, Perfect-Information Game Generator
Total Page:16
File Type:pdf, Size:1020Kb
GAMESMAN A finite, two-person, perfect-information game generator by Daniel Dante Garcia ([email protected]) B.S. Computer Science and Engineering (Massachusetts Institute of Technology) 1990 B.S. Electrical Engineering (Massachusetts Institute of Technology) 1990 A report submitted in partial satisfaction of the requirements for the degree of Master of Science in Computer Science in the GRADUATE DIVISION of the UNIVERSITY of CALIFORNIA at BERKELEY Committee in charge: Professor Elwyn R. Berlekamp, Chair Professor Brian A. Barsky Abstract “Why write a program when you can write a program to write a program?” – Author unknown This report introduces GAMESMAN, a system for generating graphical parametrizable game applications. Programmers write game ‘modules’ for a specific game, which when combined with our libraries, compile together to become stand- alone X-window applications as shown in Figure A.1 below. The modules only need contain information about the rules of the game and how the game ends. If the game is small-enough, it may be solved, and the computer can play the role of an oracle, or “perfect” opponent. This oracle can advise a novice player how to play, and teach the strategy of the game even though none was programmed into the system! If a game is too large to be solved exhaustively, the game programmer can add heuristics to provide an imperfect computer opponent. Finally, the application can provide a useful utility to two human players who are playing each other, since it be a “referee” who constrains the users’ moves to be only valid moves, can update the board to respond to the move, and can signal when one of the players has won. module for module for module for module for 1210 TicTacToe Tac Tix dodgem GAMESMAN X and text X and text X and text X and text application application application application for for for for 1210 TicTacToe Tac Tix dodgem Figure Abstract.1: The Overall Picture of GAMESMAN 1 Dedication To my parents, Raymond and Deborah, whose enduring love and simple, generous acts of allowing their 6-year-old son to play when he needed to play and to beat them at chess fostered a love for games that has not abated in the 21 years since. - i - Table of Contents 1. Introduction....................................................................................1 2. Definition of Terms ........................................................................2 2.1 Position ........................................................................................ 2 2.2 Slot ............................................................................................... 2 2.3 Piece .............................................................................................2 2.4 Move .............................................................................................3 2.5 Value, or Outcome....................................................................... 3 2.5.1. Win ............................................................................................ 5 2.5.2. Lose ........................................................................................... 5 2.5.3. Tie.............................................................................................. 6 2.5.4. Primitive positions and terminating criteria .......................... 6 2.5.5. Value-equivalent moves. .......................................................... 6 2.6 Perfect opponents ........................................................................7 2.7 Partisan vs. Impartial games ..................................................... 7 2.8 The misère game vs. the standard game ................................... 8 2.9 Solving games..............................................................................9 2.10 Static-evaluation ......................................................................... 9 2.11 MINIMAX Heuristic.................................................................. 11 3. Prior Work .................................................................................... 13 3.1 David Wolfe’s games toolkit...................................................... 13 3.2 Anders Kierulf’s Smart Game Board ....................................... 14 3.3 Rhys Hollow’s Gamemaster...................................................... 15 3.4 What does GAMESMAN provide?............................................ 16 4. What games can be solved by GAMESMAN?............................. 17 4.1 Finite.......................................................................................... 17 4.2 2-Person ..................................................................................... 17 4.3 Perfect Information ................................................................... 18 5. What are the mechanics of generating a game?......................... 20 5.1 Set global variables ................................................................... 20 5.2 Choose a Representation for Positions and Moves.................. 20 5.3 Additional issues if the game is to be solved ........................... 21 5.3.1. Compact .................................................................................. 21 5.3.2. Unique ..................................................................................... 21 5.3.3. Constant-Time Mapping Function ........................................ 22 5.3.4. Example: Tic-Tac-Toe ............................................................. 22 5.4 Write the Subroutines............................................................... 22 6. Categorizing Games..................................................................... 24 6.1 Categorizing games by total number of positions ................... 24 6.1.1. Dart-Board without Capture ................................................. 24 6.1.1.1 Number of moves upper bound ........................................... 25 6.1.1.2 Number of positions upper bound....................................... 25 - ii - 6.1.1.3 Examples .............................................................................. 26 6.1.2. Dart-Board with Capture ....................................................... 26 6.1.2.1 Number of moves upper bound ........................................... 26 6.1.2.2 Number of positions upper bound....................................... 27 6.1.2.3 Examples .............................................................................. 27 6.1.3. Rearranger .............................................................................. 27 6.1.3.1 Number of moves upper bound ........................................... 27 6.1.3.2 Number of positions upper bound....................................... 28 6.1.3.3 Examples .............................................................................. 28 6.1.4. Impartial Removal.................................................................. 28 6.1.4.1 Number of moves upper bound ........................................... 28 6.1.4.2 Number of positions upper bound....................................... 29 6.1.4.3 Examples .............................................................................. 29 6.1.5. Partisan Removal ................................................................... 29 6.1.5.1 Number of moves upper bound ........................................... 29 6.1.5.2 Number of positions upper bound....................................... 29 6.1.5.3 Examples .............................................................................. 30 6.1.6. Hybrids.................................................................................... 30 6.1.7. Comparisons............................................................................ 30 6.2 Categorizing games by type of interactions............................. 31 6.2.1. Single-piece removal/placement ............................................ 32 6.2.2. Single-piece movement........................................................... 32 6.2.3. Multiple-piece removal/placement......................................... 32 6.2.4. Multiple-piece movement ....................................................... 33 6.2.5. Hybrids.................................................................................... 33 6.3 Examples of the categories of popular games.......................... 33 7. User Interface Issues ................................................................... 35 7.1 Customization: giving users the options .................................. 35 7.2 Interactively choosing a move .................................................. 35 7.2.1. Single-piece removal/placement ............................................ 36 7.2.2. Single-piece movement........................................................... 36 7.2.2.1 Outline vs. Opaque drags .................................................... 37 7.2.2.2 Computer-assisted movements ........................................... 37 7.2.3. Multiple-piece removal/placement......................................... 38 7.2.3.1 Single toggle click ................................................................ 39 7.2.3.2 Click-drag selection rectangle ............................................. 39 7.2.3.3 Click-drag selection line ...................................................... 40 7.2.4. Multiple-piece movement ....................................................... 41 7.2.4.1 Group select and move......................................................... 41 7.2.4.2 Individual select and move.................................................