Learn R Programming

SnakesAndLaddersAnalysis (version 2.1.0)

SnakesAndLaddersGame: Plays the Game of Snakes and Ladders

Description

This is a function that will run the game of snakes and ladders for as many players as you want.

Usage

SnakesAndLaddersGame(number.of.players = 2)

Arguments

number.of.players

a single numeric value representing the number of players. Must be greater than 0.

Value

game.output

A matrix which displays the entire game of snakes and ladders.

Warning

Do not put too many players in as your computer may crash. I have not put a limit on run time as people with more powerful computers will want to run it for longer.

Details

We use matrices here to make computations very fast and allowing millions of iterations.

References

Dr Andreas Artemiou: Programming and Statistics.

Examples

Run this code
# NOT RUN {
SnakesAndLaddersGame(1)
SnakesAndLaddersGame(100)

# Run some analysis on this, consistant, output.
x <- SnakesAndLaddersGame(7)


# }

Run the code above in your browser using DataLab