diff --git a/board_randimizer.py b/board_randimizer.py new file mode 100644 index 0000000..927d28f --- /dev/null +++ b/board_randimizer.py @@ -0,0 +1,34 @@ +from sys import argv +from random import randint + +def readDiceFile(path): + with open(path, 'r+') as f: + # Ignore first two lines + f.readline() + f.readline() + dice = [] + line = ''.join(f.readline().rstrip().split(',')) + while(line): + dice.append(line) + line = ''.join(f.readline().rstrip().split(',')) + + return dice + +def rollDie(die): + return str(die[randint(0, len(die) - 1)]) + +def rollDice(dice): + rolls = [] + for die in dice: + roll = rollDie(die) + rolls.append(roll) + + return rolls + +if __name__ == '__main__': + if len(argv) != 2: + print('Usage: python3 board_randomizer DICE_FILE') + else: + dice = readDiceFile(argv[1]) + print(dice) + print(rollDice(dice)) diff --git a/dice_4x4.txt b/dice_4x4.txt new file mode 100644 index 0000000..97efa97 --- /dev/null +++ b/dice_4x4.txt @@ -0,0 +1,18 @@ +front,right,back,left,top,bottom (start with 'one of' the first alphabetical chars +----------- +a,h,s,p,o,c +e,r,l,i,x,d +a,g,a,e,e,a +e,y,t,l,r,t +e,o,t,s,s,i +d,r,y,v,l,e +h,n,l,n,z,r +e,r,w,t,v,h +h,i,u,n,m,qu +e,e,h,n,w,g +d,t,y,t,i,s +a,b,b,o,o,j +e,i,u,n,s,e +a,s,p,f,k,f +c,m,u,o,i,t +a,w,t,o,o,t