def __init__(self, agent, dirt_bias, dirt_distribution, wall_bias, world_seed): self.env = LIUVacuumEnvironment(env_x=20, env_y=20, dirt_bias=dirt_bias, dirt_distribution=dirt_distribution, wall_bias=wall_bias, world_seed=world_seed) self.agent = agent self.env.add_thing(self.agent)
def create_sim(self): """ Create environment and agent and add agent to environment """ venv = LIUVacuumEnvironment(*self.grid_dims_getter(), self.dirt_bias_getter(), self.wall_bias_getter(), self.seed_getter()) selected_agent = self.agent_getter() if selected_agent == AGENT_MYVACUUMAGENT: agent = MyVacuumAgent(*self.grid_dims_getter(), self.append_log) elif selected_agent == AGENT_RANDOM: agent = RandomVacuumAgent(*self.grid_dims_getter(), self.append_log) else: agent = ReactiveVacuumAgent(*self.grid_dims_getter(), self.append_log) venv.add_thing(agent) self.agent = agent self.vacuum_env = venv
def create_sim(self): """ Create environment and agent and add agent to environment """ venv = LIUVacuumEnvironment(*self.grid_dims_getter(), self.dirt_bias_getter(), self.dirt_distribution_getter(), self.wall_bias_getter(), self.seed_getter()) selected_agent = self.agent_getter() agents = [V1Agent(*self.grid_dims_getter(), self.append_log), V2Agent(*self.grid_dims_getter(), self.append_log), V3Agent(*self.grid_dims_getter(), self.append_log), V4Agent(*self.grid_dims_getter(), self.append_log), V5Agent(*self.grid_dims_getter(), self.append_log), V6Agent(*self.grid_dims_getter(), self.append_log) ] agent = agents[selected_agent] venv.add_thing(agent) self.agent = agent self.vacuum_env = venv
class VacuumSimulation: def __init__(self, agent, dirt_bias, dirt_distribution, wall_bias, world_seed): self.env = LIUVacuumEnvironment(env_x=20, env_y=20, dirt_bias=dirt_bias, dirt_distribution=dirt_distribution, wall_bias=wall_bias, world_seed=world_seed) self.agent = agent self.env.add_thing(self.agent) def step(self): self.env.step() def run(self): while True: self.step() if self.agent.last_action == ACTION_NOP: return def score(self): return self.agent.score()