def __init__(self): super().__init__() self.order = -1 self.decision = decision.RandomSingleCastDecision() self.actions["pre_step"] = pre_step
def test_invalid_type(): from adjsim import core, analysis, utility, decision action = True agent = core.Agent() agent.decision = decision.RandomSingleCastDecision() with pytest.raises(utility.ActionException): agent.actions["trivial"] = action
def __init__(self, pos): super().__init__() self.pos = pos self.calories = random.randint(5, 35) self.color = color.PINK self.size = 5 self.decision = decision.RandomSingleCastDecision() self.actions["wait"] = wait
def __init__(self, x, y, is_it): super().__init__() self.is_it = is_it self.color = color.RED_DARK if is_it else color.BLUE_DARK self.pos = np.array([x, y]) self.decision = decision.RandomSingleCastDecision() self.actions["move"] = move self.actions["tag"] = tag if is_it: self.order = 1
def test_trivial(): from adjsim import core, analysis, utility, decision action = lambda env, source: 0 agent = core.Agent() agent.decision = decision.RandomSingleCastDecision() agent.actions["trivial"] = action test_sim = core.Simulation() test_sim.agents.add(agent) common.step_simulate_interpolation(test_sim)
def test_invalid_too_many_arguments(): from adjsim import core, analysis, utility, decision action = lambda env, source, kek: 0 agent = core.Agent() agent.decision = decision.RandomSingleCastDecision() agent.actions["trivial"] = action test_sim = core.Simulation() test_sim.agents.add(agent) with pytest.raises(utility.DecisionException): common.step_simulate_interpolation(test_sim)
def test_timestep_count(): from adjsim import core, analysis, decision def increment_action(env, source): source.count += 1 class TestAgent(core.Agent): def __init__(self): super().__init__() self.actions["increment"] = increment_action self.count = 0 agent = TestAgent() agent.decision = decision.RandomSingleCastDecision() test_sim = core.Simulation() test_sim.agents.add(agent) common.step_simulate_interpolation(test_sim) assert agent.count == common.INTERPOLATION_NUM_TIMESTEP
def __init__(self): self.order = 1 self.decision = decision.RandomSingleCastDecision() self.actions["starve"] = starve
def __init__(self): super().__init__() self.actions["compute"] = compute self.decision = decision.RandomSingleCastDecision()
def __init__(self): super().__init__() self.decision = decision.RandomSingleCastDecision()
def __init__(self): super().__init__() self.actions["increment"] = increment_agents self.decision = decision.RandomSingleCastDecision()
def __init__(self): super().__init__() self.actions["gravity"] = gravity self.decision = decision.RandomSingleCastDecision()
def __init__(self, x, y): super().__init__(pos=np.array([x, y])) self.decision = decision.RandomSingleCastDecision() self.actions["change"] = change
def __init__(self): super().__init__() self.actions["shuffle"] = shuffle self.order = 10 self.decision = decision.RandomSingleCastDecision()
def __init__(self, order): super().__init__() self.actions["log"] = log self.order = order self.index = order self.decision = decision.RandomSingleCastDecision()
def __init__(self, pos): super().__init__(pos=pos) self.decision = decision.RandomSingleCastDecision() self.actions["move"] = move