Steven S. Skiena
Chess playing programs work by constructing a tree of all possible moves from a given position, so as to select the best possible path.
The player alternates at each level of the tree, but at each node the player whose move it is picks the path that is best for them.
A player has a forced loss if lead down a path where the other guy wins if they play correctly.
This is a recursive problem since we can always maximize, by just changing perspective.
In a game like chess, we will never reach the bottom of the tree, so we must stop at a particular depth.
Sometimes we don't have to look at the entire game tree to get the right answer:
No matter what the red score is, it cannot help max and thus need not be looked at.
An advanced strategy called alpha-beta running reduces search accordingly.
Recursive Descent Compilation
Compilers do two useful things
To do either, we need a precise description of the language, a BNF grammar which gives the syntax. A grammar for Modula-3 is given throughout your text.
The language definition can be recursive!!
Our compiler will follow the grammar to break the program into smaller and smaller pieces.
When the pieces get small enough, we can spit out the appropriate chunk of assembly code.
To avoid getting into infinite loops, we place our trust in the fellow who wrote the grammar. Proper design can ensure that there are no such troubles.