1
0
mirror of https://github.com/gsi-upm/soil synced 2025-07-03 19:52:21 +00:00
soil/soil/agents/DrawingAgent.py
J. Fernando Sánchez e1be3a730e WIP soil
* Pandas integration
* Improved environment
* Logging and data dumps
* Tests
* Added Finite State Machine models
* Rewritten ipython notebook and documentation
2017-07-03 18:17:52 +02:00

19 lines
493 B
Python

from . import BaseAgent
import os.path
import matplotlib
import matplotlib.pyplot as plt
import networkx as nx
class DrawingAgent(BaseAgent):
"""
Agent that draws the state of the network.
"""
def step(self):
# Outside effects
f = plt.figure()
nx.draw(self.env.G, node_size=10, width=0.2, pos=nx.spring_layout(self.env.G, scale=100), ax=f.add_subplot(111))
f.savefig(os.path.join(self.env.sim().dir_path, "graph-"+str(self.env.now)+".png"))