Giter Site home page Giter Site logo

Comments (7)

jwaa avatar jwaa commented on August 14, 2024

Hey @rsverhagen94! Adjusting visualization properties on the fly can indeed be a hassle. Can you provide a bit of a code snippet on what you tried with the self.agent_properties attribute? Also include where you make the adjustments (i.e., in the decide_on_action method).

from matrx.

rsverhagen94 avatar rsverhagen94 commented on August 14, 2024

@jwaa thanks for the quick reply! I tried the following code in the decide_on_action method of the agent class:
self.agent_properties["visualization"]["size"] = 5.0. When printing self.agent_properties it actually shows the changed size, but no differences are visually noticeable in the simulation.

from matrx.

jwaa avatar jwaa commented on August 14, 2024

Now a bit later reply, sorry for that. It seems that changing the visualization properties is a bit of as hassle since an update. Could you try this:

self.agent_properties["visualize_size"] = 5.0

All of the visualization properties are in their nested dictionaries, but the part that modifies it throughout MATRX cannot handle such nested properties. So the solution MATRX now uses is to translate all of them to "visualization_<property name>".

Let me know if this works!

from matrx.

rsverhagen94 avatar rsverhagen94 commented on August 14, 2024

Now a bit later reply, sorry for that. It seems that changing the visualization properties is a bit of as hassle since an update. Could you try this:

self.agent_properties["visualize_size"] = 5.0

All of the visualization properties are in their nested dictionaries, but the part that modifies it throughout MATRX cannot handle such nested properties. So the solution MATRX now uses is to translate all of them to "visualization_<property name>".

Let me know if this works!

This returns the following error:

Traceback (most recent call last):
  File "main.py", line 51, in <module>
    carry_together_case.run(scenario)
  File "/home/ruben/Downloads/moving_out/case/carry_together_case.py", line 196, in run
    world.run(builder.api_info)
  File "/home/ruben/.local/lib/python3.8/site-packages/matrx/grid_world.py", line 246, in run
    is_done, tick_duration = self.__step()
  File "/home/ruben/.local/lib/python3.8/site-packages/matrx/grid_world.py", line 697, in __step
    agent_obj._set_agent_changed_properties(agent_properties)
  File "/home/ruben/.local/lib/python3.8/site-packages/matrx/objects/agent_body.py", line 237, in _set_agent_changed_properties
    raise Exception(f"Agent {self.obj_id} tried to remove the property {prop}, which is not allowed.")
Exception: Agent robot tried to remove the property visualize_size, which is not allowed.

When adding the agent using builder.add_agent, I included visualize_size in customizable_properties. I am using MATRX version 2.2.0 btw.

from matrx.

jwaa avatar jwaa commented on August 14, 2024

This returns the following error:

Ah, that is too bad. It seems there is a bug there. A workaround is to add the visualize_size property when you make the agent with the WorldBuilder with the original size as value. No guarantees that this will work though. I made #330 to fix it and with a more detailed description why it fails.

When adding the agent using builder.add_agent, I included visualize_size in customizable_properties. I am using MATRX version 2.2.0 btw.

Also good to know. The past few hotfixes did altered the property mechanism, so it might be worthwhile to upgrade and test it with a newer version.

from matrx.

jwaa avatar jwaa commented on August 14, 2024

@rsverhagen94 I wrote a solution for MATRX here, although it is a hacky one you could try and see if it fixes it for you. Alternatively, you can wait until we implemented a hotfix and update your MATRX version.

As a side note; size needs to be an integer as it is a multitude of a grid square :)

from matrx.

rsverhagen94 avatar rsverhagen94 commented on August 14, 2024

@rsverhagen94 I wrote a solution for MATRX here, although it is a hacky one you could try and see if it fixes it for you. Alternatively, you can wait until we implemented a hotfix and update your MATRX version.

As a side note; size needs to be an integer as it is a multitude of a grid square :)

This indeed works! Thanks a lot @jwaa :-)

from matrx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.