Description Usage Arguments Value Examples
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
.
1 | markov_chain(transmat, tau = turns)
|
transmat |
The transition matrix. Must be created by the function |
tau |
The number of iterations, or turns, the markov simulation is performed |
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.
1 | markov_chain(transmat = create_transmatrix(), tau = 100)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.