Coder Social home page Coder Social logo

roberts94 / game-simulation Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 892 KB

This work analyzes a simple coin game involving two players, a pot, several coins, and a die. First Step Analysis is used to determine the expected length of the game in cycles and the distribution of cycle counts is estimated using parametric probability density estimation on the output of a game simulated with Python.

Jupyter Notebook 100.00%
simulation-modeling python stochastic-processes markov-chain

game-simulation's Introduction

A Simple Coin Game, First Step Analysis and Simulation

This work analyzes a simple coin game involving two players, a pot, several coins, and a die. First step analysis is used to determine the expected length of the game in cycles, and the distribution of cycle counts is estimated using parametric probability density estimation on the output of a game simulated with Python.

The rules of the game are defined as follows: if a player rolls a 1, nothing happens, if a player rolls a 2, the player takes all the coins in the pot, if a player rolls a 3, the player takes half of the coins in the pot (rounded down), and if a player rolls a 4, 5, or 6, the player puts 1 coin in the pot. If the pot is empty and a player rolls a 2 or 3, nothing happens (the game continues). If a player rolls a 4, 5, or 6 and the player doesn’t have any coins, the game ends. A cycle is defined as a set of two turns, one by player A, then one by player B. If the game ends on player A’s turn, that turn is counted as a full cycle.

The final write-up is included in:

  • report.pdf

The Python code is broken out into two Jupyter notebooks focusing on first step analysis and simulation:

  • code/first_step_analysis.ipynb
  • code/simulation.ipynb

game-simulation's People

Contributors

roberts94 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.