- Reset Game
- Book
- BASIC
-
Guess
Original Resources
Download the original BASIC code. Check out the original page the text below was taken from in the Book.
Instructions From the Book
In Program GUESS, the computer chooses a random integer between 0 and any limit you set. You must then try to guess the number the computer has chosen using the clues provided by the computer.
You should be able to guess the number in one less than the number of digits needed to represent the number in binary notation - i.e., in base 2. This ought to give you a clue as to the optimum search technique.
GUESS converted from the original program in FOCAL which appeared in the book "Computers in the Classroom" by Walt Koetke of Lexington High School, Lexington, Massachusetts.
Modifications For This Version
This version is very true to the original. The only change I made is that the value entered by the user for the maximum number range must be 10 or greter. Also, although the instructions from the book state that a number between 0 and the limit is generated, this is not actually true. The original program generates a number between 1 and the limit. This version does the same.
Technical Stuff
For this version I, once again, used PHP and thus uses session and post variables to manage the input. Obviously this could easily be built in JavaScript, but I like to hide the values from the user.
Also, using a little CSS magic I modified the input fields to look more like a command prompt. The input fields are type=number, but you'll notice that the little arrow scrollers are not present in the input fields. In building this project I discovered a fun bit of CSS that handles this.
Check out the article on the W3 Schools website. Then after that . . .
Enjoy Guess!
Guess
This is a number guessing game. I'll think of a number between 1 and any limit you want. Then you have to guess what it is.
What limit do you want?