class Game(): def __init__(self): pygame.init() self.surface = pygame.display.set_mode( (world.SCREENWIDTH, world.SCREENHEIGHT)) pygame.display.set_caption(TITLE) self.surface.fill(world.UGLY_PINK) self.world_map = Map(MAPFILE, self) def _get_decision(self): d = ['above', 'below', 'right', 'left'] ran = randint(0, 3) return d[ran] def next_turn(self): # --------- Read patterns ------------- # read tiles from left to right, top to bottom. self.world_map.examine_world() # -------- decision ----------------- self.world_map.decide() def draw(self): self.world_map.draw() def game_loop(self): print("===== BEGIN WHILE LOOP ========") while True: # print("begin while loop") for event in pygame.event.get(): # print("inside pygame.event.get()") if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: print("inside pygame.KEYDOWN") if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit() if event.key == pygame.K_t: print("before next turn") mygame.next_turn() print("after next turn") mygame.next_turn() mygame.draw() pygame.display.update() time.sleep(1) print("===== END WHILE LOOP ========")
self.step_count += 1 if self.advance_by( self.speed, noisy=False, checker=lambda r, dx, dy: not maze.segment_is_intersecting_walls( r.x, r.y, r.x+dx, r.y+dy)): break # Bumped into something or too long in same direction, # chose random new direction # print('self.chose_random_direction()') self.chose_random_direction() # ------------------------------------------------------------------------ world = Map('dfki-2nd-floor.json') world.draw() db = Database() all_loc_docs = db.view_result("all_location_documents_from_reckonme/") all_loc_docs = all_loc_docs[['2014-02-26']:] reckonme_location_data = {} for row in all_loc_docs: data = {k: v for k, v in db[row.id].iteritems()} if row.key[1] not in reckonme_location_data: reckonme_location_data[row.key[1]] = [data] else: reckonme_location_data[row.key[1]].append(data)