def update(): ISIN = request.args.get("ISIN","",type=str) if not ISIN: print "Error" r = {'data' :Start.getShare(ISIN),'name': ISIN} result = Response(json.dumps(r),mimetype='application/json') return result
def test_list_int(self): """ Test 2Medium """ completion_list = [ 'CATHERIN', 'TOM', '', 'Luke Shoun', 'Marquitta Strassel', 'BEBE', 'CARRION', '', 'Lynn Gartman', 'Isis Ade', 'WILLENA', 'PERRIN', '', 'Valentin Puthoff', 'Jung Imrie', 'DIA', 'HORAN', '', 'Florentino Lohwasser', 'Kevin Himebaugh', 'DENISSE', 'HALES', '', 'Jamison Discenza', 'Edna Rippon', 'DELORAS', 'GARMON', '', 'Kirby Garringer', 'Tiesha Fannings', 'DELILA,FITTS', '', 'Theodore Mccament', 'Charis Lauster', 'DAYSI', 'DELL', '', 'Jeffry Raymo', 'Megan Hogancamp', 'DAKOTA', 'BOHN', '', 'Maynard Kefauver', 'Desiree Centola', 'CURTIS', 'ATCHISON', '', 'Mary Bollozos', 'Shana Mould', 'CRYSTLE', 'WORTH', '', 'Adolfo Gasco', 'Curtis Dukelow', 'CONCHA', 'WISNIEWSKI', '', 'Nicholas Dado', 'Esta Holla', 'COLBY', 'WILL', '', 'Virgilio Ranft', 'Laurence Cina', 'CLARETTA', 'VANWINKLE', '', 'Wayne Champoux', 'Karon Adkins', 'CHU', 'STURM', '', 'Julio Rio', 'Krystina Koszyk', 'CHRISTIA', 'SALLEE', '', 'Jonathon Suganuma', 'Debbra Berky', 'CHARLSIE', 'PROSSER', '', 'Josue Carasco', 'Dean Buchta', '', 'FAWCETT', '', 'Michal Woodside', 'Coral Solon', '', 'EADS', '', 'Martin Farson', 'Estell Nanney', '', 'DRIGGERS', '', 'Rashad Pistoresi', 'Margot Rosenberg', '', 'DONLEY', '', 'Randal Homs', 'Vicky Mendonsa', '', 'COLLETT', '', 'Olin Trafton', 'Veola Espenoza' ] self.assertListEqual(Start.Medium("2Medium.csv"), completion_list)
def game_screen(): # 화면에 표현해주는 함수 global score pygame.mouse.set_visible(True) pygame.display.set_caption('우주에서 살아남기') start_image = pygame.image.load('./PySpaceShip/game_screen.png') screen.blit(start_image, [0, 0]) draw_text('우주에서 살아남기', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 50), screen, WINDOW_WIDTH / 2, 100, (255, 255, 255)) draw_text('마우스를 움직여서 수룡이가 암석을 피할 수 있게 도와주세요!', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 18), screen, WINDOW_WIDTH / 2, 170, WHITE) draw_text('게임 중 수정구 아이템을 획득할 수 있습니다.', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 18), screen, WINDOW_WIDTH / 2, 210, WHITE) draw_text('클릭으로 수정구를 사용하여 암석을 모두 제거할 수 있습니다.', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 18), screen, WINDOW_WIDTH / 2, 250, WHITE) draw_text('마우스 버튼이나 "1"키를 누르면 게임이 시작됩니다.', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 18), screen, WINDOW_WIDTH / 2, 310, (255, 255, 255)) draw_text('"0"키를 누르면 메인화면으로 돌아갑니다.', pygame.font.Font('./PySpaceShip/NanumGothic.ttf', 18), screen, WINDOW_WIDTH / 2, 350, (255, 255, 255)) draw_text('점수: {}'.format(score), default_font, screen, WINDOW_WIDTH / 2, 390, YELLOW) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: return 'quit' elif event.key == pygame.K_0: import Start Start.main_loop() elif event.key == pygame.K_1: return 'play' if event.type == pygame.MOUSEBUTTONDOWN: return 'play' if event.type == QUIT: return 'quit' return 'game_screen'
def askSwitchMode(self, root): ans = messagebox.askquestion( title="Switch user mode", message= "Switching user mode will close the current window, do you want proceed?" ) if ans == 'yes': root.destroy() start_window = start.Start()
def __init__(self): random.seed(datetime.now()) self.st = Start.Start() self.tabuleiro = self.st.startTabuleiro() self.saco = self.st.startSaco() self.dicionario = self.st.startDicionario() self.pecas_P1 = self.startPecas() self.pecas_P2 = self.startPecas() self.permuta = [] self.palavrasVD = []
def __init__(self, data): self.data = data expression = self.data.get_parameter() self.commands_event = { CommandsEnum.start.value: Start(), CommandsEnum.help.value: Help(), CommandsEnum.math.value: Math(expression) } self.response = ""
def module_init(): os.chdir( "C:/Users/ADM/Desktop/Temporários/Rats" ) # rats significa a pasta aonde estão os arquivos a serem analizados print("Seu diretório atual é: C:/Users/ADM/Desktop/Temporários/Rats") r = input("\nDeseja mudar de diretório? [y/n]") try: if r == 'y': return select_directory() elif r == 'n': global directory directory = str(os.getcwd()) return list_directorys() else: print("Comando inválido") return module_init() except KeyboardInterrupt: r = input("Deseja voltar ao menu inicial? [y/n]") if r == 'y': import Start Start.initialization() else: return module_init()
def __init__(self): ''' Defines the game screen. param list:(object) only needs self return: (None) ''' pygame.init() self.begin = True while self.begin: self.x = WIDTH / 2 self.y = HEIGHT - 140 self.cont = True self.front = Start.Start() if self.front.choice(): try: self.char = Char.Char() self.image = self.char.start() self.display = pygame.display.set_mode((WIDTH, HEIGHT)) self.background = pygame.Surface( self.display.get_size()).convert() self.room = pygame.image.load('classroom2.jpg') self.room = pygame.transform.scale(self.room, (1000, 700)) self.background.blit(self.room, (0, 0)) self.ship = ship.ship(self.image[0], self.x, self.y) self.alien = [] self.bullet = [] self.num = 0 self.speed = 1 self.spriteship = pygame.sprite.Group(self.ship) self.spritealien = pygame.sprite.Group(self.alien) self.spritebullet = pygame.sprite.Group(self.bullet) self.font = pygame.font.SysFont('bodoniblack', 30) self.score = score.score() self.value = self.font.render( 'Score: ' + str(self.score.count), True, (0, 255, 0)) self.game = Controller.start(self) self.end = End.End(self.game) Controller.end(self) except: self.cont = False else: self.end = End.End(0) Controller.end(self) if not self.cont: self.begin = False
def test_list_goods(self): """ Test the Hard Case """ product_list = [ "5.2 in Midas 2-in-1 Classic Fragrance Warmer", 17.99, "600 Thread Count Supima Cotton Sateen Sheet Set", 69.97 - 84.97, "StyleWell Glenville White Kitchen Cart with 2 Drawers", 183.20, "4 in. x 16.74 in. 16-Piece Distressed Barn Wood Plank Blue Peel and Stick Wall Decals", 20.24, "Cuckoo 6-Cup Induction Heating Pressure Rice Cooker in Dark Gray", 520.00, ] self.assertListEqual(Start.Hard("3Hard.csv"), product_list)
def api_board(): board = json.loads(json.dumps(request.json['board'])) score = json.dumps(request.json['score']) score_vs = json.dumps(request.json['score_vs']) player = json.dumps(request.json['player']) round = json.dumps(request.json['round']) launch_ia = Start.Ai(board, score, score_vs, player, round) returnSet = launch_ia.MinMax() valueToReturn = list(returnSet) js = json.dumps({"x": valueToReturn[0][0], "y": valueToReturn[0][1]}) resp = Response(js, status=200, mimetype='application/json') return resp
print "argument", i, sys.argv[i] print('start initialize') size = 100 print('start over') dfs = DFS.DFS() bfs = BFS.BFS() # print "p" probability p of a cell being occupied as density # print Length for the average shortest path length print "density, Length" for i in range(0, 450): # every turn density increase 0.001,from 0-0.45 density = float(i) / 1000 count = 0 success_3_count1 = 0 success_3_count2 = 0 start = Start.Start(size, density) # get 100 map with a path and calculate the average path length while count < 100: start.paint_random() success1 = dfs.dfs_route(start.get_matrix(), size) success2 = bfs.bfs_init(start.get_matrix(), size) # for every time find a path, get the average path length if success1[0] == 1: count += 1 success_3_count1 += success1[2] if success2[0] == 1: count += 1 success_3_count2 += success2[2] print density, print float(success_3_count1) / 100, float(success_3_count2) / 100 print('end')
def parse(str): #start up the emulator if (str == "-init"): Start.start() Done = TerminateKeyInput("icon.png", "enter", "App opened.") if (Done != ""): return Done else: return "Error starting up the app." #return to home if (str == "-h"): Start.openApp() SendKeyInput("home.png", "h") #run dimension missions if (str == "-dm"): Start.openApp() SendMouseClick("home.png") SendMouseClick("enter.png") SendMouseClick("dm.png") SendMouseClick("ready.png") SendMouseClick("clear.png") SendMouseClick("cmax.png") SendMouseClick("home.png") noEnergyErr = TerminateKeyInput("noenergy.png", "n", "Out of energy. Returning to home.") if noEnergyErr != "": SendKeyInput("home.png", "h") return noEnergyErr time.sleep(4) SendMouseClick("close.png") Done = TerminateKeyInput("home.png", "h", "Done.") if Done != "": return "Done." else: return "Error." #collect antimatter from store if (str == "-lab col"): Start.openApp() SendMouseClick("home.png") SendMouseClick("list.png") SendMouseClick("lab.png") SendMouseClick("amcollect.png") time.sleep(0.5) Done = TerminateKeyInput("home.png", "h", "Antimatter collected. Returning to home.") if Done != "": return Done else: return "An error occurred." #Legendary battle: Loki Ragnarok if (str == "-lb"): Start.openApp() SendMouseClick("start.png") pyautogui.press("l") time.sleep(10) pyautogui.press("l") while True: if (Recognition.locate("repeat.png")): pyautogui.press("l") time.sleep(4) return "Stage complete." pyautogui.press("l") pyautogui.press("l") time.sleep(0.5) pyautogui.press(";") pyautogui.press(";") time.sleep(0.5) pyautogui.press("'") pyautogui.press("'") time.sleep(0.5) pyautogui.press("[") pyautogui.press("[") time.sleep(0.5) pyautogui.press("p") pyautogui.press("p") time.sleep(0.5) return ""
print( ' | 3) Credits | \n | 4) Exit |' ) print(' |___________________|') try: option = int(input('Enter your option:(1-4)>')) except: print( 'Genius, Enter only number,\nIf you do not know number go learn and come ;-p :\n ' ) if option == 1: Name = input('\nEnter your name: ') if Name in gp: is_New_Name = 'no' Start.start_game(Name, game, check, is_New_Name) else: is_New_Name = 'yes' Start.start_game(Name, game, check, is_New_Name) elif option == 2: Leaderboard.score_board() elif option == 3: print(''' CREDITS PROGRAMMED BY: MR.S DEEPAK (K)ISHORE (P) MR.N.SAFFIUDDIN
def main(): player_wins = 0 dealer_wins = 0 draws = 0 plays = 0 new_deck1, new_dealer1, new_hand1, ace_dealer1, ace_hand1 = Start.start() answer = float(input("How many times do you want to run the simulation? ")) print() done = False while not done: if plays == answer: break if new_hand1 == 21: player_wins += 1 plays += 1 continue new_deck2, new_hand2, ace_hand2, new_dealer2, ace_dealer2 = \ Start.bot(new_deck1, new_hand1, ace_hand1, new_dealer1, ace_dealer1) if new_hand2 == 21: player_wins += 1 plays += 1 continue elif new_hand2 > 21: dealer_wins += 1 plays += 1 continue new_deck3, new_hand3, ace_hand3, new_dealer3, ace_dealer3 = \ dealer_turn(new_deck2, new_hand2, ace_hand2, new_dealer2, ace_dealer2) if new_dealer3 == 21: dealer_wins += 1 plays += 1 continue elif new_dealer3 > 21: player_wins += 1 plays += 1 continue elif new_hand1 == new_dealer1: draws += 1 plays += 1 continue elif new_dealer3 > new_hand3: dealer_wins += 1 plays += 1 continue elif new_dealer3 < new_hand3: player_wins += 1 plays += 1 continue print() print("You ran the simulation", plays, "times") print() print("You won", player_wins, "times") print("The dealer won", dealer_wins, "times") print("There were", draws, "draws") print() print(player_wins + dealer_wins + draws) print()
def __init__(self): self.picker = [] self.choice = [] pygame.init() self.begin = True while self.begin: self.front = Start.Start() if self.front.choice(): self.x = WIDTH / 2 self.y = HEIGHT - 140 self.score = 0 self.box1 = Colors.Colors(50, 20) self.box2 = Colors.Colors(180, 20) self.box3 = Colors.Colors(310, 20) self.box4 = Colors.Colors(440, 20) self.box5 = Colors.Colors(50, 150) self.box6 = Colors.Colors(180, 150) self.box7 = Colors.Colors(310, 150) self.box8 = Colors.Colors(440, 150) self.box9 = Colors.Colors(50, 280) self.box10 = Colors.Colors(180, 280) self.box11 = Colors.Colors(310, 280) self.box12 = Colors.Colors(440, 280) self.box13 = Colors.Colors(50, 410) self.box14 = Colors.Colors(180, 410) self.box15 = Colors.Colors(310, 410) self.box16 = Colors.Colors(440, 410) self.box = [self.box1,self.box2,self.box3,self.box4, \ self.box5,self.box6,self.box7,self.box8, \ self.box9,self.box10,self.box11,self.box12, \ self.box13,self.box14,self.box15,self.box16] self.image = pygame.image.load('app.png').convert_alpha() self.image = pygame.transform.scale(self.image, (100, 100)) self.spritebox = pygame.sprite.Group(self.box) self.display = pygame.display.set_mode((WIDTH, HEIGHT)) self.background = pygame.Surface( self.display.get_size()).convert() for i in self.box: self.background.blit(self.image, (i.x, i.y)) self.font = pygame.font.SysFont('bodoniblack', 50) self.font2 = pygame.font.SysFont('bodoniblack', 20) self.value = self.font.render('Score: ' + str(self.score), True, (0, 0, 255)) self.text = self.font2.render('Click the images', True, (255, 0, 255)) self.text2 = self.font2.render('in the order that', True, (255, 0, 255)) self.text3 = self.font2.render('they change', True, (255, 0, 255)) self.background.blit(self.text, (350, 550)) self.background.blit(self.text2, (350, 580)) self.background.blit(self.text3, (350, 610)) self.num = 4 self.game = True while self.game: for i in range(len(self.picker)): self.picker[i].revert() self.picker = [] self.choice = [] self.game = Controller.game(self) self.num += 1 self.end = End.End(self.score) self.begin = self.end.choice() else: self.begin = False pygame.quit()
def Start(): path = entPath.get() if path == "": return S.Main(path)
#!/usr/local/bin/env python3 # -*-coding:utf-8 -* from Start import * from Main_game_display import * if __name__ == "__main__": startScreen = Start(None) startScreen.title('Quarto') startScreen.mainloop() mode = startScreen.mode player1 = startScreen.name_player1.get() player2 = startScreen.name_player2.get() mainGame = Main_game_display(None, player1, player2, mode) mainGame.title('Quarto') mainGame.mainloop()
ui1.progressBar.setValue(0) info = Handle.get_info() ui1.number.setText(info[0]) ui1.user_name.setText(info[1]) widget1.show() def logout(): widget1.close() ui.clear() widget.show() if __name__ == "__main__": ui = Login.Ui_Form() ui.setupUi(widget) ui1 = Start.Ui_MainWindow() ui1.setupUi(widget1) ui2 = Info.Ui_Dialog() ui2.setupUi(widget2) widget.show() if upgrade(): reply = QtWidgets.QMessageBox.question(None, '更新', '有新版本,是否更新?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.Yes) if reply == QtWidgets.QMessageBox.Yes: webbrowser.open("http://www.parallelc.cn/pj.zip") sys.exit() ui.login.clicked.connect(try_go) ui1.logout.triggered.connect(logout)
import Start as st import Source as s import json import os start = st.Start() start.render() sources = [] print("Write \"help\" in order to view all commands") running = True while (running): command = input('> ').lower() #shows all commands if (command == 'help' or command == 'h'): print("""..:::COMMANDS:::.. add / a : adds a source view / v : shows all keys + title pairs save / s : saves all sources as a JSON file load / l : loads soures from a JSON file quit / q : closes the script""") #adds a source if (command == 'add' or command == 'a'): sources.append(s.Source()) sources[len(sources) - 1].create(sources) #shows all sources if (command == 'view' or command == 'v'):
def main_loop(): pygame.init() pygame.display.set_caption("카레이서 수룡이의 레이싱!") clock = pygame.time.Clock() #게임 사운드 pygame.mixer.music.load('./PyCar/race.wav') sound_crash = pygame.mixer.Sound('./PyCar/crash.wav') sound_engine = pygame.mixer.Sound('./PyCar/engine.wav') #사용자 레이싱 카 생성 player = Car(WINDOW_WIDTH / 2, (WINDOW_HEIGHT - 150), 0, 0) player.load_image() #컴퓨터 레이싱 카 생성 cars = [] score = 0 car_count = 3 for i in range(car_count): x = random.randrange(0, WINDOW_WIDTH - 55) car = Car(x, random.randrange(-150, -50), 0, random.randint(5, 10)) car.load_image() cars.append(car) #도로 차선 생성 lanes = [] lane_width = 10 lane_height = 80 lane_margin = 20 lane_count = 10 lane_x = (WINDOW_WIDTH - lane_width) / 2 lane_y = -10 for i in range(lane_count): lanes.append([lane_x, lane_y]) lane_y += lane_height + lane_margin crash = True game_on = True while game_on: for event in pygame.event.get(): if event.type == pygame.QUIT: game_on = False if crash: if event.type == pygame.KEYDOWN and event.key == pygame.K_0: import Start Start.main_loop() elif event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE: crash = False for i in range(car_count): cars[i].x = random.randrange(0, WINDOW_WIDTH - cars[i].width) cars[i].y = random.randrange(-150, -50) cars[i].load_image() player.load_image() player.x = 175 player.dx = 0 score = 0 pygame.mouse.set_visible(False) sound_engine.play() sleep(3) pygame.mixer.music.play(-1) if not crash: if event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: player.dx = 4 elif event.key == pygame.K_LEFT: player.dx = -4 if event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: player.dx = 0 elif event.key == pygame.K_RIGHT: player.dx = 0 #GRAY로 화면 채우기 screen.fill(GRAY) #게임 화면 출력 if not crash: #도로 차선 이동 for i in range(lane_count): pygame.draw.rect(screen, WHITE, [lanes[i][0], lanes[i][1], lane_width, lane_height]) lanes[i][1] += 10 #도로 차선 속도 if lanes[i][1] > WINDOW_HEIGHT: lanes[i][1] = -40 - lane_height #사용자 레이싱 카 player.draw_image() player.move_x() player.check_out_of_screen() #컴퓨터 레이싱 카 for i in range(car_count): cars[i].draw_image() cars[i].y += cars[i].dy if cars[i].y > WINDOW_HEIGHT: score += 10 cars[i].y = random.randrange(-150, -50) cars[i].x = random.randrange(0, WINDOW_WIDTH-cars[i].width) cars[i].dy = random.randint(4, 9) cars[i].load_image() #레이싱 카 충돌사고 체크 for i in range(car_count): if player.check_crash(cars[i]): crash = True pygame.mixer.music.stop() sound_crash.play() # name 입력하는 부분 root = Tk() # 버튼 클릭 이벤트 핸들러 def okClick(): name = txt.get() try: # DB를 이용해 score 저장 conn = cx_Oracle.connect("shy/[email protected]:1521/shy") cursor = conn.cursor() if len(name)==0: messagebox.showinfo("완료", "이름 없이 저장되었습니다") name = "익명" else: messagebox.showinfo("완료", "저장되었습니다") cursor.execute("insert into ranking(gamecode, name, score) values ('%d', '%s', '%d')" % (2, name[:5], score)) conn.commit() cursor.close() conn.close() except: messagebox.showerror("경고", "인터넷에 연결되어 있지 않아 로컬에만 저장되었습니다.") # 로컬에 등록 try: PyCarRankingList = pickle.load(open("./PyCar/PyCarRanking.pic", "rb")) except: PyCarRankingList = [] tmpList = [] tmpList.append(name) tmpList.append(score) PyCarRankingList.append(tmpList) pickle.dump(PyCarRankingList, open("./PyCar/PyCarRanking.pic", "wb")) root.destroy() root.title('이름 입력') # 타이틀 root.geometry('230x60+190+350') lbl = Label(root, text="이름(최대 5글자)") lbl.grid(row=0, column=0) txt = Entry(root) txt.grid(row=0, column=1) btn = Button(root, text="OK", width=15, command=okClick) btn.grid(row=1, column=1) root.mainloop() # 한글 설정 os.putenv('NLS_LANG', '.UTF8') # pickle을 이용해 파일에 score 저장 #try: # PyCarRankingList = pickle.load(open("./PyCar/PyCarRanking.pic", "rb")) #except: # PyCarRankingList = [] #PyCarRankingList.append(score) #pickle.dump(PyCarRankingList, open("./PyCar/PyCarRanking.pic", "wb")) sleep(1) pygame.mouse.set_visible(True) break draw_score(score) pygame.display.flip() else: draw_main_menu(score) clock.tick(60) pygame.quit()
import Start new_deck1, new_dealer1, new_hand1, ace_dealer1, ace_hand1 = Start.start() Start.bot(new_deck1, new_dealer1, new_hand1, ace_dealer1, ace_hand1)
def getListOfShares(): r = Start.getListOfISINs() result = Response(json.dumps(r),mimetype='application/json') return result
import Start as start import pickle import os if __name__== '__main__': empty = set([]) if os.path.getsize('settings.txt') > 0: with open('settings.txt', 'rb') as settings: load_start = pickle.load(settings) print(load_start.preferred_screen) start.Start.preferred_screen=load_start.preferred_screen if start.Start.preferred_screen == "": start_window = start.Start() with open('settings.txt', 'wb') as settings: # Step 3 pickle.dump(start_window, settings, -1) else: if start.Start.preferred_screen == 'Beginner': if os.path.getsize('novice.txt') > 0: with open('novice.txt', 'rb') as n_s: load_start = pickle.load(n_s) novice = start.NoviceWindow(load_start.listBoxBuffer) else: novice = start.NoviceWindow(empty) elif start.Start.preferred_screen == 'Medium': if os.path.getsize('typical.txt') > 0: with open('typical.txt', 'rb') as n_s: load_start = pickle.load(n_s) typical = start.TypicalWindow(load_start.listBoxBuffer)
import matplotlib.pyplot as plt import Start import Update import Calculate #Declerations------------------------ N = 4 l = 30 itr = 50 alpha= 20.0 #------------------------------------------ U = Start.start(l,N).cold_start() ll = 1 while (ll < itr+1): for s in range(l): for t in range(l): for r in range(2): U = Update.link(r,U,s,t,l,alpha,N) avp = Calculate.avplqt(U,l,N) #avp = Wilson11(U0) print avp
import time import DFS import BFS import ASTAR_MHT import ASTAR_EUC import sys import Start if __name__ == "__main__": print "script_name", sys.argv[0] for i in range(1, len(sys.argv)): print "argument", i, sys.argv[i] print('start initialize') # set the size and density of this matrix size = 10 start = Start.Start(size, 0.3) # start.print_matrix() start.paint_random() # init all the algorithm dfs = DFS.DFS() bfs = BFS.BFS() a_mht = ASTAR_MHT.ASTAR() a_euc = ASTAR_EUC.ASTAR() print('start run') print "DIM, T_DFS, T_BFS, T_MHT, T_EUC" while 1: print size, start = Start.Start(size, 0.3) start.paint_random() while dfs.dfs_route(start.get_matrix(), size)[0] == 0: start.paint_random()
from Start import * from Final import * from Game import * a = Start() a.blank() b = Game() b.window(int(a.start_count), int(a.start_money)) c = Final() name = b.zn[0] money = b.mon_all[4] x = list(zip(name, money)) x.sort(key=lambda f: f[1]) x.reverse() name = [i[0] for i in x] #список имен с капиталом по убыванию money = [i[1] for i in x] #список капиталов по убыванию c.window(name, money, b.mon_all) print(c.mnoey)
def ranking_screen(): pygame.mouse.set_visible(True) start_image = pygame.image.load('ranking.png') screen.blit(start_image, [0, 0]) ################ 우주에서 살아남기 랭킹 ################ # 파일에서 점수 정보 가져오기 draw_text("우주에서 살아남기(Local)", default_font, screen, 120, 150, BLACK) try: PySpaceshipLocalRankingList = pickle.load( open("./PySpaceship/PySpaceshipRanking.pic", "rb")) except: PySpaceshipLocalRankingList = [] PySpaceshipLocalRankingList.sort(key=itemgetter(1), reverse=True) length = len(PySpaceshipLocalRankingList) if length > 4: length = 4 for i in range(0, length): draw_text(str(PySpaceshipLocalRankingList[i][0]), default_font, screen, 90, 180 + (i * 30), BLACK) draw_text(str(PySpaceshipLocalRankingList[i][1]), default_font, screen, 140, 180 + (i * 30), BLACK) # DB에서 점수 정보 가져오기 draw_text("우주에서 살아남기(Online)", default_font, screen, 360, 150, BLACK) try: conn = cx_Oracle.connect( "shy/[email protected]:1521/shy" ) # DB 연결 cursor = conn.cursor() # cursor 가져오기 cursor.execute( "select * from ranking where gamecode = 1 order by score desc" ) # 쿼리 실행 PySpaceshipOnlineRankingList = cursor.fetchall() # 조회 결과를 list에 저장 conn.commit() # commit cursor.close() # cursor 닫기 conn.close() # 연결 close 하기 length = len(PySpaceshipOnlineRankingList) if length > 4: # 최대 4개의 ranking 점수만 가져오기 위해 랭킹 정보가 4개보다 많은 경우 length를 4로 설정 length = 4 for i in range(0, length): # 상위 4개의 점수를 화면에 출력하기 draw_text(str(PySpaceshipOnlineRankingList[i][1]), default_font, screen, 330, 180 + (i * 30), BLACK) draw_text(str(PySpaceshipOnlineRankingList[i][2]), default_font, screen, 390, 180 + (i * 30), BLACK) except: # DB에 연결 시도했는데 실패할 경우 온라인 랭킹에 "인터넷에 연결할 수 없습니다"를 화면에 출력하기 draw_text("인터넷에 연결할 수 없습니다.", default_font, screen, 360, 180, BLACK) #<PyCar 점수> # 파일에서 점수 정보 가져오기 draw_text("수룡이의 레이싱(Local)", default_font, screen, 120, 300, BLACK) try: PyCarLocalRankingList = pickle.load( open("./PyCar/PyCarRanking.pic", "rb")) except: PyCarLocalRankingList = [] PyCarLocalRankingList.sort(key=itemgetter(1), reverse=True) if len(PyCarLocalRankingList) >= 4: for i in range(0, 4): draw_text(str(PyCarLocalRankingList[i][0]), default_font, screen, 90, 330 + (i * 30), BLACK) draw_text(str(PyCarLocalRankingList[i][1]), default_font, screen, 140, 330 + (i * 30), BLACK) else: for i in range(0, len(PyCarLocalRankingList)): draw_text(str(PyCarLocalRankingList[i][0]), default_font, screen, 90, 330 + (i * 30), BLACK) draw_text(str(PyCarLocalRankingList[i][1]), default_font, screen, 140, 330 + (i * 30), BLACK) # DB에서 점수 정보 가져오기 draw_text("수룡이의 레이싱(Online)", default_font, screen, 360, 300, BLACK) try: connection = cx_Oracle.connect( "shy/[email protected]:1521/shy" ) cursor = connection.cursor() cursor.execute( "select * from ranking where gamecode = 2 order by score desc") PyCarOnlineRankingList = cursor.fetchall() connection.commit() cursor.close() connection.close() if len(PyCarOnlineRankingList) >= 4: for i in range(0, 4): draw_text(str(PyCarOnlineRankingList[i][2]), default_font, screen, 390, 330 + (i * 30), BLACK) draw_text(str(PyCarOnlineRankingList[i][1]), default_font, screen, 330, 330 + (i * 30), BLACK) else: for i in range(0, len(PyCarOnlineRankingList)): draw_text(str(PyCarOnlineRankingList[i][2]), default_font, screen, 390, 330 + (i * 30), BLACK) draw_text(str(PyCarOnlineRankingList[i][1]), default_font, screen, 330, 330 + (i * 30), BLACK) except: draw_text("인터넷에 연결할 수 없습니다.", default_font, screen, 360, 330, BLACK) # 3번 게임 랭킹 ************************************************************ # 파일에서 로컬 점수 가져오기 draw_text("학교를 지켜라(Local)", default_font, screen, 120, 450, BLACK) try: PyShootingLocalRankingList = pickle.load( open("./PyShooting/PyShootingRanking.pic", "rb")) # 피클 모듈을 통해 저장된 점수 불러와 리스트에 넣기 except: PyShootingLocalRankingList = [] # 기존에 저장된 점수가 없을 경우 빈 리스트 만들기 PyShootingLocalRankingList.sort( key=itemgetter(1), reverse=True) # 이름/점수로 구성된 2차원 리스트를 점수를 기준으로 내림차순으로 정렬 if len(PyShootingLocalRankingList) >= 4: # 가장 높은 점수 4개 까지만 출력 for i in range(0, 4): draw_text(str(PyShootingLocalRankingList[i][0]), default_font, screen, 90, 480 + (i * 30), BLACK) # 이름 출력 draw_text(str(PyShootingLocalRankingList[i][1]), default_font, screen, 140, 480 + (i * 30), BLACK) # 점수 출력 else: for i in range(0, len(PyShootingLocalRankingList)): draw_text(str(PyShootingLocalRankingList[i][0]), default_font, screen, 90, 480 + (i * 30), BLACK) draw_text(str(PyShootingLocalRankingList[i][1]), default_font, screen, 140, 480 + (i * 30), BLACK) # DB에서 온라인 점수 가져오기 draw_text("학교를 지켜라(Online)", default_font, screen, 360, 450, BLACK) try: conn = cx_Oracle.connect( "shy/[email protected]:1521/shy" ) cursor = conn.cursor() cursor.execute( "select * from ranking where gamecode = 3 order by score desc") PyShootingOnlineRankingList = cursor.fetchall() conn.commit() cursor.close() conn.close() if len(PyShootingOnlineRankingList) >= 4: for i in range(0, 4): draw_text(str(PyShootingOnlineRankingList[i][2]), default_font, screen, 390, 480 + (i * 30), BLACK) draw_text(str(PyShootingOnlineRankingList[i][1]), default_font, screen, 330, 480 + (i * 30), BLACK) else: for i in range(0, len(PyShootingOnlineRankingList)): draw_text(str(PyShootingOnlineRankingList[i][2]), default_font, screen, 390, 480 + (i * 30), BLACK) draw_text(str(PyShootingOnlineRankingList[i][1]), default_font, screen, 330, 480 + (i * 30), BLACK) except: draw_text("인터넷에 연결할 수 없습니다.", default_font, screen, 360, 480, BLACK) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_0: import Start Start.main_loop() return 'ranking_screen' if event.type == QUIT: return 'quit' return 'ranking_screen'
def test_average(self): self.assertEqual(Start.Easy("1Easy.csv"), 1238)
res = astar.find_path(map, len(map)) # return 1, self.path, p.distance, traversal_node_count, fridge if res[0] == 1: cur_cost = res[0] * res[2] else: cur_cost = 0 return cur_cost if __name__ == "__main__": print "script_name", sys.argv[0] for i in range(1, len(sys.argv)): print "argument", i, sys.argv[i] # set the size and density of this matrix size = 10 start = Start.Start(size, 0.35) # start.print_matrix() best = -1 best_res = () hard_map = () for i in range(100): start.paint_random() #start.print_matrix() sa = SA() res_map = sa.sa_init(start.get_matrix(), size, 100, 0.02) astar = ASTAR_MHT.ASTAR() res = astar.find_path(res_map, len(res_map)) if res[0] != 0: if best < res[3]: best = res[3] best_res = res
def start(): print "Pasar a la historia" Start.iniciar()
if self.open.get((node.x, node.y)).distance > node.distance: self.open[(node.x, node.y)] = node continue self.open[(node.x, node.y)] = node if open_size < len(self.open): open_size = len(self.open) return open_size def is_valid(self, x, y): # judge if the new node is out of bound if x < 0 or x >= self.w or y < 0 or y >= self.h: return False #judge if the new node is a block return self.map[x][y] != 1 if __name__ == "__main__": print "script_name", sys.argv[0] for i in range(1, len(sys.argv)): print "argument", i, sys.argv[i] # set the size and density of this matrix size = 100 start = Start.Start(size, 0.2) # start.print_matrix() start.paint_random() # start.print_matrix() astar = ASTAR() astar.find_path(start.get_matrix(), size)
''' Filename: Main.py Date last modified: May 3, 2019 By: Wesley Duerksen ''' import Start run = Start.UI() run.menu()
from Start import * if __name__ == "__main__": Start()
"""server URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('report/', include('report.urls')) ] # Start the sweep application try: import sys sys.path.append("..") import Start Start.main() except ImportError as e: print("Failed to import START: %s" % e)