def init_node_type_test(self): """Puts Test in known state for Node type tests.""" self.clear_test_state() player1 = Individual() player2 = Individual() testee = player1.get_robot() testee.location = constants.testee_loc ally = player1.get_robot() ally.location = constants.ally_loc enemy = player2.get_robot() enemy.location = constants.enemy_loc enemy.player_id = 1 self.robots = [testee, ally, enemy] for bot in self.robots: self.gamestate.add_robot(bot.location, bot.player_id) # I use the default 'guard' action to determine when a rule evaluates # False, so the test rule must not be the guard rule while testee.eval_order[0].action == 'guard': random.shuffle(testee.eval_order) testee.eval_order[0].insert_random_parent()
def init_children_test(self, num_children): self.clear_test_state() player1 = Individual() testee = player1.get_robot() testee.location = constants.testee_loc self.robots = [testee] self.gamestate.add_robot(testee.location, testee.player_id) # Force the prime rule to be the move rule so direction is returned while testee.eval_order[0].action != 'move': random.shuffle(testee.eval_order) rule = self.robots[0].eval_order[0] rule.insert_random_parent() for x in range(num_children): self.insert_random_root_child(rule)