#Code for matching number of each symbol type, locking successes #Results for 6 dice########### #----2 symbols----------- #1 each of 2 symbols ~90 #2 of a single symbol ~80 #----3 symbols----------- #1 each of 3 symbols ~80 #2 of 1, 1 of another ~70 #3 of a single symbol ~50 ** ##----4 symbols----------- #3 of 1, 1 of another ~40 ** #2 of 1, 1 of two others~55 ** #2 each of 2 symbols ~45 ** #1 each of 4 symbols ~65 easy #4 of a single symbol ~20 hard #----5 symbols----------- #1 each of 3, 2 of anoth~40 ** #1 each of 5 symbols ~45 ** #5 of a single symbol ~04 #----6 symbols----------- #3 each of 2 symbols ~04 #2 each of 3 symbols ~09 #1 each of 6 symbols ~20 hard (also means using defence/move symbols) #6 of a single symbol ~00.6 from random import randint initialdice = 6 #number of dice rolled numrolls = 3 #number of rolls allowed per turn num_tests = 1 #total number of turns to undertake #Red: slashing (ssbpmd) Yellow: piercing (ppbsmd) Green: bludgeoning (bbpsmd) Black: attack (bpsmdw) Pink: move (mmbpsd) Yellow: defence (ddbpsm) #symbols: #0 slashing, 1 bludgeoning, 2 piercing, 3 moving, 4 defence, 5 wildcard die_type = [[0 for x in range(6)] for x in range (6)] die_type[0] = [0,1,2,3,4,5] #attack die_type[1] = [0,0,1,2,3,4] #slashing die_type[2] = [0,1,2,2,3,4] #piercing die_type[3] = [0,1,1,2,3,4] #bludgeoning die_type[4] = [0,1,2,3,3,4] #movement die_type[5] = [0,1,2,3,4,4] #defence #hierarchy symbol > die_type > die_pool die_pool = [0,1,2,3,4,5] #each type of die in the pool/hand die_locked = [0,0,0,0,0,0] #1 when locked #base character would be one of each [0,1,2,3,4,5] #eg. sword would be Sword: 1 attack, 2 slash, 1 pierce, 0 bludgeon, 1 move, 1 defence [0, 1, 1, 2, 4, 5] #number of times each face/symbol must be rolled/locked (assuming 6 sided die here) eg [0,0,0,2,0,1] means two 4's and one 6 must be rolled successval = [1,0,0,0,0,0] any_success_val = 4 #any type of success #die_type[die_pool[dice]][roll] print "Success required: " for i in range(0,initialdice): print str(i+1) + ": " +str(successval[i]) #counters numdice = initialdice num_trials = 0 successes = 0 #code start #number of trials for iterations in range (0,num_tests): numdice = initialdice success = [0 for x in range(initialdice)] print"_____________________________________" print "Trial: " + str(iterations+1) #3 rolls (turns) for turns in range (0,numrolls): print " Turn "+str(turns+1) + ", Number of dice " + str(numdice) for dice in range (0, numdice): print " Die: " +str(dice) + "", if die_locked[dice] == 0: roll = randint(1,6) symbol = die_type[die_pool[dice]][roll-1] print " Roll: ", print str(roll) +", symbol: " +str(symbol) +"", if successval[symbol] > success[symbol]: die_locked[dice] = 1 success[symbol] +=1 print "match, die locking", else: print "die previously locked", print"" print "Number of trials " + str(num_trials) print "Successes: " + str(float(successes)/float(num_tests))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question