def __init__ (self,sigdis, detectiondis, gendis, minships, genships, fighterprob, enemyprob, capprob, credits_to_maximize_difficulty, capdist):#negative garbage collect dist disables that feature Director.Mission.__init__(self) self.loops=(difficulty (credits_to_maximize_difficulty), random_encounters (sigdis, detectiondis, gendis, minships,genships,fighterprob,enemyprob,capprob,capdist), trading (), dynamic_universe, #garbage_collect (), hideProgress())
def p1vsai(): clearScreen() diff = difficulty() time.sleep(1.5) board = Board() turns_taken = 0 possible_nums = [str(i) for i in range(1, 10)] last_move, AI_XO, p1_XO = chooseXO() while turns_taken < 9: clearScreen() board.print_board() if last_move == "p1": print("Bot's turn") time.sleep(1.5) if diff == "E": possible_nums = AI_turn_easy(board, possible_nums, AI_XO, p1_XO) elif diff == "H": possible_nums = AI_turn_hard(board, possible_nums, AI_XO, p1_XO) elif diff == "I": possible_nums = AI_turn_impossible(board, possible_nums, AI_XO, p1_XO) last_move = "AI" elif last_move == "AI": print("Player 1's turn") possible_nums = p1_turn(board, possible_nums, p1_XO) last_move = "p1" win = check_win(board, turns_taken) if win == None: pass else: break turns_taken += 1 clearScreen() board.print_board() if win == AI_XO: print("Bot wins. You lose :(") time.sleep(1.5) elif win == p1_XO: print("You win :) Congratulations!") time.sleep(1.5) else: print("It was a draw") time.sleep(1.5) time.sleep(1.5)
def reinit(self): self.docked_un=None self.current_un=VS.Unit() self.player_num=-1 self.objectives=0 self.callsign='' self.ship='Llama.begin' #self.loops=() from difficulty import difficulty self.loops = (difficulty(850000), ) server_lib.player_reinit(self)
def __init__ (self,sigdis, detectiondis, gendis, minships, genships, fighterprob, enemyprob, capprob, credits_to_maximize_difficulty, capdist):#negative garbage collect dist disables that feature #print "initing direct" Director.Mission.__init__(self) #print "done direct" self.loops=(difficulty (credits_to_maximize_difficulty), random_encounters (sigdis, detectiondis, gendis, minships,genships,fighterprob,enemyprob,capprob,capdist), trading (), dynamic_universe, total_jump.total_jump() # garbage_collect (), )
def __init__( self, sigdis, detectiondis, gendis, minships, genships, fighterprob, enemyprob, capprob, credits_to_maximize_difficulty, capdist): #negative garbage collect dist disables that feature debug.debug("initing direct") Director.Mission.__init__(self) debug.debug("done initing direct") self.loops = ( difficulty(credits_to_maximize_difficulty), random_encounters(sigdis, detectiondis, gendis, minships, genships, fighterprob, enemyprob, capprob, capdist), trading(), dynamic_universe, total_jump.total_jump() # garbage_collect (), )
) elif system == "Windows": print("Only silly children become hanged, now press") os.system('pause') time.sleep(0.2) try: level = int( input( "Now is the time to prove that you are not a fool, choose the level from 1 to 3: " )) except: while level != 1 and level != 2 and level != 3: level = int( input( " you are a fool, choose again the level from 1 or 2 or 3 \n")) lifes = difficulty(level) game(lifes) goback = input("\nDo you want to try again useless? Y/N\n") if goback == "y" or goback == "Y" or goback == "yes" or goback == "YES": while True: title() vidas = 10 game(lifes) goback = input("Do you want to try again useless? Y/N \n") if goback == "y" or goback == "Y" or goback == "yes" or goback == "YES": pass elif goback == "n" or goback == "N" or goback == "not" or goback == "NOT": print("are you a chicken?\nThis is not for cowards") time.sleep(0.5) break elif goback == "n" or goback == "N" or goback == "not" or goback == "NOT":
def fitness(individual, ground): paths = np.flip(individual.trail_set, axis=2) lifts = individual.chair_set pathLengths = [] path_points = [] for path in paths: temp_path = path_lib() temp_path.set_points(path) single_point = temp_path.calc_locations(20) path_points.append(single_point) pathLengths.append(ground.length_of_path(np.array(single_point))) totalPathLength = np.sum(pathLengths) #print(pathLengths) penalty = 0 if (totalPathLength > feet_to_deg(656168)): penalty += (totalPathLength - feet_to_deg(656168)) * -.01 if (totalPathLength < feet_to_deg(524934)): penalty += (feet_to_deg(524934) - totalPathLength) * -.01 if (len(lifts) > 19): penalty += (len(lifts) - 19) * -.2 if (len(lifts) < 3): #feet penalty += (3 - len(lifts)) * -.4 pathDiff = diff.difficulty(paths, ground) green = np.where(pathDiff == 0, 1, 0) blue = np.where(pathDiff == 1, 1, 0) black = np.where(pathDiff == 2, 1, 0) #print("Printing pathDiffs") #print(pathDiff) greenLength = np.sum(green * pathLengths) blueLength = np.sum(blue * pathLengths) blackLength = np.sum(black * pathLengths) lengthByDiff = np.array([greenLength, blueLength, blackLength]) liftDistance = [] skiTimeDown = [] for lift in lifts: Xcoords = np.linspace(lift[0][0], lift[1][0], 300) Ycoords = np.linspace(lift[0][1], lift[1][1], 300) #liftPath = np.swapaxes(np.array([Xcoords, Ycoords]), 0, 1) liftDistance.append(ground.length_of_path(np.array([Xcoords, Ycoords]))) elevations = ground.height_at_coordinates( np.array([[lift[0][0], lift[1][0]], [lift[0][1], lift[1][1]]])) skiTimeDown.append(abs((elevations[1] - elevations[0]) / descentSpeed)) liftTimeToTop = np.array(liftDistance) / liftSpeeds trailLengthsPerLift = np.zeros((len(lifts))) i = 0 for lift in lifts: lengthByLift = 0 for index in individual.trails_owned(lift): lengthByLift += ground.length_of_path(paths[index]) trailLengthsPerLift[i] = lengthByLift i += 1 liftCapacity = np.array([200] * len(lifts)) #FIXXXXX TODO TODO congestScore = congest.congFitness(totalPeople, trailLengthsPerLift, liftCapacity, liftTimeToTop, skiTimeDown) #print([varietyScores[0],varietyScores[1],congestScore]) fit = weights["difficulty"] + weights["congestion"] * congestScore + penalty return fit