Uncategorized

Android Development Day Two

Today, learned a few things.

How to move from one Activity to another.

A bit more about the xml layout for controls, specifically layout weights.

The eclipse built-in way to take a screen shot from the emulator.

Even a simple game like “Guess My Number” needs things like a Main Menu, an Instructions page, and an About page.

I also bought myself a developer registration for the Google Play store.

Yes, I’m actually planning to publish the craptacular “Guess My Number”.

And I’m doing it in Java, not a cross platform hoop-de-hoo.

Why?

I already know Eclipse.

I’ve already been working in Java relatively steadily for Minecraft Plugins and other side projects.

The android UI stuff isn’t very hard.

And I’m already time constrained. Church, house, job, kid, marriage (alphabetical order).

And the entry fee was only $25.

Basically, if I do nothing more than release GMN for free in Google Play, then the $25 I spent was worth it, because I get an accomplishment badge – “Published Android App”.

If I go on to do a bunch of other craptacular games: Russian Roulette; Rock, Scissors, Paper; a turn based “Stock Market” simulator; and things akin to old David Ahl games, then all the better.

If I improve in my command of the platform, and decide to go more sophisticated, I can do that.

If one day I find something sell-able, I can do that, too.

And if I don’t…. $25.

 

Uncategorized

Because I’m A Nerd… That’s Why!

Today, I was mulling over the statistics behind “Guess My Number”.  For those few who are not familiar with the game, a random number between 1 and 100 (inclusively) is chosen, and the player guesses what the number is.  He is told if his guess is too high or too low. The idea is to have the smallest number of guesses.

Now, granted, this is not much of a game, but it does have all of the elements of a game, and so is good for studying games.

So, I was thinking about the statistics of it.  The “best” strategy for playing is to divide the current possibility space into two sections in order to eliminate the most numbers from subsequent guesses. So, the first guess would be 50, followed by 25 or 75 (depending on the status of 50), and so on, subdividing the remaining possibilities into two until the final number is guessed.

This can be trivially formulized with logarithms…. the average number of guesses should be around log 100/log 2, or about 6.6.  Empirical evidence seems to support this idea, as most number are guessed in either 6 or 7 guesses, unless the player “gets lucky” with the number being 50, 25, 75, or the other early on numbers.

I realized today that I cannot discount those “lucky” numbers, and so I figured out the following:

There is 1 number that will always be guessed in 1 move (the number 50).

There are 2 numberst that will always be guessed in 2 moves (25 and 75).

Similarly there are 4 numbers guessed in 3, 8 numbers guessed in 4, 16 numbers guessed in 5, 32 numbers guessed in 6, and the remaining 37 numbers (to make 100 total) are guessed in 7.

Add these probabilities up in an excel spreadsheet:

1 x 1 guess = 1 guess

2 x 2 guesses = 4 guesses

4 x 3 guesses = 12 guesses

8 x 4 guesses = 32 guesses

16 x 5 guesses = 80 guesses

32 x 6 guesses = 192 guesses

37  x 7 guesses = 259 guesses

Total guesses = 580 guesses.

Divide by 100 numbers = 5.8 guesses/number.

So, we find that the actual average score is 5.8, which is 0.8 guesses less than the prediction from the logarithm approximation.

This analysis has also shed light on an important aspect of this game: why it isn’t fun.

Basically, your score at Guess My Number is wholly dependent on the number chosen randomly, provided that the player is using a deterministic strategy. The player has a 1% chance of winning on the first move. The second move he has a 1 divided by whatever numbers are left, and so on.

So, this makes the game a complete game of chance.  You might as well take a die and roll it, and whatever you roll is the score.  Beyond picking a binary search deterministic strategy, there is no method of improving score due to skill/technique development.