コード例 #1
0
def role():
    cheater1 = Cheat_Swapper()
    cheater2 = Cheat_Loaded_Dice()

    cheater1.roll()
    cheater2.roll()
    print("=" * 70)
    print("Player 1 rolled " + str(cheater1.get_dice()), sum(cheater1.get_dice()))
    print("Player 2 rolled " + str(cheater2.get_dice()), sum(cheater2.get_dice()))


    cheater1.cheat()
    cheater2.cheat()
    print("=" * 70)
    print("Player 1 rolled " + str(cheater1.get_dice()), sum(cheater1.get_dice()))
    print("Player 2 rolled " + str(cheater2.get_dice()), sum(cheater2.get_dice()))

    if sum(cheater1.get_dice()) == sum(cheater2.get_dice()):
        print("Draw")
    elif sum(cheater1.get_dice()) > sum(cheater2.get_dice()):
        print("Player 1 Wins")
    else:
        print("Player 2 Wins")
コード例 #2
0
#!/usr/bin/env python3

from cheatdice import Player
from cheatdice import Cheat_Swapper
from cheatdice import Cheat_Loaded_Dice

cheater1 = Cheat_Swapper()
cheater2 = Cheat_Loaded_Dice()

cheater1.roll()
cheater2.roll()

cheater1.cheat()
cheater2.cheat()

print("Cheater 1 rolled " + str(cheater1.get_dice()))
print("Cheater 2 rolled " + str(cheater2.get_dice()))

if sum(cheater1.get_dice()) == sum(cheater2.get_dice()):
    print("Draw!")

elif sum(cheater1.get_dice()) > sum(cheater2.get_dice()):
    print("Cheater 1 Wines!")

else:
    print("Cheater 2 Wine!")

コード例 #3
0
ファイル: dice_contest.py プロジェクト: subash-kc/mycode
from cheatdice import Cheat_Loaded_Dice

swapper = Cheat_Swapper()
loaded_dice = Cheat_Loaded_Dice()
swapper_score = 0
loaded_dice_score = 0
number_of_games = 100000
game_number = 0
print("Simulation running")
print("==================")
while game_number < number_of_games:
    swapper.roll()
    loaded_dice.roll()

    swapper.cheat()
    loaded_dice.cheat()
    #Remove # before print statements to see simulation running
    #Simulation takes approximately one hour to run with print
    #statements or ten seconds with print statements
    #commented out

    #print("Cheater 1 rolled" + str(swapper.get_dice()))
    #print("Cheater 2 rolled" + str(loaded_dice.get_dice()))
    if sum(swapper.get_dice()) == sum(loaded_dice.get_dice()):
        #print("Draw!")
        pass
    elif sum(swapper.get_dice()) > sum(loaded_dice.get_dice()):
        #print("Dice swapper wins!")
        swapper_score += 1

    else:
コード例 #4
0
#!/usr/bin/env python3

#Commented by: Kyle Jorgensen
#This dice sim imports classes from another file

from cheatdice import Player #Import necessary classes
from cheatdice import Cheat_Swapper #Import necessary classes
from cheatdice import Cheat_Loaded_Dice #Import necessary classes

cheater1 = Cheat_Swapper() #This is the one who rolls 6 on roll 3 every time.
cheater2 = Cheat_Loaded_Dice() #This is the one who adds 1 to every value (except 6)

cheater1.roll() #Players roll their random numbers as normal
cheater2.roll()

cheater1.cheat() #Call cheat function to work some magic on those random ints
cheater2.cheat() #Call cheat function to work some magic on those random ints

print("Cheater 1 rolled" + str(cheater1.get_dice())) #Report results
print("Cheater 2 rolled" + str(cheater2.get_dice()))

if sum(cheater1.get_dice()) == sum(cheater2.get_dice()): #If sums are the same:
  print("Draw!")

elif sum(cheater1.get_dice()) > sum(cheater2.get_dice()): #If cheater1 sum is higher:
  print("Cheater 1 wins!")

else: #If cheater2 sum is higher:
  print("Cheater 2 wins!")