Exemplo n.º 1
0
    def __init__(self):
        super().__init__()

        self.order = -1

        self.decision = decision.RandomSingleCastDecision()

        self.actions["pre_step"] = pre_step
Exemplo n.º 2
0
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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
    def __init__(self):
        self.order = 1

        self.decision = decision.RandomSingleCastDecision()

        self.actions["starve"] = starve
Exemplo n.º 9
0
    def __init__(self):
        super().__init__()

        self.actions["compute"] = compute
        self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 10
0
 def __init__(self):
     super().__init__()
     self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 11
0
 def __init__(self):
     super().__init__()
     self.actions["increment"] = increment_agents
     self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 12
0
 def __init__(self):
     super().__init__()
     self.actions["gravity"] = gravity
     self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 13
0
 def __init__(self, x, y):
     super().__init__(pos=np.array([x, y]))
     self.decision = decision.RandomSingleCastDecision()
     self.actions["change"] = change
Exemplo n.º 14
0
 def __init__(self):
     super().__init__()
     self.actions["shuffle"] = shuffle
     self.order = 10
     self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 15
0
 def __init__(self, order):
     super().__init__()
     self.actions["log"] = log
     self.order = order
     self.index = order
     self.decision = decision.RandomSingleCastDecision()
Exemplo n.º 16
0
 def __init__(self, pos):
     super().__init__(pos=pos)
     self.decision = decision.RandomSingleCastDecision()
     self.actions["move"] = move