This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Calculate the average number of moves in a snakes and ladders game. | |
Because as a parent one gets roped into these board (boring?) games | |
every so often, and I wanted to calculate the average duration of a | |
snakes and ladders game. Turns out it's about 36 moves for a | |
single-player game and 15 moves for a three-player game :-) | |
> python snakes_and_ladders.py | |
Played 10000 rounds, averaged 36.0559 moves, max 324 moves, took 0.508s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SNAKES GAME | |
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting | |
import curses | |
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN | |
from random import randint | |
curses.initscr() | |
win = curses.newwin(20, 60, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Cee-lo is a gambling game played with three six-sided dice. | |
''' | |
from __future__ import print_function | |
import random | |
from collections import Counter | |
def input_float(msg): | |
''' |