Develop a python application that will simulate a simple dice game by rolling two dice for the player as his bet followed by another roll of the two dice for the computer.
The mechanics as is follows:
1. If after the roll of the two dice, resulted to same number, then the sum will be doubled.
2. If the value of each dice is different, then just get the sum of the values of each dice.
Who gets the highest value wins the game.
I need the code to have an output stated above.
import random
print("Rolling Player dice")
playerD1 = random.randint(1, 6)
print("Die 1 outcome:", playerD1)
playerD2 = random.randint(1, 6)
print("Die 2 outcome:", playerD2)
playerSum = playerD1 + playerD2
if playerD1 == playerD2:
playerSum *= 2
print("Sum:", playerSum)
print()
print("Rolling CPU dice")
cpuD1 = random.randint(1, 6)
print("Die 1 outcome:", cpuD1)
cpuD2 = random.randint(1, 6)
print("Die 2 outcome:", cpuD2)
cpuSum = cpuD1 + cpuD2
if cpuD1 == cpuD2:
cpuSum *= 2
print("Sum:", cpuSum)
print()
if playerSum > cpuSum:
print("Player Wins!")
elif playerSum < cpuSum:
print("CPU Wins!")
else:
print("It's a tie!")
Comments
Leave a comment