The program TTT is our version of a rule-based board game that plays (duh!) tic-tac-toe. In our program, you play against the computer, as you would in any computer game. What is different about our program is that you can create and enter into the program the rules it uses to make its moves. In fact, the computer's moves are completely dictated by the rules you provide for it.
|
- Click on the "Start" button in the lower-right corner of TTT to start a new game. The computer replies to this click by telling you that it has no rule to apply, and so cannot make a move. If you click on the "Rules" button along the left side of TTT, you will see the computer's currently empty list of rules. No wonder it couldn't make a move to start the game.
- Click on the "Help" button along the left side of TTT. Read completely the description of how to play the game, how to enter rules into the program, and how to save collections of rules for future use.
- Click on the "Rules" button again and enter the following list of rules into TTT's Rules window:
1b1
2b2
3b3
4b4
5b5
6b6
7b7
8b8
9b9
When finished, click on the "Game" button, and then click "Start" to begin a new game, this time using the rules that you entered. Play a number of games using this rule set to make sure that you see how it is being used by the program.
- Edit the rule list so that the rule encoded as "5b5" is the first one in the list, and then start a new game. What effect does this have on the behavior of the program?
- Now, edit your rule list to include the rules you created in Lab Exercise 9.1.
- Finally, save your list of rules as a text file (by copying and pasting the list
into a simple text editor like NotePad or SimpleText).
|
|