CSE 111, Fall 2000

Virtual HW #6: CODING DECISION TREES IN PASCAL

NEW Corrected Version NEW

Write (and test) a complete Pascal program that codes the following decision tree for 5-Nim:

                              D--------------
                               | I play OO; |
                               |   I win!   |
                               --------------
                              /
                           X /
                            /
             B-------------/
              | I play O; |
              | your move |
              -------------\
             /              \
          X /             XX \
           /                  E-------------
A---------/                    | I play O; | <--NOTE CORRECTION
 | Your  |                     |   I win!  |
 | move! |                     -------------
 ---------\
           \                  F-------------
         XX \                 /|  You win! |
             \             X / -------------
             C--------------/
              | I play OO; |
              | your move  |
              --------------\
                             \
                           XX \
                              G------------
                               | That's   |
                               | illegal! |
                               ------------

Hint: Here's the top-level design (= the code for decision tree "A") to get you started (recall from the online lecture notes that "<>" is Pascal's way of saying "is not equal to"):

Further hint: The code for decision trees "B" and "C" will look almost exactly like the code for decision tree "A": It will be a sequence (or "compound statement") consisting of a "writeln" instruction, followed by a "readln" instruction, followed by an "if-then-else" instruction.

NOT TO BE HANDED IN;
DO THIS TONIGHT!
ANSWER WILL BE POSTED TO NEWSGROUP TOMORROW



Copyright © 2000 by William J. Rapaport (rapaport@cse.buffalo.edu)
file: 111F00/hw6.11oc00.html