Introduction to Using Games in Education: A Guide for Teachers and Parents Chapter 6 Two-Player Games There are many different kinds of two-person games. You may have played a variety of these games such as such as chess, checkers, backgammon, and cribbage. While all of these games are competitive, many people play them mainly for social purposes. A two-person game environment is a situation that facilitates communication and companionship. Two major ideas illustrated in this chapter: 1. Look ahead: learning to consider what your opponent will do as a response to a move that you are planning. 2. Computer as opponent. In essence, this makes a two-player game into a one- player game. In addition, we will continue to explore general-purpose, high-road transferable, problem-solving strategies. Tic-Tac-Toe To begin, we will look at the game of tic-tac-toe (TTT). TTT is a two-player game, with players taking turns. One player is designated as X and the other as O. A turn consists of marking an unused square of a 3x3 grid with one’s mark (an X or an O). The goal is to get three of one’s mark in a file (vertical, horizontal, or diagonal). Traditionally, X is the first player. A sample game is given below. Page 95 Introduction to Using Games in Education: A Guide for Teachers and Parents X X X O X O Before X's O's X's game first first second begins move move move X X X X O X X O X O O O X O X O X O X O X O O's X's O's X wins on second third third X's fourth move move move move Figure 6.1. Example of a Tic-Tac-Toe game. TTT provides a good environment in which to explore how a computer can play a game. You are familiar with the idea of random numbers. For example, if you designate one side of a “true” coin as a 0, and the other side as a 1, then repeating flipping this coin generates a random sequence of 0’s and 1’s. If you repeatedly toss a “true” six-sided die, you will generate a random sequence of integers in the range [1, 6]. In many games, a spinner is used to generate random moves. The process of shuffling a deck of cards is a process of randomizing the locations of the cards in a deck. Randomness is a complex area of study. For example, suppose you throw a pair of “true” dice, and add up the total. You will get an integer in the range [2,12]. However, a sequence of such throws will not produce a random sequence of number in this range. Some numbers, such as 2 and 12, will occur much less frequency than others. The number 7 will occur far more frequently than 2 or 12. The study of this and related types of situations is part of the field of probability. It turns out that random numbers are quite important in many non-game settings. For example, an educational researcher is conducting an experiment in which one set of students receives a certain treatment, and a different set receives a different treatment. To decide which student gets a particular treatment, all of the student names are written on identical small pieces of cardboard and places in a box. The box is then thoroughly shakes and contents thoroughly stirred. Then names are drawn out one at a time, alternately placing the name into the group to receive the first treatment or the group to receive the second treatment. Computer programs have been developed that generate pseudorandom numbers. (See http://en.wikipedia.org/wiki/Pseudorandomness.) Quoting from the Wikipedia: A pseudo-random variable is a variable which is created by a deterministic procedure (often a computer program or subroutine) which (generally) takes random bits as input. The pseudo-random string will typically Page 96 Introduction to Using Games in Education: A Guide for Teachers and Parents be longer than the original random string, but less random (less entropy, in the information theory sense). This can be useful for randomized algorithms. Pseudo-random number generators are widely used in such applications as computer modeling (e.g., Markov chains), statistics, experimental design, etc. Some of them are sufficiently random to be useful in these applications. Many are not, and considerable sophistication is required to correctly determine the difference for any particular purpose. You know that computers can play some games quite well. Perhaps you believe that is a computer has been programmed to play a game, the computer will never lose. However, that is not the case. Let’s use TTT for an example. Suppose that a computer has been programmed to make random moves when playing against a human opponent. When it is the computer’s turn to make a move, it selects one of the legal available moves at random, and makes that move. As you might expect, a human player can often beat such a compute program. Your students may enjoy creating a “by hand” simulation of this situation. Prepare nine small pieces of paper that are numbered 1, 2, … 9, respectively, and place them in a small box. Number the spaces of a TTT board with the nine digits as follows: 1 2 3 4 5 6 7 8 9 Figure 6.2. A TTT board with its squares numbered 1 to 9. Use of Random Moves in a Game Let us suppose, as an example, that X is going to play first and that X’s moves will be randomly generated. You play O against the random mover. Start at step 1. 1. To generate X’s move, stir up the pieces of paper in the box and draw one out. Its number will be the space in which X moves. Then one of the following 3 situations occurs: 1a. If this move completes a file with three X’s, X wins and the game ends. 1b. Otherwise, if this is the ninth move in the game, the game ends and is a draw. 1c. Otherwise, go to step 2. 2. You (O) make a move. If this produces a file with three O’s, you win and the game ends. Otherwise, look into the box and remove the slip of paper that contains the number corresponding to the move you just made. Then go to step 1. The set of steps can easily be written as a computer program. The set of steps is an algorithm that generates moves for X and determines who wins or if the game is a draw. It should be evident to you that just because a computer has been programmed to play a game it does not Page 97 Introduction to Using Games in Education: A Guide for Teachers and Parents follow that the computer wins all the time or will always play well. Indeed, the random number player will play poorly. However, it will occasionally best a child who is just learning to play the game. The idea of using random numbers in a computer program adds an unpredictability dimension to what a computer can or cannot do. People often argue about limitations of computers by stating that a computer can only do what it is told to do in a computer program. However, when this “telling the computer” includes making use of random numbers, the programmer or the program user may not be able to accurately predict the results. A TTT Algorithm that Never Loses Next, we will explore a TTT algorithm that can be followed by a person or programmed into a computer, and that plays quite well. This algorithm is specifically designed to produce moves for X, who moves first. Begin by numbering the nine squares on the grid as follows: 2 6 3 7 1 8 4 9 5 Figure 6.3. TTT board numbered to help specify a game-playing algorithm. The first player (X) uses the following 4-part procedure to determine what move to make at each turn: 1. Examine the grid and carry out the following sub-steps: 1a. If there are one or more files that contain 2 X’s and no O’s, play in the one that contains the lowest numbered blank space. Thus, you win the game, and the game ends. 1b. Otherwise, if there is only one blank square remaining, play in it. The game then ends as a draw. 1c. Otherwise, go to step 2. 2. If there is a file containing 2 O’s and no X, play in that file. Otherwise: 3. Consider each possible remaining legal move, from the lowest numbered one to the highest numbered one. For each, see if making that move would result in the creation of two or more distinct files each containing two X’s and no O’s. If (and as soon as) such a possible move is discovered, make it. Otherwise: 4. Move in the lowest numbered unused square. Page 98 Introduction to Using Games in Education: A Guide for Teachers and Parents Through some careful thought, you should be able to convince yourself that X (playing first) never loses. This algorithm that never loses is dependent on X going first, on the board being numbered as shown, and on the “look ahead” feature in step 3. Use of the look-ahead strategy is a key feature in writing a program that plays a good game of chess, checkers, or other somewhat similar games.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages19 Page
-
File Size-