Write a perl program to design a computer game, Programming Languages

Write a Perl program ghici.pl, one of the simplest computer games. The program should generate a random integer between 1 and 1000 and asks the user to guess it. If the user ?nds the number, the program stops with a message. If not, the program adjusts the interval based on the user's guess and lets him try again. To generate a random integer, use function rand, documented in perldoc perlfunc.

despi@turing> ghici.pl
comp315@turing> ghici.pl
Enter a number between 1 and 1000: 1200
Please stay between 1 and 1000.
Enter a number between 1 and 1000: 500
Enter a number between 500 and 1000: 300
Please stay between 500 and 1000.
Enter a number between 500 and 1000: 750
Enter a number between 500 and 750: sir!
Please enter a number only.
Enter a number between 500 and 750: 625
Enter a number between 625 and 750: 684
Enter a number between 684 and 750: 712
Enter a number between 684 and 712: 694
Enter a number between 684 and 694: 689
Enter a number between 689 and 694: 692

You guessed it in 11 tries.

Notice how the program works:

  • it uses a dichotomic search based on user's answer to adjust the limits.
  • it tests if the answer is a number in between limits
  • it counts the number of tries.

What features would you like to add to this program? Write them down as a comment in the source code of ghici.pl.

Posted Date: 3/12/2013 1:42:43 AM | Location : United States







Related Discussions:- Write a perl program to design a computer game, Assignment Help, Ask Question on Write a perl program to design a computer game, Get Answer, Expert's Help, Write a perl program to design a computer game Discussions

Write discussion on Write a perl program to design a computer game
Your posts are moderated
Related Questions
My kinect hand cursor only works for main menu but when it goes to another page it wouldn''t work.. especially when there is for camera feed

Question: (i) Each time a security mechanism is installed or deleted in a Digital UNIX system, SIA is involved. Draw a Security Integration Architecture diagram. (ii) How

Identifying the Central Individual in a Social Network 1. Introduction You have just been hired by a social networking company! The division you are working in is particul

What are Attributes in HTML langauge? A few tags have attributes. An attribute is a name, followed through an = sign, followed by the value. For instance, to make a centered H1

All programs have to be done in console application. Program 1, 2 and 3 are due on 2/11/12 Program 4, 5, and 6 are due on 2/18/12 Program 7, 8, and 9 are due on 2/25/12 Program 10

Write a program to read a text file and create a dictionary. The keys for the dictionary should be all 26 letters of the alphabet and the values of the dictionary should be the lis

You must implement the control mechanism for the robot arm so that it can safely move the blocks from the source pile to their destination, without colliding with any obstacles or

write and compile a simple program in Assembly Language that compute and print student grades for a course.which you can open a file, read from it, and compute the results...using

need a command to : Display user id, first and last names of all the students the class specified by the prefix in alphabetical order by last name from /etc/passwd

Im having problems with my php / mysql code. I am trying to make it so it looks for an asset Number and if it is in the shop if the asset is in the database but is not in the shop