What is the best strategy for guessing the number game?

  • Thread starter Thread starter fisico30
  • Start date Start date
  • Tags Tags
    Game
Click For Summary

Discussion Overview

The discussion revolves around strategies for the "guess the number" game, where a computer attempts to identify a number between 1 and 100 through a series of questions. Participants explore different questioning techniques, including binary search and more complex approaches.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants propose that a simple binary search strategy is commonly used, where the computer starts with a guess of 50 and halves the interval based on feedback.
  • Others suggest that asking if any digit of a number is correct could be a more sophisticated version of the game, though this approach may not lead directly to the correct number.
  • A later reply indicates that knowing a digit's position can help narrow down possibilities, such as determining that a number must be in a specific range based on feedback.

Areas of Agreement / Disagreement

Participants generally agree on the effectiveness of binary search as a strategy, but there is no consensus on the viability or effectiveness of more complex questioning methods.

Contextual Notes

Limitations include the potential complexity of implementing more sophisticated questioning strategies and the uncertainty regarding their effectiveness compared to traditional binary search methods.

fisico30
Messages
362
Reaction score
0
Hello Forum,
I just learned about the "guess the number" game. There are 100 numbers, from 1 to 100 and the computer must ask questions to find the correct number.

The computer could start from 1 and go up until it finds the right number. That would involve a certain number of questions.
Or the computer could ask more intelligent questions, like "is the number smaller or larger than 50", etc...


Most of the codes I have seen don't ask that "is the number smaller or larger than 50?" but simply ask some binary questions that are all similar (is this number smaller or larger than the previously guessed number? etc...)

Why?

thanks
fisico30
 
Technology news on Phys.org
Hi fisico30. This game usually uses a simple binary search, in which it always halves the interval in which it currently knows where the solution lies. So the "computer" would typically start with a guess of 50 and then simply require to be told if it was either correct or high or low.

If correct the game stops with a score of "one guess". If it was told 50 was high then it would next guess 25, if told 50 was low then it would next guess 75 and so on. Searching by continually halving the interval is easy to implement and fairly efficient.

BTW. This game is sometimes given as a exercise for students learning an introductory programming course. It's about the simplest example the you can think of that in some sense constitutes an "AI" game.
 
Thanks uart,

great help. Ideally, the least number of guesses, questions, to get to the right answer, the better...

What would be a slightly more sophisticated version of this game? Instead of asking questions based on halving the interval in which it currently knows where the solution lies, would could be asked?

thanks
fisico30
 
Increase the range, say to 0-1,000, and ask if *any* (not which) digit is correct.
 
Thanks, I see.

So, if we get the number 3456, we would ask if any of the digits forming this number are correct...
that still seems far from being able to correctly guess the right number though...

thanks
fisico30
 
You know it has to be 3xxx or x4xx or xx5x or xxx6.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
1K
Replies
17
Views
10K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 43 ·
2
Replies
43
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
21
Views
4K