What quality standards do you want to fulfil (what do you mean by “best”)? What is your goal for this question?
Some advice:
Fix your syntax errors:
>>> for i in range(0,size):
... for j in range(0,min(6, last-i)):
File "<stdin>", line 2
for j in range(0,min(6, last-i)):
^
IndentationError: expected an indented block
There are more and other syntax errors, make sure code you post can be run.
Check your results
After that, your code should run and produce a board, if I am not mistaking. Check that the board is like you expect.
Use numpy?
You do not show your imports, but it looks like you want to be using numpy (np.zeros etc.). Is that required? It adds to the learning curve, I think this problem is easier to solve using “plain Python” and the Standard Library.
We have board is going to be 10x10, which means we have 100 tiles in total. The game starts at tile 0 and ends at tile 99. We are going to use a Markov Chain to study the game, and so we need a 100x100 stochastic matrix. We start by creating the matrix for the Markov chain graph of an empty board:
source code:
size = 100
first = 0
last = 99
board = np.zeros((size, size), dtype = float)
board[last, last] = 1.0
for i in range(0,size):
for j in range(0,min(6, last-i)):
board[i+j+1,i] = 1.0
colsum = np.dot(allone, board)
allone = np.ones((1,size))[0]
for i in range(size):
board[:,i] /= colsum[i]
def addShortCut(board, i, j):
board[j, :] += board[i, :]
board[i, :] = np.zeros(size, dtype = float)
now:
Add 5 snakes and 5 ladders to the game using “addShortCut”
I need python code which answers the following questions:
For one player playing the game:
What is the minimal number of rolls needed to finish the game
What is the average number of rolls needed to finish the game.
What percentage of games are finished after 30 rolls.
What percentage of games are finished after 50 rolls.
How many rolls are needed for 90% of games to be finished.