projectmesa / mesa

Mesa is an open-source Python library for agent-based modeling, ideal for simulating complex systems and exploring emergent behaviors.
https://mesa.readthedocs.io
Apache License 2.0
2.51k stars 879 forks source link

Adding a Text "Output" Box #404

Closed narc98 closed 2 weeks ago

narc98 commented 7 years ago

Your project is a great launching pad for my ABM work. I'm curious if there's a mechanism to add something like a TextData element to the overall server window (for instance, the Wolf/Sheep ModularServer). I have added a few different charts to monitor variables in my model but would like to add another module that simply displays the contents of a dictionary (concept in the attached picture). This behavior either doesn't exist or I can't solve how to add that element to the server (which I presume is probably the case). Thanks for any help anyone can offer.

Nate

textbox

narc98 commented 7 years ago

For clarification purposes, I tried creating a simple "TextData" element and adding it to the call to the ModularServer constructor (throws a "AttributeError: 'TextData' object has no attribute 'package_includes'). I also tried the sample code concept from the docs/modular-visualization.rst file (lines 117-165), but that throws the same error. If I just add the missing variables to the "AttributeElement" class, then the server will open, but a "TypeError: render() takes 1 positional argument but 2 were given" (line 322 from ModularVisualization.py). I can't trace why multiple arguments are being passed there (I have not modified any of the base Mesa code).

dmasad commented 7 years ago

That's definitely a good idea! The documentation on readthedocs was slightly out of date; that's fixed now. Can you post your code on here or in a gist or something? That'll make it easier to see what the issue is.

narc98 commented 7 years ago

https://gist.github.com/narc98/3bd3b0617958047d19ef5a4227818c1e

Sure. I'm working on a model where drones (agents) depart a location and search a given area and report back to a Command/Control agent if they find any objects. My "Operator" class just has some basic movement behaviors (moveToPos(pos), stayCloseToPos(distance), etc..). Each step, I'd like to show what's in the C2.investigate and C2.tracking dictionaries in the main window.

Thanks very much for taking a look, Nate

jackiekazil commented 5 years ago

@dmasad

  1. I am going thru old tickets. Is there something here to update on the docs or no?
  2. Should we create a new ticket for this or retitle this one for the feature add?
quaquel commented 2 weeks ago

this is easy to do with solara and covered in some of the examples on read the docs.

EwoutH commented 2 weeks ago

For example: