def __init__(self): pygame.init() screen = pygame.display.set_mode((Map_width, Map_length), pygame.RESIZABLE, 32) surface = pygame.Surface(screen.get_size()) surface = surface.convert() user_response = "worldmap" GUIshop = ShopGUI.Shop(surface, screen) GUIworld = worldmap.WorldMap(surface, screen) GUIprep = battleprep.BattlePrep(surface, screen) GUIbattle1 = battle.BattleMap(surface, screen, 0) GUIbattle2 = battle2.BattleMap(surface, screen, 1) while True: if user_response == "shop": user_response = GUIshop.run() if user_response == "worldmap": user_response = GUIworld.run() if isinstance(user_response, int): chapter = user_response user_response = GUIprep.run() if user_response == "battle": if chapter == 0: user_response = GUIbattle1.run() if chapter == 1: user_response = GUIbattle2.run() pygame.quit() sys.exit()
def pygame_main_loop(): pygame.init() DISPLAYSURF = pygame.display.set_mode((400, 300)) herp = worldmap.WorldMap() derp = worldmap.Tile() herp.add_tile(derp) pygame.display.set_caption('Hello World!') while True: # main game loop for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() derp.draw(DISPLAYSURF) pygame.display.update()
print("Hurricane ID " + key + " overall error per prediction is " + str(totalError / predictionsMade)) totalPredictionsMade += predictionsMade aggregateErrors.append(totalError / predictionsMade) #Average out errors across all hurricanes overallError = sum(aggregateErrors) / len( aggregateErrors) / config.FUTURE_VISION print("Overall error per prediction averaged across " + str(len(aggregateErrors)) + " hurricanes and " + str(totalPredictionsMade) + " predictions: " + str(overallError)) return overallError #Initialize world map worldmap = worldmap.WorldMap() #Prepare data all_fn = "./data/atlantic.csv" train_fn = "./train.csv" valid_fn = "./validate.csv" test_fn = "./test.csv" all_df = processCSVFile(all_fn) train_df = processCSVFile(train_fn) valid_df = processCSVFile(valid_fn) test_df = processCSVFile(test_fn) #Which data for the baseline to run on #baseline(worldmap, train_df.getHurricaneLatAndLong()) baseline(worldmap, valid_df.getHurricaneLatAndLong())
def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title) # Splitters and Panels self.controls_map_splitter = wx.SplitterWindow(self) self.controls_map_splitter.SetMinimumPaneSize(300) controls_panel = wx.Panel(self.controls_map_splitter) map_panel = wx.Panel(self.controls_map_splitter) self.graphs_messages_splitter = wx.SplitterWindow(controls_panel) self.graphs_messages_splitter.SetMinimumPaneSize(50) graphs_panel = wx.Panel(self.graphs_messages_splitter) messages_panel = wx.Panel(self.graphs_messages_splitter) # World graphic self._graphics = worldmap.WorldMap(map_panel) self.graphics_sizer = wx.BoxSizer(wx.VERTICAL) self.graphics_sizer.Add(self._graphics, 1, wx.EXPAND) map_panel.SetSizerAndFit(self.graphics_sizer) # Controls panel self.controls = Controls(controls_panel, (300, 250), self) # Info panel self.info = Info(controls_panel, (300, 250)) # Graph canvas self.graphs = graphs.Graphs(graphs_panel, (300, 300)) # Messages panel self.messages = Messages(messages_panel, (600, 200)) self.interface_sizer = wx.BoxSizer(wx.VERTICAL) self.controls_info_sizer = wx.BoxSizer(wx.HORIZONTAL) self.controls_info_sizer.Add(self.info, 0, wx.EXPAND) self.controls_info_sizer.Add((20, -1), proportion=0) # Padding self.controls_info_sizer.Add(self.controls, 1, wx.EXPAND) self.messages_sizer = wx.BoxSizer(wx.VERTICAL) self.messages_sizer.Add(self.messages, 1, wx.EXPAND) messages_panel.SetSizerAndFit(self.messages_sizer) self.graphs_sizer = wx.BoxSizer(wx.VERTICAL) self.graphs_sizer.Add(self.graphs, 1, wx.EXPAND) graphs_panel.SetSizerAndFit(self.graphs_sizer) self.interface_sizer.Add(self.controls_info_sizer, 0, wx.EXPAND) self.interface_sizer.Add(self.graphs_messages_splitter, 1, wx.EXPAND) controls_panel.SetSizerAndFit(self.interface_sizer) self.graphs_messages_splitter.SplitHorizontally( messages_panel, graphs_panel) self.controls_map_splitter.SplitVertically(controls_panel, map_panel) # Set up event handler for any worker thread results EVT_RESULT(self, self.OnResult) EVT_STOP(self, self.OnStop) # Set up close event so timer is properly stopped wx.EVT_CLOSE(self, self.OnClose) self.reset_gui() self.Show()
def start_game(self): worldmap.WorldMap().loop()