{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Chutes and Ladders in Monte Carlo ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The game of Chutes and Ladders is pretty well known. What you didn't known until now is that you'd be cutting your Python chops in creating a simulation of the game for the purpose of gaining some serious insight. By keeping track of your simulations you'll learn some interesting things about such a simple game." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create a simulation of the game.###" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The basic idea is to try to get to square 100 starting at 0. You role a die (or spin a wheel) and play against others doing the same. If you finish a turn at the base of a ladder, you go to the top. If you finish a turn at the top of a chute (slide) you go down to the bottom of the slide. Familiarize yourself with the [full rules](http://www.hasbro.com/common/documents/dad2614c1c4311ddbd0b0800200c9a66/43EA24525056900B105B53AC74279484.pdf).\n", "\n", "First, build a compact representation of the location of the location of the chutes and ladders using a Python dictionary.\n", "\n", "Next, create `Pawn` class that keeps track of the location of a player and simulates (using the `random` module) the Pawn movement. You should also create a `Game` class that keeps track of the game play as many Pawns move throughout the board. By calling a method of Game `.run()` a full Game is simulated.\n", "\n", "Make sure that the Pawn and Game classes keep statistics on the results, like how many moves were made, how many ladders and chutes were hit, which player wins etc.\n", "\n", "Simulate 1000 games with 2 players. Simulate 1000 games with 4 players." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Questions to Answer with your Simulation ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. What is the average number of turns a player must take before she gets to 100?\n", "\n", "2. What is the minimal number of turns in the simulation before getting to 100? What was the sequence of values in the spin in each turn? What was the longest number of turns?\n", "\n", "3. What is the ordering of first spins in a game that gives, on average, the quickest path to 100? What about the median?\n", "\n", "4. What is the probability that someone who goes first will win in a 2 and 4 person game?\n", "\n", "5. (optional) Ask another question of your simulation and answer it." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }