A few times I've gotten a notion to do simulations of simple board games. I was inspired by playing Chutes and Ladders with my son. I realized that I would much rather write a computer program to play this game for me, so I did. It could play 2.8 million games per second, and I collected some data: Average game is 18.7 rounds, with 73.4 spins. Shortest observed game was 7 rounds, longest 145. The ladders help more than the chutes hurt. Players going first have an advantage. Most of the game is spent on the bottom half of the board. Heat map of most common player positions // 100 entries, containing the space number you should move to. // If a ladder, contains a number higher than the index it's at // If a slide, contains a smaller number than the index it's at // If neither, contains its own index. int[] spaces; // current space each player is on, size == 4 int[] players; while (true) // keep playing 'til someone wins { ...
Comments
Post a Comment