Infinite Monkeys
Enjoy the game? Check out my upcoming game VSCS-II, which contains an 80s-style remake of Infinite Monkeys (link opens in new tab).
How To Play
The goal of the game is to write the entire first scene of the first act of Shakespeare's King Lear, one random letter at a time. Monkeys will type letters at random until one hits the correct one, and each completed letter gets you $1. Use the buttons on the top floor to hire more monkeys and motivate the existing ones to work faster by buying posters and banana trees. Toggle the music and sound effects by clicking on the radio.
I highly recommend giving the write-up below a read while you wait for your monkeys to progress.
Infinite Monkeys on Infinite Typewriters
This game is based on the Infinite Monkey Theorem, which posits that a monkey on a typewriter, if given infinite time, would be able to write any complex piece of literature, such as Shakespeare's King Lear. In I̶n̶finite Monkeys, your monkeys will have to type the entire first scene of King Lear - the length of the text is part of the absurd premise; I don't actually expect you to complete it all.
Though I do some really basic statistics below, I avoided all the very technical stuff like the formal proof of the theorem. Because if you've been on pop-science YouTube, you'll know that even though it's better for proofs to treat the monkeys in this theorem like uniformly random string generators, it's much more fun to just calculate big numbers and talk about monkeys.
Finite Monkeys?
While planning this game, I wanted to make the description and premise somewhat dorky. The initial concept was to simulate a "true" version of the monkeys-on-typewriters experiment, with multiple rounds of guessing, and I wrote some test code for doing so (knowing that it wouldn't end well). A monkey would guess random words of length N until it got the right one, then a round would start for N+1. So on round 1, if the word was "A", it guesses "K"... "B"... "G"... "G"... "A"... okay! Now guess "UE", then "JHW" and so on.
The problem? Runtime. When you get to N=5 and above, the simulation becomes very slow. If we equate what the monkey in this example is doing to something more realistic, like password-guessing, it becomes clear why. If a human were guessing a 5-character password, they'd be foolish to guess the word "BEANS" once, only to guess it again a little while later. They already know the password isn't "BEANS"!
Monkeys aren't so smart, because the idea behind the experiment is that their actions are (in an abstract sense) random, or rather, any previous action has no bearing on the next in any meaningful way. This means that the "monkey approach" to password cracking is much worse on average than a brute-force attempt.
So even for tiny guesses of five characters, the program would sometimes run for much longer than it should have, because every attempt is a purely random guess. I knew the complexity would blow up very quickly, but the degree to which it exploded was a surprise - primarily because of the random element. Similarly, in I̶n̶finite Monkeys, you may notice that there are occasionally long stretches of time where no correct letter is hit, even with fast typing speeds. Fully random guesses are, generally, bad guesses.
King Lear, Act I, Scene I
Now let's use King Lear as a more specific example, because the numbers are big and that's just more fun. The first scene in the manuscript of King Lear used in this game is 14326 characters long (the entire play is 150746). All sections of whitespace are replaced with only a single basic space character, and all letters are treated as uppercase. The punctuation symbols {. , ' : ; ? -} are also included.
So, suppose we had a single monkey which would generate purely random strings of length 14326 over some period of time, at which point we'd compare it to King Lear and give the monkey a thumbs up or (much more likely) a big ol' thumbs down.
Given the previous discussion, you may guess that it would take a few attempts. This is the reason why the thought experiment proposes "infinite" of a few resources. It varies, but this usually includes infinite time, monkeys, typewriters, and presumably zookeepers (so the monkeys stay in their seats).
So, how many possible strings of length 14326 could any given monkey generate in one attempt? Well, if we confine the alphabet to what appears in the correct full text, each character in the random string can be one of 34 characters (26 letters, 1 space character, and 7 punctuation marks). Now, for each character in the string beyond the first, we multiply 34 by itself to get the total keyspace of the 14326 character string.
The number of possible strings the monkey could generate is a whopping 34^(14326). That's a decimal number that's 21940 decimal digits long . For more context, there are approximately 6 x 10^(79) atoms in the universe, which is still less than the number 34^(53). Now multiply that number by 34 again, then do that another 14272 times.
Out of all those possibilities, only a single one is the true first scene of King Lear. So it's probably fair to also assume that the monkey must be immortal for this whole operation to get off the ground; it's going to take them a while.
A Practical Compromise
Now, back to the game, which is probably still running as we speak, because half of the joke is that it's annoyingly long. I think I've made a case for why it isn't just a single chimpanzee in an armchair yelling random letters until one is right... because you'd be here until the heat-death of the universe waiting for divinely-primate-generated Shakespeare, even just to get that first act.
Instead, there's an obvious solution that makes things a bit more tolerable: make the monkeys less Darwinist and more collectivist, by which I mean they work together, and mistakes are ignored. I mean, we were already checking the output against a copy of King Lear in the last hypothetical for correctness anyways, so is writing it a letter at a time really cheating?
The answer is "yes", but again: waiting until the end of the universe certainly can't be any more appealing. It's much more interesting to watch monkeys hit things.
PS: if you want to support my future projects, check out my current game in development: VSCS-II. Thanks!
Status | Released |
Platforms | HTML5 |
Rating | Rated 4.4 out of 5 stars (134 total ratings) |
Author | Skullbutton Interactive |
Genre | Educational, Simulation |
Made with | Unity |
Tags | Animals, Funny, Idle, Math, monkey, Pixel Art, random, sitting-simulator |
Download
Click download now to get access to the following files:
Development log
- Infinite Monkeys: 1986 EditionNov 27, 2022
- CORDELIA [ASIDE]: Fixed Bracket BugNov 22, 2021
Comments
Log in with itch.io to leave a comment.
Do the monkeys get breaks
no
good
my monkeys only guess correctly if Im watching them.
fun fact: there’s a 1 in ~9x10^21939 chance of getting a perfect run. and if it was, say, the entirety of king lear… it’d be a 1 in ~2.1x10^230864 chance. fun. that’s over 11 times the itch io comment character limit.
Thank you for this interesting fact, undertaleman.
and this game is impossible it takes 10+ hours for me to beat
luck issue
in some reason the game starts slow granding money
Wow, got 2 letters at the same time with only 3 monkeys, they are evolving! Loved the game ^^
i love monkeystep, best flavor of dubstep
I forgot I had this tab open and couldn't figure out where those fresh beats were coming from.
Fun fact, in Spain, the theorem is told with Don Quixote instead, due to it being a more recognizable work here
I love this game! :D
I have one monkey and by the time I finished reading the description it had done 1 letter
I DID IT!!!
Took 2 hours
Trial 1: For data comparison, 2 hours have passed and this is my progress:
1) Maxed out all possible upgrades.
2) 9.0113% complete
3) 90.9887% incomplete
Notes: 2 hours seems quite efficient when compared to my current progress.
I guess if you have an infinite amount of monkeys with type writers, they will eventually write shakespeare
Me encanto
Being able to independently toggle either the music or fx would be nice. I like the ding to signify a correct character typed, but the music quickly becomes insufferably repetitive. Other than that, a lovely game.
This is a fantastic—well done!
they should add something to do while you wai
oh ok, didn't knew about this
seriusly!?! no fkn way :o
when I download and open the game it runs in media player, what can i do? or is the download only for the music and you have to play on the browser?
The download is indeed for the music, yep! the game only supports in-browser play so this definitely isn't intentional.
you should expand the game i got all the monkeys and upgrades to quick now i can only wait for them to finish :(
They do say that the point of the game is not to complete it and that it's just an absurd premise:
"In Infinite Monkeys, your monkeys will have to type the entire first scene of King Lear - the length of the text is part of the absurd premise; I don't actually expect you to complete it all."
ME ENCANTÓ!!!
Cool!
Seria legal se vc fizesse um projeto chamado "O macaco infinito", que seria um projeto onde vc faz literalmente esse jogo, mas as pessoas podem colocar o texto que elas quisessem no jogo, caso baixassem, assim as pessoas poderiam jogar com amigos e familiares, ou até mesmo criar conteúdo com sua comunidade, com textos que fazem sentido pra eles, não só o capítulo 1 desse livro.
I checked the Game in Development, nice touch adding the reference to this game!
Welp, going on ~3 hours and we've got 5%.
monkey smash
I did it
This is some serious monkey business
10/10 great game
Dang you! I made a game with a similar concept, and I'm hoping that my teacher doesn't look up "infinite monkey game" because you did it SO much better. If you see this Prof. Bierman, I swear I found this after making my project.
Great game, I got to like 50% and left it for the night only to discover the next day that it doesn't save your progress.
Bunch of these comments are just people skipping the whole description saying that the game being slow as dirt is literally the joke.
I dislike how their is a max speed cap. gib infinite plants pls
quit at 10 percent, took to long. remove the MAX! thing for plants and posters please.
Quitting at 10% is valid, and as long as you've read the game description, I think you got the full experience. The absurd length of the game is very much intentional.
mnketypn
you should add something that shows stats, like what the speed they are typing at, and how many correct letters each monkey has got, and so on
lol my monkey spelled n i g b a.
close one.
there should one hundred percent be a banana break option which lets you have a monkey rest for a couple seconds to eat bananas and it gives them +1% speed for every minute on banana break. I just want monke to eat banan.
monke
computer unexpectedly restarted when I was finally halfway through, it took days to get there. why.
Fun game but I feel like the limit on posters and plants makes it needlessly slow. If you could get more upgrades you could finish the game way faster.
Like, I "finished" the game (bought all upgrades) in like 20 or 30 minutes, but then there's just hours of waiting?
finally got to 1%
EDIT: everything is max and it's at 5%
EDIT2: it's been 2 hours and it's at 15%