Skip to content

Instantly share code, notes, and snippets.

@fedden
Created October 27, 2017 15:17
Show Gist options
  • Select an option

  • Save fedden/03e4be43b62991c1fe26447f19403f6b to your computer and use it in GitHub Desktop.

Select an option

Save fedden/03e4be43b62991c1fe26447f19403f6b to your computer and use it in GitHub Desktop.
diffusion
for (auto& agent : unhappy_agents)
{
if (happy_agents.size() > 0)
{
size_t random_index = uniform_random.get_next(agent_size - 1);
if (agents[random_index]->happy)
{
set_agent_randomly_in_same_quadrant(agents[random_index],
agent,
agents,
partial_grid,
partial_size,
grid_size,
uniform_random);
}
else
{
agent->x = uniform_random.get_next(grid_size - 1);
agent->y = uniform_random.get_next(grid_size - 1);
}
}
else
{
agent->x = uniform_random.get_next(grid_size - 1);
agent->y = uniform_random.get_next(grid_size - 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment