Prolog program
I want you to make a prolog game its easy and due in 1.5 hours
2 years ago
30
prolog.pdf
prolog.pdf
CSE 240 Introduction to Programming Languages
Assignment 11 Prolog Part I Due: Sunday, November 19th at 11:59pm
Submit guess_simple.pl to Gradescope.
Requirements
For this assignment we want to use Prolog to write a simple guessing game as we did in previous assignments with C/C++. This game asks the user to guess a number from 1 to 10 and tells the user if they should guess higher or lower. When the user successfully guesses the number, they are told that it is correct. Each time the game is played the program needs to generate a random number from 1 to 10. In SWI Prolog you can use the predicate:
random(1, 10, Number)
Your code will likely consist of a rule like:
guess() :- ...
to start the program. An example output is shown below:
?- consult('/Users/Joshelliot/Documents/guess_simple.pl'). true.
?- guess. Try to guess a number between 1 and 10. |: 5. Higher. |: 7. Higher. |: 8. Higher. |: 9. Correct! true .
?- guess. Try to guess a number between 1 and 10. |: 5. Higher. |: 8. Lower. |: 7. Lower. |: 6. Correct! true .
?-