Home | Notes | Languages | Programs | Homework |
Program Assignment 3 |
Problem |
This is your first assignment in Prolog, and is intended to demonstrate a capability in the language that is difficult to implement in any other language.
Design, implement and fully test, a Prolog program that will solve the following logic problem:
Five people visit a bar for a drink of Scotch Whisky. They all have their drink served differently and by different bar staff. From the clues given below, determine which bar person served whom, how they had their Scotch and in what order they were served at the bar.
The complete set of data for this puzzle is:
Drinkers: Weiss Muller Petit Johnson La Rue Servers Paul Carmen Hans Marcella Andy Drinks (Scotch &) Cola Ginger Ale Ice Soda Cocktail Order Served 1 2 3 4 5 The clues you have available are:
Someone is served a Scotch & Cola by Carmen.
Mrs. Johnson was not served her Scotch & Ginger Ale by Marcella.
Mr. Weiss was served by Paul.
The person who drinks Scotch & Cola wasn't served second.
The cocktail drinker was served last.
Marcella served the fourth person in line but they didn't order a Scotch & Soda.
Neither Carmen nor Hans served Mr. Petit who was third in line at the bar.
First in line was not Miss La Rue.
For this program, there is no interactive input data. Further, your program must produce a solution within 1 minute of execution time.
Implementation Language |
For this assignment, your program must be written in Prolog.
You will be programming
in a "logic programming" style, as described in Chapter 15 of the text
book. Since this program must be written in Prolog, appropriate use of
logic programming language features is expected. In particular, you
may not use any versions of assert
, retract
,
record
, erase
, flag
, or any
of the other database features of Prolog.
As with prior programs, your solution must adhere to good programming style, including correct use of parameter passing, identifier naming, predicate length, commenting, headers for each predicate, etc.
Input/Output Format |
Write your program as a prolog predicate called
scotch_solution
taking 15 unbound variables as
parameters, like this:
scotch_solution( Drinker1, Drink1, Server1, /* The first in line */ Drinker2, Drink2, Server2, /* The second in line */ Drinker3, Drink3, Server3, /* The third in line */ Drinker4, Drink4, Server4, /* The fourth in line */ Drinker5, Drink5, Server5 /* The fifth in line */ ) :- /* your implementation here */ ...The Curator will invoke your solution with 15 unbound variables and then print out the results using
write
goals.
Submitting Your Program |
Your Prolog implementation is to be organized in a single file. All documentation and identifying information should be placed in comments within the single source file. The comments at the beginning of the file should identify the assignment and give your full name. Every Prolog predicate should be preceded by comments explaining its purpose and implementation.
Your program will be submitted electronically through the Curator for automatic grading. To submit your program, login to the Curator using your PID and password. Be sure to select the 11374-CS 3304 11:15 MWF Edwards section when logging in. Click on "Submit", choose Prolog3 from the project drop-down list, click "Browse" to specify your solution, and then click "Upload."
In addition, you must also turn in a printed version of your program source in class according to the rules specified in the syllabus, which also describes the late policy.
Home | Notes | Languages | Programs | Homework |