def successor(status): actions = list(Action) shuffle(actions) children = [] for action in actions: next_status = simulate(status, action) children.append((next_status, action)) return children
def successor(status): children = [] if status.turn >= turn_limit: return children actions = list(Action) shuffle(actions) for action in actions: next_status = simulate(status, action) children.append((next_status, action)) return children
def perform_test(self, status_dict): """Test that simulate returns a new object""" # Build models map_obj = Map(status_dict["game"]["board"]["tiles"]) status = Status(status_dict["game"], map_obj) original_status = status.clone() next_status = simulate(status, Action.north) if original_status != next_status: self.assertNotEqual(id(status), id(next_status))
def perform_test(self, status_dict): """Test that simulate returns a new object""" # Build models map_obj = Map(status_dict["game"]["board"]["tiles"]) status = Status(status_dict["game"], map_obj) # Simulate the last turn status.turn = status.max_turns next_status = simulate(status, Action.north) self.assertEqual(status, next_status)
game_maps = {} for status_dict in get_status_samples(): game_id = status_dict["game"]["id"] if game_id not in game_maps: game_maps[game_id] = Map(status_dict["game"]["board"]["tiles"]) status = Status(status_dict["game"], game_maps[game_id]) samples_status.append(status) # # 1. Measure simulation speed # print("(*) Client simulation speed") t = Timer( lambda: simulate( # a random state random.choice(samples_status), # a random action random.choice(list(Action)) ) ) measurements = t.repeat(repeat=5000, number=1) print(report(measurements)) # # 2. Measure Bot speed # bots = [ (bots.RandomBot, None), (bots.SimpleGoalBot, None), (bots.MaxnBot, heuristics.GoldHeuristic), (bots.MaxnBot, heuristics.EloGoldHeuristic), (bots.MaxnBot, heuristics.MineGoldHeuristic),