Skip to content

Commit

Permalink
F8
Browse files Browse the repository at this point in the history
  • Loading branch information
Corvince committed May 22, 2019
1 parent 2c031af commit 7928330
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
54 changes: 26 additions & 28 deletions examples/shape_example/shape_example/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,32 @@ def agent_draw(agent):
pass
elif isinstance(agent, Walker):
print("Uid: {0}, Heading: {1}".format(agent.unique_id, agent.heading))
portrayal = {"Shape": "arrowHead",
"Filled": "true",
"Layer": 2,
"Color": ["#00FF00", "#99FF99"],
"stroke_color": "#666666",
"Filled": "true",
"heading_x": agent.heading[0],
"heading_y": agent.heading[1],
"text": agent.unique_id,
"text_color": "white",
"scale": 0.8,
}
portrayal = {
"Shape": "arrowHead",
"Filled": "true",
"Layer": 2,
"Color": ["#00FF00", "#99FF99"],
"stroke_color": "#666666",
"Filled": "true",
"heading_x": agent.heading[0],
"heading_y": agent.heading[1],
"text": agent.unique_id,
"text_color": "white",
"scale": 0.8,
}
return portrayal


def launch_shape_model():
width = 15
height = 10
num_agents = 2
pixel_ratio = 50
grid = CanvasGrid(agent_draw, width, height,
width * pixel_ratio, height * pixel_ratio)
server = ModularServer(ShapeExample, [grid], "Shape Model Example",
{"N": num_agents, "width": width, "height": height})
server.max_steps = 0
server.port = 8521
server.launch()


if __name__ == "__main__":
launch_shape_model()
width = 15
height = 10
num_agents = 2
pixel_ratio = 50
grid = CanvasGrid(agent_draw, width, height, width * pixel_ratio, height * pixel_ratio)
server = ModularServer(
ShapeExample,
[grid],
"Shape Model Example",
{"N": num_agents, "width": width, "height": height},
)
server.max_steps = 0
server.port = 8521
7 changes: 4 additions & 3 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ def test_examples(self):
with self.active_example_dir(example):
try:
# model.py at the top level
mod = importlib.import_module('model'.format(example))
server = importlib.import_module('server'.format(example))
mod = importlib.import_module('model')
server = importlib.import_module('server')
server.server.render_model()
except ImportError:
# <example>/model.py
mod = importlib.import_module('{}.model'.format(example.replace('-', '_')))
server = importlib.import_module('{}.server'.format(example.replace('-', '_')))
server.server.render_model()
Model = getattr(mod, classcase(example))
model = Model()
(model.step() for _ in range(100))

1 change: 0 additions & 1 deletion tests/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def move_agent(self):
assert self.space.grid[final_pos[0]][final_pos[1]] == _agent



class TestSingleNetworkGrid(unittest.TestCase):
GRAPH_SIZE = 10

Expand Down

0 comments on commit 7928330

Please sign in to comment.