~mc27/labs/nim/nim.scmsomewhere under your home directory, and then evaluate everything in it in DrScheme. (Note: The easiest way to save the file is to go to the link, and then do a Save As... under the File menu in Mozilla.) This file contains the Nim program and the game-state implementation from the book, except that
human-moveare modified as indicated in exercise 6.13(c).
make-move-instructionand the two selectors are called
pile-number. You should write them correctly by removing the
errorexpressions which they currently contain and replacing them with the actual procedure bodies.
Keep in mind that
constructs a move-instruction object, while
next-game-state actually performs the move.
Once you have implemented the move-instruction ADT, you can test your implementation in two ways. First, you could test the ADT in isolation with expressions such as:
(num-coins (make-move-instruction 4 2))Second, you can test the ADT in the context of the whole application by playing Nim games with the computer by evaluating, for example, the expression:
(play-with-turns (make-game-state 5 8) 'human)Both kinds of tests are critical in any large application, so be sure to do both kinds of tests whenever appropiate throughout this lab. You should identify when and how both types of tests were done in the appendix of your project writeup.
Play a couple of games so that you get a hang of how the interaction works. (You needn't include transcripts of your game playing in the lab writeup.)
randomprocedure, keep in mind that each time you use it you may get a different result; if you want to use the same randomly chosen integer twice, you should hold onto it, for example by naming it with a
let, as you won't be able to regenerate it.
Again, as with the
move-instruction ADT, be sure
test each strategy in isolation as well as in the context of the whole
application. Also, be sure that every random strategy really is
random. If you are unsure about how to test the strategies in
pile-number. (If this is confusing, look at the two implementation of
make-game-stateon pages 148 and 151.)
Your finished product in this project is a software system that allows users to play a game of Nim against various different strategies. Even though the game is relatively simple compared to games you might actually purchase, the situation is a familiar one: you have created a software system which might later be revised and extended by other programmers. Your task is to write a manual for future programmers describing the structure of the programming system and how they should go about extending that system.
More specifically, you first describe what your system is intended to do -- namely, playing a game of Nim, which you should briefly describe. Then you should explain the structure of your software system for programmers who are competent in Scheme, but are unaware of the system itself. Give a good overview of the structure of the software system, giving special attention to its two ADTs. Try to be brief and precise in describing the ADTs (i.e., the interfaces) and avoid going into details (such as implementation) irrelevant to the "strategy writer".
Furthermore, explain what a strategy is (as a Scheme procedure) and how a programmer should go about writing a new strategy for the system. You may also, if you wish, add suggestions for possible improvements or extensions that could be made to the system. If you do make suggested improvements, they should include specific guidance on what would need to be changed to implement those improvements.
For the purposes of my grading your report, I ask that you also include an appendix all of the procedures you wrote or modified. You should also describe the testing you did on those procedures. This should include examples of the testing, but should also be descriptive of your testing strategy.
You can get some sense of how this project report will be graded by looking at the grading sheet that we use.