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 __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
from Start import * if __name__ == "__main__": Start()
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)
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()
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
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')
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)
## By Dibakar Sigdel Collection: Python-25-06-02 # ########################################################################## import matplotlib.pyplot as plt import Start import Update import Calculate #Declerations------------------------ N = 3 l = 30 itr = 10 alpha = 10.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.update(U, l, N).link(r, s, t, alpha) avp = Calculate.Calculate(U, l, N).avplqt() #avp = Wilson11(U0) print avp plt.figure(1) plt.scatter(ll, avp)
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 __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()
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)