Coding, Crafty, Geometry Joys, JavaScript, Math and Computer Science Everywhere, Simon makes gamez, Simon teaching, Simon's Own Code, Together with sis

Ancient Chinese Game Luk Tsut K’i Game in p5.js

Play Simon’s game: https://editor.p5js.org/simontiger/present/1pGeJY7c Code: https://editor.p5js.org/simontiger/sketches/1pGeJY7c

Simon learned this game on Brilliant.org at https://brilliant.org/practice/winning-moves/?chapter=competitive-games (Warning: this link will only work if you have a Premium Subscription to Brilliant). Brilliant describes the game as follows: “Luk tsut K’i is a board game from China in the time of Confucius. In medieval Europe, it went by the title Three Men’s Morris. This game is very similar to tic-tac-toe; the objective is for one player to get their three pieces all on the same line. If this occurs, that player wins”.

Simon and Neva playing the original paper version he made
Crafty, Geometry Joys, Math and Computer Science Everywhere, Math Riddles, Murderous Maths, Simon makes gamez, Simon teaching, Simon's sketch book, Together with sis

Fun crafty puzzles Simon did with Neva

Three boxes with fruit, all the three labels are misplaced. What is the minimum number of times one will have to sample a random piece of fruit from one of the boxes to know how to label all the three boxes correctly? From Mind Your Decisions.

Connect A and A’, B and B’, C and C’, D and D’ so that no lines intersect. (Neva added colors).

Dividing 11 coins among three people: “How many ways can you divide 11 coins to 3 people? How many ways are there if each person has to get at least 1 coin?” From Mind Your Decisions.

Solving a simple quadratic equation geometrically: the geometric interpretation of “completing the square”, a notion from deriving the quadratic formula. From Mind Your Decisions.

Which way do the arrows point? (Simon made this drawing in Microsoft Paint):

Coding, JavaScript, Notes on everyday life, Simon makes gamez, Simon's Own Code, Together with sis

Tic-Tac-Tic-Tac-Toe-Toe in p5.js

Simon has programmed this game of Tic-Tac-Tic-Tac-Toe-Toe Game in p5.js from scratch. He and his sister have had hours of fun playing it (and she turned out to be better at this strategic game):

Play Simon’s game online at: https://editor.p5js.org/simontiger/present/k9NfaDmpi

Code: https://editor.p5js.org/simontiger/sketches/k9NfaDmpi

Experiments, Murderous Maths, Notes on everyday life, Simon makes gamez, Simon teaching

2048 Cookies

We devoted the beginning of January to a goofy stop-motion project: Simon and I baked 2048 cookies! No, we didn’t bake over two thousand cookies! We only baked and decorated a little over a hundred of them, Simon had calculated that that would be enough to play the 2048 game… with cookies. Simon came up with all the editing tricks to make this project work. In the video, he also explains his winning strategy and confesses he has made another attempt to program the game, without me knowing it. Apparently, that’s how he first came up with the idea to bake the cookies, by looking up pictures of 2048 while programming and stumbling upon this blog.

Here is a link to Simon’s previous attempt to program 2048, about a year ago (he got pretty far).

Simon calculated how many cookies we needed and came up with a colour scheme
Math Tricks, Murderous Maths, Simon makes gamez, Simon teaching, Simon's sketch book

Peg Solitaire

Simon proving his peg solitaire solution:

In a game of peg solitaire, if you win you must end up on one of these 5 points! This analysis was a little more difficult than with the pyramid. Because in the pyramid, I ended up with a symmetric picture whereas with this one I ended up with an asymmetric picture. So I had to do one more step of removing all of the x’s that break the symmetry:

Coding, Crafty, Experiments, Geometry Joys, JavaScript, Math and Computer Science Everywhere, Math Riddles, Milestones, Murderous Maths, Notes on everyday life, Simon makes gamez, Simon teaching, Simon's Own Code, Simon's sketch book

Approximating pi and e with Randomness

This has been one of Simon’s most ambitious (successful) projects so far and a beautiful grand finale of 2019, also marking his channel reaching 1K subscribers. The project – approximating Euler’s number (e) in a very weird way – is based upon a Putnam exam puzzle that Simon managed to prove:

The main part of the project was inspired by 3Blue1Brown Grant Sanderson’s guest appearance on Numberphile called Darts in Higher Dimensions, showing how one’s probable score would end up being e to the power of pi/4. Simon automated the game and used the visualization to approximate e. Below is the main video Approximating pi and e with Randomness. You can run the project online at: https://editor.p5js.org/simontiger/present/fNl0aoDtW

Code: https://editor.p5js.org/simontiger/sketches/fNl0aoDtW

The history and the math behind the project:

Simon’s proof od the math behind the project:

Simon has visualized this problem and proof at: https://editor.p5js.org/simontiger/present/2uMPZ8THW

Code: https://editor.p5js.org/simontiger/sketches/2uMPZ8THW

Coding, Computer Science, Contributing, JavaScript, Milestones, Murderous Maths, Notes on everyday life, Simon makes gamez, Simon teaching, Simon's Own Code, Simon's sketch book

Simon Builds a Chess AI with Minimax

I’ve been terrible at keeping this blog up to date. One of Simon’s best project in December 2019 was creating a chess robot and I haven’t even shared it here.

We were joking how this is Simon’s baby and her name is Chessy. Simon also made an improved version with a drop-down menu allowing to choose 1 to 5 steps ahead difficulty level (warning: levels 4 and 5 may run quite slowly): https://chess-ai-user-friendly–simontiger.repl.co/

Code: https://repl.it/@simontiger/Chess-AI-User-friendly

Simon’s original 2-steps-ahead game: https://chess-ai–simontiger.repl.co/ Code: https://repl.it/@simontiger/Chess-AI

While researching how to apply the Minimax algorithm, Simon has relied on Sebastian Lague’s Algorithms Explained – minimax and alpha-beta pruning; Keith Galli’s How does a Board Game AI Work? (Connect 4, Othello, Chess, Checkers) – Minimax Algorithm Explained; a Medium article on Programming a Chess AI: A step-by-step guide to building a simple chess AI by Lauri Hartikka; of course, The Coding Train’s challenge Tic Tac Toe AI with Minimax; and What is the Minimax Algorithm? – Artificial Intelligence by Gaurav Sen.

Simon contributed his chess robot to the MINIMAX coding challenge page on the Coding Train website:

And naturally we’ve had a lot of fun simply playing with Chessy as a family:

Crafty, Math and Computer Science Everywhere, Math Riddles, motor skills, Murderous Maths, Simon makes gamez, Simon teaching, Simon's sketch book

Proof Visualization. Warning: Mind-boggling!

Inspired by the Card Flipping Proof by Numberphile, Simon created his own version of this proof. He made a solitaire game and proved why it would be impossible to solve with an even number of orange-side-up circles. He drew all the shapes in Microsoft Paint, printed them out and spent something like two hours cutting them out, but it was worth it!

The colourful pieces in the lower row are a “key” to solve the solitaire puzzle. The objective is to remove all the circles. One can only remove a circle if it’s orange side up. Once a circle is removed, its neighbouring circles have to be flipped. Using the key, start with the yellow pieces, and move in the direction of the “grater than” sign (from smallest to largest).

If there’s an odd number of orange circles in the middle, then the end pieces are the same, both orange or both white. In both cases the total number of orange circles will also be odd. If there’s an even number of orange circles in the middle, then the ends have to be different (one orange, one white).

In the case of odd number of orange pieces, the ends have to match. In the case of an even number of orange pieces, you would have pieces that point the same way at both ends. “Now we’ve proven that to make this puzzle possible it has to have an odd number of orange pieces”, Simon says.

Why? Imagine a stick figure that always walks to the right, but always faces in the direction of the arrow (as in it can’t go backwards). It would flip every time it reaches an orange circle. Focusing on everything except the ends, if there are an odd number of orange circles, the puzzle pieces would face the other way. Which means that the end pieces are the same, and therefore the end circles are the same. If there are an even number of orange circles in the middle, the puzzle pieces would face the same way. Which means that the end pieces are different, and therefore the end circles are different.

Simon finds this sort of proof easy, but I felt like my brains are going to boil and dripple through my ears and nostrils. He patently exlained it to me several times and types the above explanation, too.

Crafty, Math and Computer Science Everywhere, Notes on everyday life, Simon makes gamez, Simon's sketch book, Together with sis

Sinterklaas math game with “gingerbread buttons”

It’s Sinterklaas season in the Dutch-speaking world and, of course, as we have started baking the traditional spiced cookies called kruidnoten (“gingerbread buttons”) Simon didn’t want to miss an opportunity to play a version of peg solitaire with eatable pieces!

Simon has baked these himself (together with Neva)
the winning strategy
Simon mixing the right proportion of spices, grinding clove (then adding nutmeg, white pepper, ginger, cardamom and cinnamon)
Coding, Community Projects, JavaScript, Milestones, Simon makes gamez, Simon's Own Code

Simon’s Math Games in p5.js

Simon loves the Maths Is Fun website and has borrowed a couple of ideas for cool games from there. He wrote the code completely on his own, from scratch. Below is a video where he presents his Connect games:

Published on October 30, 2019

I’ve gone Connect Crazy!
This project is inspired by MathsIsFun, which has a lot of variations on the classic game Connect Four, the code is entirely mine.
Classic Game of Connect Four: https://editor.p5js.org/simontiger/full/TISsTqZ8D
And then I’ve made Connect Three: https://editor.p5js.org/simontiger/full/c30Oqd4Qf
And Connect Five: https://editor.p5js.org/simontiger/full/I6Digth0A
Then I’ve also made a version called Drop, where if the bottom row fills up, the whole board drops down one row:
https://editor.p5js.org/simontiger/full/Ysu2yvh1x
https://editor.p5js.org/simontiger/full/gb3gVSd5K

screen shot of Simon’s Connect 5 game

Another game Simon built was Bulls and Cows (trying to guess a sequence of letters): https://editor.p5js.org/simontiger/full/3bC9j3501 Link to Simon’s code: https://editor.p5js.org/simontiger/sketches/3bC9j3501

Yet another one was a Reaction Time test! You can test your reaction time by clicking anywhere on the screen as soon as the circle changes color: https://editor.p5js.org/simontiger/full/Gzv094mgzM Link to Simon’s code: https://editor.p5js.org/simontiger/sketches/Gzv094mgzM

screenshot of the Reaction Test

And last but not least, an unfinished project of building a Checkers game:

screenshot of Simon’s yet unfinished Checkers game sketch