- Reset Game
- Book
- BASIC
-
Stars
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 this game, the computer selects a random number from 1 to 100 (or any value you set in Statement 150). You try to guess the number and the computer gives you clues to tell you how close you're getting. One star (*) means you're far away from the number; seven stars (*******) means you're really close. You get 7 guesses.
On the surface this game is very similiar to GUESS; however, the guessing strategy is quite different. See if you can come up with one of more approaches to finding the mystery number.
Bob Albrecht of People's Computer Company created this game."
Modifications For This Version
I kept this one very close to the original version. The stars, as described above, are the same for this version, and also, you get 7 guesses, just like above.
Technical Stuff
Like many of the other projects on this site, I'm using PHP, server pings, POSTs, page refreshes and SESSION variables. I may consider a JavaScript version down the road. For the coders among you, you may get a kick out of knowing that I used goto statements in my PHP to calculate how many stars to display. It was one of the cleanest and most streamlined ways to do it. It also deepened the nostalgia of the whole project because it's very B.A.S.I.C-esque to write code like that.
The Future
I've already built in some hooks to make a couple of future modifications. One is to allow the user to choose the range of numbers rather than being stuck with 1 through 100. I just haven't decided, yet, on the best way to dynamically create the proper number of stars based on the distance the guess is from the computer's number. I want it to be 100% dynamically calculated, and I'm not happy with any of the calculations I've come up with thus far.
This change will necessitate giving the user more than 7 guesses as well. I'll get there one of these day, but for now . . .
Enjoy Stars!