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

Visualization changes #1278

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

GaelLucero
Copy link

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)

aiwhoo and others added 8 commits April 5, 2022 15:29
…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.
… handling in regards to code reviews for commits: 6a939f5 and ed6921f
@rht
Copy link
Contributor

rht commented Apr 13, 2022

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
Copy link
Contributor

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.

mesa/agent.py Outdated Show resolved Hide resolved
mesa/agent.py Outdated Show resolved Hide resolved
"""Turns the agent left by the given degree"""
self.heading = (self.heading + degree) % 360

def setxy(self, x, y):
Copy link
Contributor

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.

Copy link
Contributor

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.

mesa/agent.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 14, 2022

Codecov Report

Merging #1278 (0858679) into main (04aca59) will decrease coverage by 1.87%.
The diff coverage is 31.91%.

❗ Current head 0858679 differs from pull request most recent head 8a2b3fe. Consider uploading reports for the commit 8a2b3fe to get more accurate results

@@            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     
Impacted Files Coverage Δ
mesa/agent.py 43.75% <31.91%> (-32.73%) ⬇️
mesa/visualization/ModularVisualization.py 75.80% <0.00%> (+0.19%) ⬆️
mesa/batchrunner.py 93.72% <0.00%> (+1.44%) ⬆️
mesa/visualization/modules/NetworkVisualization.py 100.00% <0.00%> (+13.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04aca59...8a2b3fe. Read the comment docs.

… 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) {
Copy link
Contributor

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.

Copy link
Contributor

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.

@rht
Copy link
Contributor

rht commented Apr 16, 2022

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.

@Corvince
Copy link
Contributor

+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)

@aiwhoo
Copy link

aiwhoo commented May 25, 2022

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.

@tpike3
Copy link
Member

tpike3 commented May 25, 2022

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!

@rht
Copy link
Contributor

rht commented May 25, 2022

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.

@rht
Copy link
Contributor

rht commented May 25, 2022

For context, hash.ai's hEngine is a performant ABM library written in Rust, with interfaces to Javascript, Python, and other languages.

@jackiekazil
Copy link
Member

Should we close this in lieu of two PRs or will this be one of the PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants