About Secret Number
Secret Number is the "I'm thinking of a number" game with a referee. One player chooses, the other guesses, and the game answers each guess with "too high" or "too low". Then you change places.
How a match works
Player one enters a number using the keypad. It shows as dots, so it cannot be read over a shoulder. After pressing OK, a handover screen appears and the device goes to player two.
Player two types a guess and presses OK. The game replies, and the counter goes up by one. When the number is found, the roles reverse: player two sets a number and player one guesses.
At the end, the two counts are compared. Fewer guesses wins, and equal counts are a draw.
The best way to guess
There is a method that never needs more than seven guesses. Always guess the middle of what is left.
Start with 50. If that is too high, the number is between 1 and 49, so guess 25. If that is too low, it is between 26 and 49, so guess 37. Each guess throws away half of the remaining numbers. A hundred possibilities become fifty, then twenty-five, then twelve, six, three, one.
Any other approach, such as creeping up in tens, is slower on average.
So where is the game?
If both players halve perfectly, the result comes down to where the secret number sits. Some numbers are found on the first or second guess by this method: 50, 25 and 75. Others take all seven.
That gives the chooser something to think about. Pick a number that the halving method reaches last. And if your opponent does not know the method, you have a real edge.
It is also a splendid way to teach a child the idea of halving a search.
As two-player HTML5 games go, it takes two minutes and leaves something useful behind.