CIS 400 Assignment 2
                         Fall 1996
 
     In this assignment you are to write a series of Lisp 
functions which will allow you to play a simplified version 
of the game Craps. You will also be required to implement 
these functions in a some imperative language like Pascal or 
C/C++. You may work with a friend if you wish. 

     For the first part of the assignment, write Lisp  
implementations for the functions described below:
 
  1. A function THROW-DIE which has a NIL argument list and 
     returns a random number from 1 to 6, inclusive. 
     Hint: The Common Lisp function call (RANDOM 6) returns 
     values ranging from 0 to 5.
 
  2. A function THROW-DICE which has a NIL argument list and 
     returns a list having the value of the first die thrown 
     followed by the value of the second die thrown. For 
     example, (THROW-DICE) might return the throw (3 5).
 
3.  Throwing two ones is called "snake eyes" and two sixes   
   is called "box cars". Write predicate functions 
   SNAKE-EYES-P and BOXCARS-P which take a throw as input 
   and return T or NIL. For example,(BOXCARS-P '(2 3)) 
   returns NIL and(SNAKE-EYES-P '(1 1)) returns T.
 
  4. A throw having a total value of 7 or 11 is an instant 
     winner. A throw having a value of 2, 3, or 12 is an 
     instant loss (American casino rules). Write predicates 
     INSTANT-WIN-P and INSTANT-LOSS-P taking a throw as 
     input to detect these conditions. For example, 
     (INSTANT-LOSS-P '(2 5)) returns NIL and 
     (INSTANT-WIN-P '(2 5)) returns T.
 
5.  Write a function SAY-THROW that takes a throw as input
   and returns either the sum of the two dice, the symbol 
   BOXCARS,  or the symbol SNAKE-EYES (as appropriate). 
   For example, (SAY-THROW '(3 4)) returns 7 and 
   (SAY-THROW '(1 1)) returns SNAKE-EYES.
 
6.  Write a function CRAPS which can be called repeatedly 
   by the user to simulate the game of craps. Don't worry 
   about recording the previous "point" (unless you 
   already are a craps expert and know what to do with 
   it). Model your output after the examples shown below:

       >(CRAPS)
        (THROW 1 AND 1 -- SNAKE-EYES -- YOU LOSE)
       >(CRAPS)
        (THROW 3 AND 4 -- 7 -- YOU WIN)
       >(CRAPS)
        (THROW 2 AND 4 -- YOUR POINT IS 6)

     For the second part of your assignment, you are to 
implement these functions from the first part in some 
imperative language. You are to write this program in a 
functional style, without excessive reliance on the 
assignment operation. This means that you may use any 
control structures from the language you wish, but you must 
write functions not procedures. 

     You may use any Lisp dialect you have access to (XLisp 
and muLisp live in the CW micro lab). You should include 
enough trials of each function (Lisp or otherwise) to 
demonstrate that they perform as specified. Be sure that I 
end up with a complete listing of your carefully commented 
source code (both Lisp and whatever) as well as your output. 
Also be certain that it will be easy for me to match the 
function calls with their output (some hand written notes or 
comments might be helpful). I am not requiring a memo this 
time. The first part of your assignment will be 20 points, 
the second will be worth 15 (compiler listing, language use, 
comments). The due date for this assignment will be 
negotiated in class.