# Tricky dice game in Python

It’s a dice game between 2 people using tricky dices. For example,three dices ((1, 1, 4, 6, 7, 8), (2, 2, 2, 6, 7, 7), (3, 3, 3, 5, 5, 8)).

The code will decide, in order to win, who chooses the dice first and which dice to play. Say if you choose a dice first, return the index of the dice. Say if you decide to be the second one to choose a dice, then specify for each dice that your opponent may take, and the dice that you would take in return.

The code works but please tell me what you think or how to improve it!

``````from itertools import product

def count_wins(dice1, dice2):
assert len(dice1) == 6 and len(dice2) == 6
dice1_wins, dice2_wins = 0, 0
for p in product(dice1,dice2):
if p(0)>p(1):
dice1_wins += 1
elif p(0)<p(1):
dice2_wins += 1
return (dice1_wins, dice2_wins)

def find_the_best_dice(dices):
assert all(len(dice) == 6 for dice in dices)
for i in range(len(dices)-1):
for j in range(i+1,len(dices)):
a,b=count_wins(dices(i),dices(j))
print('ij',i,j,'ab',a,b)
if a<b:
elif a>b:
else:
ans=-1
ans=i

def compute_strategy(dices):
assert all(len(dice) == 6 for dice in dices)
strategy = dict()
strategy("choose_first") = True
strategy("first_dice") = 0
if ans!=-1:
strategy("first_dice") = ans
else:
strategy.pop("first_dice")
strategy("choose_first") = False
for i in range(len(dices)):