Game Development Reference
This chapter shows that a few rules and a framework to run them go a long way.
Once the framework is created and understood, new rules can be added quickly and
easilywithout upsetting existingwork. There is anup-front cost to the system, but it
pays off quickly with every new capability added. Rule-based systems are inherently
tunable and allow for almost Darwinian evolution to cover any deficits. As shown
by the project, when the rules fit the game well, they are powerfully effective.
Answers are in the appendix.
1. What are the two parts of a rule in a rule-based system?
2. What does the framework do in a rule-based system?
3. Why is it that a rule-based system can play like both a human and a machine
at the same time?
4. What makes a rule-based AI appear intelligent? What makes it appear stupid?
The code for some of these exercises is on the CD.
1. Add buttons below the Expert button for Intermediate (16 row, 16 columns,
and 40 mines) and Beginner (9 rows, 9 columns, and 10 mines) games.
2. Add code to track the number of moves made by the player and by each rule.
For a more in-depth analysis, keep statistics over many games that include
per-move data for all 480 possible moves. When is the game the most
3. Modify the framework so that RunAI runs the match-execute cycle repeatedly
until it finds no moves around the revealed square. You will need to add a
scrollbar to the ThoughtsTextBox control. You might want to make it taller as
well. This code is on the CD.
4. Add code to take free moves when a zero is revealed. Recall that the playing
field can tell a square who its neighbors are. The following fragment of code
may come in handy: