Tuesday, July 26, 2022

Chutes and Ladders is totally random, just let the computer play it...

My kids like to play Chutes and Ladders as a family and I have no idea why. Even though the game is pretty much entirely random (pro spinner flickers aside), they still feel bummed when they lose. As a quick exercise, I decided to code up the game having the computer play all the turns until a winner is found. This was meant to take me 30 minutes, but I guess including my son's 30 minutes to test it, we could say it took about an hour. It's not meant to be clean or any kind of representation of proper coding, syntax, etc. so keep your expectations low...

I do not have this hosted at the moment, but the code is available on GitHub: 

https://gist.github.com/mcorrigan/086ff9b5f4de18be1a68420aca876612

P.S. If you have your console open, you can see all the moves the winner made on their way to win the game. 

No comments: