Simple Dice Game
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 is as 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.
import random
playerDie1=random.randint(1, 6)
playerDie2=random.randint(1, 6)
sumResultPlayer=playerDie1+playerDie2
if playerDie1==playerDie2:
sumResultPlayer=sumResultPlayer*2
computerDie1=random.randint(1, 6)
computerDie2=random.randint(1, 6)
sumResultComputer=computerDie1+computerDie2
if computerDie1==computerDie2:
sumResultComputer=sumResultComputer*2
if sumResultPlayer>sumResultComputer:
print(f"Player gets the highest value {sumResultPlayer} wins the game.")
else:
print(f"Computer gets the highest value {sumResultComputer} wins the game.")
Comments
Leave a comment