-
Notifications
You must be signed in to change notification settings - Fork 165
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
Improve boid flocker model and documentation #101
Conversation
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
@@ -5,19 +5,56 @@ | |||
|
|||
|
|||
def boid_draw(agent): | |||
return {"Shape": "circle", "r": 2, "Filled": "true", "Color": "Red"} | |||
neighbors = agent.model.space.get_neighbors(agent.pos, agent.vision, False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This operation is very expensive for all agents, for each step. At which number of agents did you notice any performance degradation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing I set 20 FPS. It is fine until 200 agents (which I set as upper limit). After this it slows down kinda linearly until 500, after which it is unbearably slow.
To make the colour process faster I can add the colour logic in the agent class itself. This would make it faster since we anyways need to search neighbourhood there. I can make the change as per your recommendation.
Except for the |
Get the Boid's neighbors, compute the new vector, and move accordingly. | ||
""" | ||
|
||
neighbors = self.model.space.get_neighbors(self.pos, self.vision, False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we make this self.neighbors
we can also use if for the visualisation right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that would work fine, but it could take too much memory with many agents. If the only need is to change colour, I think it would be more convenient to make a self.colour variable instead.
Edit: It will work but there will be a small issue. The visualization will always be one frame behind the model, this is because the neighbourhood will change after the movement but the neighbours
variable will remain the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could save the neighbours of the previous step.
I think in many systems that compute will be more of an bottleneck than memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model can now smoothly handle around 600 agents after which it slows down. After 1000 it is too slow and not practical
That's useful info to take a note on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First it was around 200 right? If so, that's a great improvement! Thanks!
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Merged, thank you. |
I have made the following changes:
NOTE: I also tried to work on #86 for adding better visualization but I was facing some issues.