Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move_agent_to_one_of is deterministic when pos has multiple closest choices and selection="closest" #2117

Closed
OrenBochman opened this issue Apr 23, 2024 · 0 comments · Fixed by #2119 or #2118
Labels
bug Release notes label

Comments

@OrenBochman
Copy link
Contributor

OrenBochman commented Apr 23, 2024

Describe the bug

move_agent_to_one_of is deterministic when pos has multiple closest choices and selection="closest"

Expected behavior

expected that when using move_agent_to_one_of() in a sugarscape agent's motion will be random within a sugar plateau for low vision agents, but noticed that such agents now exhibit periodic motion.

To Reproduce

use the following test

def test_move_agent_closest_selection_multiple(self):
    random_locations = []
    agent = self.agents[0]
    agent.pos = (5, 5)
    repetititions = 10

    for _ in range(repetititions):
        possible_positions = [(4, 4), (6, 6), (10, 10), (20, 20)]
        self.space.move_agent_to_one_of(
            agent, possible_positions, selection="closest"
        )
        random_locations.append(agent.pos)
        assert agent.pos in possible_positions
        self.space.move_agent_to_one_of(agent, [(5, 5)], selection="closest")
    non_random_locations = [random_locations[0]] * repetititions
    assert random_locations != non_random_locations

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Release notes label
Projects
None yet
2 participants