-
Notifications
You must be signed in to change notification settings - Fork 883
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
Visualization changes #1278
base: main
Are you sure you want to change the base?
Visualization changes #1278
Conversation
…agents position to the specified parameters
…t and the given coordinate and distance function, which gives you the distance between the agent and another agent
… the agent will move. forward function, which moves the agent forward by specified amount. back function, which moves the agent backwards by specified amount. right function, turns the agent right by specified degree. left function, turns the agent left by specified degree.
Thank you for the PR! I have seen @aiwhoo's presentation on your behalf from last month, and has been waiting for this. |
@@ -28,6 +28,7 @@ def __init__(self, unique_id: int, model: "Model") -> None: | |||
self.unique_id = unique_id | |||
self.model = model | |||
self.pos: Optional[Position] = None | |||
self.heading = 90 |
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.
I think we should define a new class for the new attribute and methods, AgentWithHeading
/ AgentWithDirection
/ if you have a better name for it. Because not all models need the feature.
"""Turns the agent left by the given degree""" | ||
self.heading = (self.heading + degree) % 360 | ||
|
||
def setxy(self, x, y): |
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.
What about set_position(self, position)
? This way, the API remains the same in the implementation with higher number of dimensions, instead of e.g. set_xyz
for 3D.
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.
setxy
needs to be removed now that we have set_pos
.
Codecov Report
@@ Coverage Diff @@
## main #1278 +/- ##
==========================================
- Coverage 89.05% 87.18% -1.88%
==========================================
Files 19 19
Lines 1307 1280 -27
Branches 265 244 -21
==========================================
- Hits 1164 1116 -48
- Misses 104 131 +27
+ Partials 39 33 -6
Continue to review full report at Codecov.
|
… Adding background image capabilities to new visualization module SimpleContinousModule.py and added various shapes including rectangle, circle, default, triangle, star, smile, pentagon, arrow, plane, and ant.
@@ -0,0 +1,332 @@ | |||
var ContinuousVisualization = function(height, width, context, background_src=null) { |
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.
Need to use const
/let
instead of var
in all of the var
usage in this file. You case see how to do it in #1246.
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 entire file needs to be formatted with prettier
.
I think this PR is too big, and will take a while to be merged. It is better to make a separate PR that does only the Python part. |
+1 for giving this a new name. From skimming the code this is primarily supposed to be for the continuous space, right? I think the name should be somewhat representative for that (don't know if it also works for grid, but I guess at least not for network) |
We're working on breaking this PR into 2 pull requests: one for the ABM language (e.g. fd, bk, rotate, etc) in agents.py, the other for the visualization improvements (canvas, background images, shapes). The ABM language would be for continous space, while the visualization improvements would be for all spaces. |
@aiwhoo Thanks for the update! |
Check out the reserved fields of hash.ai's hengine for inspiration for the names: https://hash.ai/docs/simulation/creating-simulations/anatomy-of-an-agent/state#Reserved-Fields. // Can be used for custom movement logic. Will affect the agent's visualization
// Suggested values: 0 to 1 for each axis
"direction": [x, y, z],
// Can be used for custom movement logic. Will affect the agent's visualization
// Suggested values: 0 to 1 for each axis
"velocity": [x, y, z], They most likely also have methods associated with those attributes. It's good to check their naming choice. |
For context, hash.ai's hEngine is a performant ABM library written in Rust, with interfaces to Javascript, Python, and other languages. |
Should we close this in lieu of two PRs or will this be one of the PRs? |
Implemented additional core agent functionalities including adding a heading for rotational movements (forward, backwards, right, left, setxy). As well as, removal from scheduler and grid (die)