markov_chain: Simulate markov chain for a game of Snakes and Ladders

Description Usage Arguments Value Examples

Description

markov_chain simulates a markov chain for a game of Snakes and Ladders with previously described parameters. This function requires a transition matrix, and is thus meant to be used after add_snakesandladders() and create_transmatrix() in succession. probdis is initialized as a vector of 0s with the same length as the board, and probdis[1] is set to 1. markov_chain takes the transpose of the transition matrix and multiplies it with the vector probdis for each turn. The values contained in probdis after each multiplication correspond to the probability that a player will be on that square after that turn. The vector recorder records the probability that the player will be on the final square after each turn. This vector is used in the function finish_game_chance() This is repeated for the number of turns specified in the argument tau.

Usage

1
markov_chain(transmat, tau = turns)

Arguments

transmat

The transition matrix. Must be created by the function create_transmat()

tau

The number of iterations, or turns, the markov simulation is performed

Value

The vector recorder which contains the probabilities of winning the game after each turn. The index is the turn number, and the value is the probability.

Examples

1
markov_chain(transmat = create_transmatrix(), tau = 100)

iawindham/snakesandladders documentation built on May 20, 2019, 2:08 p.m.