Write a number guessing game. I don't know if anyone has played it. There is this game on the home phone, and I've played it many times. I'm also writing one myself, 7788, not perfected yet. I want to see if everyone has better ideas.
In the forum, those who feel there are no challenging experts can come out and discuss. Thanks.
Rules:
1. The game will randomly obtain a four-digit number without repeated digits from 0-9 at the beginning (the first digit can be 0)
2. The player first makes a guess, entering a four-digit number without repeated digits from 0-9
3. Compare the number obtained at the beginning of the game with the number entered by the player:
If one digit has the exact same number and position, set flag A1
If one digit has a matching number but wrong position, set flag B1
If the number and position are both mismatched, set flag B0
The exact match of number and position only sets flag A, regardless of B
For example: The answer is 4690. If I guess 0679, then the prompt is A1B2
If the prompt is A0B0, it means the guessed number does not appear at all in the answer
If the prompt is A0B4, it means the guessed number matches exactly but all positions are wrong
A4B0 is the correct answer.
4. Only 10 chances
General idea:
* Must verify the random answer
Verify if the randomly obtained number is four digits, and if each digit has repetition
* Must verify the player's input specification
Verify if the player's input is pure digits, if there is repetition, if it is 4 digits, otherwise give corresponding prompt and jump back to re-enter
* Record historical records
What the user entered for the first time, what the prompt was, must be displayed for reference when guessing the second time
* Record the number of uses
How many times have been guessed, how many times are left, displayed together with the historical records
* Must have a chance to play again
After the player uses up 10 times and hasn't guessed it, there must be a chance to play again, or if guessed correctly at once, there must be a chance to play again
-------------------------------------------------------------------------------------------
The final answer is in posts 7, 9, 11, 16
Close the post!
[ Last edited by dosmania on 2007-9-26 at 09:32 PM ]
In the forum, those who feel there are no challenging experts can come out and discuss. Thanks.
Rules:
1. The game will randomly obtain a four-digit number without repeated digits from 0-9 at the beginning (the first digit can be 0)
2. The player first makes a guess, entering a four-digit number without repeated digits from 0-9
3. Compare the number obtained at the beginning of the game with the number entered by the player:
If one digit has the exact same number and position, set flag A1
If one digit has a matching number but wrong position, set flag B1
If the number and position are both mismatched, set flag B0
The exact match of number and position only sets flag A, regardless of B
For example: The answer is 4690. If I guess 0679, then the prompt is A1B2
If the prompt is A0B0, it means the guessed number does not appear at all in the answer
If the prompt is A0B4, it means the guessed number matches exactly but all positions are wrong
A4B0 is the correct answer.
4. Only 10 chances
General idea:
* Must verify the random answer
Verify if the randomly obtained number is four digits, and if each digit has repetition
* Must verify the player's input specification
Verify if the player's input is pure digits, if there is repetition, if it is 4 digits, otherwise give corresponding prompt and jump back to re-enter
* Record historical records
What the user entered for the first time, what the prompt was, must be displayed for reference when guessing the second time
* Record the number of uses
How many times have been guessed, how many times are left, displayed together with the historical records
* Must have a chance to play again
After the player uses up 10 times and hasn't guessed it, there must be a chance to play again, or if guessed correctly at once, there must be a chance to play again
-------------------------------------------------------------------------------------------
The final answer is in posts 7, 9, 11, 16
Close the post!
[ Last edited by dosmania on 2007-9-26 at 09:32 PM ]
