Adding Strategies to the Nim Program
This is also addressed in
Assignment 3. Here is the basic
approach:
- The computer-move procedure will be given a strategy
procedure as a second argument.
- The strategy procedure takes a game state as an argument and returns an
abstraction called a move instruction.
- A move instruction packages a pile number and number of coins to be
removed from that pile.
Since strategies are encapsulated in procedures, different strategies can be
"plugged in" to the program and tried.