def cphase(n, L_prime): # Start with a clean slate resources = create_empty_resources() # Create the initial \ket{\psi_{n,1}} rps_res = rps(n=n) # Copy to create m \ket{\psi_{n,1}} via addition add_res = add(m = L_prime, n = n) resources = combine_resources(rps_res, add_res) # Add n Hadamards for creating \ket{\psi_{n,0}} resources['single'] += n resources['depth'] += 1 # Add negations for L_prime * n addends, and then for the n-bit result resources['single'] += ((L_prime*n) + n) resources['depth'] += 2 # We need to load the values of l for each cphase gate w/ NOT gates resources['single'] += (L_prime * n) resources['depth'] += 1 # We also need to simulate the cphase gates by adding the l values with DKRS # These can be done in parallel add_res = dkrs_add(n = n) #print "before multiply: " + str(add_res) add_res = multiply_resources_with_ancillae(add_res, L_prime) #print str(add_res) resources = combine_resources(resources, add_res) return resources
def execute_play(game_id): """This function takes the name of a mini-game and then calls it. The game is then played by the player, if the player loses the mini-game, the player must "have a drink", which is implemented by a counter. If the player wins the mini-game, then the player doesn't incur any "drinking" penalties, i.e. the counter remains the same. """ global alcoholCounter global winCounter if game_id == "rps": # RPS works fine if current_room == rooms["Tiger Tiger"]: alc, win = rps() if alc == True and win == False: alcoholCounter += 1 elif alc == False and win == True: winCounter += 1 else: print("You cannot play that game here.") elif game_id == "hangman": # Problem! Hangman won't seem to reset when you play it again! if current_room == rooms["Students Union"]: alcFromHangman = exec_hangman() if alcFromHangman < 6: winCounter += 1 alcoholCounter += alcFromHangman else: print("You cannot play that game here.") elif game_id == "fetch": # Works fine. if current_room == rooms["Retros"]: fetch() else: print("You cannot play that game here.") elif game_id == "riddle": # Works fine. if current_room == rooms["Pryzm"]: riddleNumber = random.randint(1, 6) if (riddleNumber == 1): alcFromRiddle, winFromRiddle = riddle_one() if (alcFromRiddle == True and winFromRiddle == False): alcoholCounter += 1 else: winCounter += 1 if (riddleNumber == 2): alcFromRiddle, winFromRiddle = riddle_two() if (alcFromRiddle == True and winFromRiddle == False): alcoholCounter += 1 else: winCounter += 1 if (riddleNumber == 3): alcFromRiddle, winFromRiddle = riddle_three() if (alcFromRiddle == True and winFromRiddle == False): alcoholCounter += 1 else: winCounter += 1 if (riddleNumber == 4): alcFromRiddle, winFromRiddle = riddle_four() if (alcFromRiddle == True and winFromRiddle == False): alcoholCounter += 1 else: winCounter += 1 if (riddleNumber == 5): alcFromRiddle, winFromRiddle = riddle_five() if (alcFromRiddle == True and winFromRiddle == False): alcoholCounter += 1 else: winCounter += 1 else: print("You cannot play that game here.") elif game_id == "numberguesser": # Works fine. if current_room == rooms["Glam"]: pass alcoholCounter += number_guesser() winCounter += 1 else: print("You cannot play that game here.") elif game_id == "blackjack": # Untested if current_room == rooms["Live Lounge"]: pass alcoholCounter += blackjack() winCounter += 1 else: print("You cannot play that game here.") elif game_id == "mastermind": # Works fine. if current_room == rooms["Unse Unse Unse"]: alcoholCounter += mastermind() winCounter += 1 else: print("You cannot play that game here.") else: print("This doesn't make sense.") print("Overall, you have consumed " + str(alcoholCounter) + " units of alcohol.") print("Overall, you have won the mini-games " + str(winCounter) + " times.") time.sleep(3)
from rps import * for i in range(6,24): resources = rps(n=i) print "n= " + str(i) print "resources= " + str(resources)