We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Markov's Snakes And Ladders
Markov's Snakes And Ladders
Sort by
recency
|
24 Discussions
|
Please Login in order to post a comment
Be aware that the n_step<1000 condition should be included, otherwise the result of case 0 will be larger than expected.
Easy way to sample from categorical:
Ref: https://en.wikipedia.org/wiki/Categorical_distribution#Sampling_via_the_Gumbel_distribution
from random import choices
n=input()
p=[1,2,3,4,5,6]
for i in range(0,int(n)):
#print(i , dice_turn) #print(counter) if i == 100: break counter += 1 dice_turn = roll(p,w) if (i+int(dice_turn[0])) <= 100: i = i+int(dice_turn[0]) for start,stop in ladder_dict.items(): #print(i , start , stop) if i == int(start): #print("value matched ladder") i = int(stop[0]) for start,stop in snake_dict.items(): #print(i , start , stop) if i == int(start): #print("value matched snake") i = int(stop[0])
Hi
I have written the below code and its working fine. Since its taking random values, its not matched with the expected values. Can you please me identify whats wrong in this ?
from random import choices
n=input()
p=[1,2,3,4,5,6]
for i in range(0,int(n)):
print(ladder_dict)
print(snake_dict)
#print(i , dice_turn) #print(counter) if i == 100: break counter += 1 dice_turn = roll(p,w) if (i+int(dice_turn[0])) <= 100: i = i+int(dice_turn[0]) for start,stop in ladder_dict.items(): #print(i , start , stop) if i == int(start): #print("value matched ladder") i = int(stop[0]) for start,stop in snake_dict.items(): #print(i , start , stop) if i == int(start): #print("value matched snake") i = int(stop[0])