Okay, so I'm takin' a whack at making my own number guessing game, but I've hit a road block. I have the basic game done, but I tend to want to add more onto what I do. I came up with an idea to have the computer try to guess the players number instead of the other way around. What i was trying to do was make the player enter his number, store it as a variable, then have the computer generate a random number between 1-100. Then compare it's guess with the variable, narrow it's value and then try again, until finally getting the answer.
My problem is that I can't seem to figure out how to change the values for the random number to be generated. Lets say my number was 20, and the computer guessed 40. Well 40 is too high, so I want it to narrow it's values down and generate a new number. So instead of 1-100, it'll be 1-39. This is where my problem comes in. I need to find out how to use the number the computer previously generated, then use it as the min/max value for the next number to be generated.
I've tackled this problem myself for a while, but to no avail. Any help would be greatly appreciated, and sorry for the long post.
This is what I got so far, though it's no where near done.
DO:
CompGuess=Rnd(99)+1
CLS
Print "This entire game mode is done automatically, so it'll be pretty quick."
Print "This is really only ment to show the User how fast the computer can figure out your number"
Input "Please enter you number ", PlayerNumber
CLS
Print "Your number is ";PlayerNumber;""
Print "The Computer guessed the number ";CompGuess;""
If CompGuess < PlayerNumber
Print "The Computer guessed too low. It'll try again."
Inc GuessCounter
CompGuess=Rnd(CompGuess-100)
Endif
If CompGuess > PlayerNumber
Print "The Computer guessed too high. It'll try again."
Inc GuessCounter
CompGuess=Rnd(1-CompGuess)
Endif
If CompGuess = PlayerNumber
Print "The Computer guessed the correct number!"
Print "It took the Computer ";GuessCounter;" guesses this time."
Print "Do you want to see the Computer try again? (Y/N)"
Repeat
I$=Upper$(Inkey$())
Until I$="Y" or I$="N"
If I$="N"
End
Else
GuessCounter=0
Endif
Endif
Loop