Simon finds the explanation on Brilliant.org incomplete, so he started a discussion about it on the Brilliant community page: https://brilliant.org/discussions/thread/games-of-chance-course-marble-problem/?ref_id=1570424
Simon’s code is published online at:
“If I take many random walks and see what the endpoints of those random walks are, what I’ll find is a Gaussian distribution!” Simon says. In the video, he programs 1D and 2D random walks and 2D and 3D histograms to show the distribution of the endpoints in Wolfram Mathematica.
Simon has tried to find out whether each of the players have equally fair chance to win a NIM game. In many games that’s exactly the case, but not in the game of NIM, as Simon proves in the course of these two videos. If you just want to see the math behind it, feel free to only watch the second video:
The game of NIM is about flipping two coins and playing with 12 more coins. Depending on what a player throws (two heads, heads-tails, tails-heads or two heads) she can claim a number of coins from the 12 (corresponding to the binary value of the throw, that can vary from 1 to 4 coins). The person who claims the last coin wins all the 12 of them. Simon has proved that the person starting the game (according to the rules of the game, that’s the person who brought in the money) has better chances of winning!
Simon learned about the game of NIM from Matt Parker’s Stand Up Math channel, but worked out the proof himself.
Simon created this coin flip simulation in the form of a game that runs until you get 10 heads in a row. In the video, he explains what the chance that you get 10 heads in a row is, and how he calculated the average number of flips it should take. We also actually play the game and get very lucky the first time and very unlucky the second time. Simon talks about the code he wrote in the second part of the video.
Simon also built another coin flip game in Processing: Coin Flip simulation that doubles the number of coins in the pot as long as you get consecutive heads and clears the pot once you throw tails. At one point, Simon got 12 heads in a row, which means that he had 2^12 coins in the pot (4096). What is the chance of getting that? (It’s actually 1 in 8192). How cool is that?
More images of the game:
This random number generator Simon built in Processing simultaneously graphs the probability of the values as you “throw the dice”. This is Simon’s own code and what’s more, he has turned it into a truly scientific experiment/observation. Simon programmed the generator to automatically throw the dice every 60 frames a second (i.e. every 1/15th of a second). The graph showing the probability of certain values should increasingly resemble a perfect isoceles triangle the more throws occur, because the probability of you getting 7 is much higher than those of getting 2 or 12.
The perfect triangle was drawn at around 4000 throws.
Simon also experimented with programming the same generator for 3 dice. The graph should then form a bell shaped curve, a parabola, and takes a longer while to shape up. “As the number of dice grows towards infinity, the distribution will change from a uniform distribution to a Gaussian distribution”, – Simon explains.
What does Simon do when he is sick and free from having any lessons? Follow a course on probability theory and logarithms (which he watched four times), writing equations and trying to program a circle as an infinite number of sides. His mother spent a couple hours digging up information on logarithms and the number of sides in a circle today.
Here are Simon’s notes in Word. On probability theory, where c is the chance, t is the number of times and p – the possibilities.
And about these equations he said that the first one is about exponents, the second is about square roots and the third one is about logarithms:
Simon’s project online: https://alpha.editor.p5js.org/simontiger/sketches/HJBw-fOng