#!/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!")
from cheatdice import Player from cheatdice import Cheat_Swapper from cheatdice import Cheat_Loaded_Dice from cheatdice import Cheat_Always_Six cheater1 = Cheat_Swapper() cheater2 = Cheat_Loaded_Dice() cheater3 = Cheat_Always_Six() cheater1.roll() cheater2.roll() cheater3.roll() cheater1.cheat() cheater2.cheat() cheater3.cheat() print("Cheater 1 rolled" + str(cheater1.get_dice())) print("Cheater 2 rolled" + str(cheater2.get_dice())) print("Cheater 3 roller" + str(cheater3.get_dice())) if sum(cheater1.get_dice()) == sum(cheater3.get_dice()): print("Draw!") elif sum(cheater1.get_dice()) > sum(cheater3.get_dice()): print("Cheater 1 wins!") else: print("Cheater 3 wins!")
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")
#!/usr/bin/env python3 from cheatdice import Player from cheatdice import Cheat_Swapper 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()):
#!/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() print(f"Cheater 1 rolled {str(cheater1.get_dice())}") print(f"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 wins!") else: print("Cheater 2 wins!")
#!/usr/bin/env python3 #25 May 2018, Lab 34b from cheatdice import Player #non-cheating player class with standard dice rolling from cheatdice import Cheat_Swapper #cheater that always gets a 6 for 3rd roll from cheatdice import Cheat_Loaded_Dice #cheater that uses loaded dice (loaded in this case adds 1 to every roll less than 6) cheater1 = Cheat_Swapper() #cheater1 always gets a 6 via cheat_swap func cheater2 = Cheat_Loaded_Dice( ) #cheater2 gets +1 for every roll via cheat_load func #standard rolls that feed the cheating functions cheater1.roll() cheater2.roll() #cheating functions executed, same verbiage 'cheat()' but maps to different classes/cheats cheater1.cheat() cheater2.cheat() #display values of rolls print("Cheater 1 rolled" + str(cheater1.get_dice())) print("Cheater 2 rolled" + str(cheater2.get_dice())) #if/elif/else operator to determine winner if sum(cheater1.get_dice()) == sum(cheater2.get_dice()): print("Draw!") elif sum(cheater1.get_dice()) > sum(cheater2.get_dice()): print("Cheater 1 wins!") else:
''' Test the objects created in cheatdice.py John Nealy ''' #import the classes from cheatdice import Player from cheatdice import Cheat_Swapper from cheatdice import Cheat_Loaded_Dice # instantiate cheaters cheater1 = Cheat_Swapper() #cheats by swapping the last roll for a 6 cheater2 = Cheat_Loaded_Dice() #cheats by bumping up each roll by 1 (to a max value of 6) #players roll the dice cheater1.roll() cheater2.roll() #now they cheat - shameful! cheater1.cheat() cheater2.cheat() #print the results and declare a winner or a draw 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 wins!")
#!/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!")