Skip to content

Commit

Permalink
make pd_grid and hex_snowflake standards-compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed May 14, 2018
1 parent c34aa95 commit 86d6cfa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/hex_snowflake/hex_snowflake/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HexSnowflake(Model):
Represents the hex grid of cells. The grid is represented by a 2-dimensional array of cells with adjacency rules specific to hexagons.
'''

def __init__(self, height, width):
def __init__(self, height=50, width=50):
'''
Create a new playing area of (height, width) cells.
'''
Expand Down
4 changes: 2 additions & 2 deletions examples/pd_grid/pd_grid/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .agent import PDAgent


class PDModel(Model):
class PdGrid(Model):
''' Model class for iterated, spatial prisoner's dilemma model. '''

schedule_types = {"Sequential": BaseScheduler,
Expand All @@ -21,7 +21,7 @@ class PDModel(Model):
("D", "C"): 1.6,
("D", "D"): 0}

def __init__(self, height, width, schedule_type, payoffs=None):
def __init__(self, height=50, width=50, schedule_type="Random", payoffs=None):
'''
Create a new Spatial Prisoners' Dilemma Model.
Expand Down
6 changes: 3 additions & 3 deletions examples/pd_grid/pd_grid/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mesa.visualization.UserParam import UserSettableParameter

from .portrayal import portrayPDAgent
from .model import PDModel
from .model import PdGrid


# Make a world that is 50x50, on a 500x500 display.
Expand All @@ -13,8 +13,8 @@
"height": 50,
"width": 50,
"schedule_type": UserSettableParameter("choice", "Scheduler type", value="Random",
choices=list(PDModel.schedule_types.keys()))
choices=list(PdGrid.schedule_types.keys()))
}

server = ModularServer(PDModel, [canvas_element], "Prisoner's Dilemma",
server = ModularServer(PdGrid, [canvas_element], "Prisoner's Dilemma",
model_params)
12 changes: 0 additions & 12 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ def test_examples(self):
model = Model()
(model.step() for _ in range(100))

def test_hex_snowflake(self):
with self.active_example_dir('hex_snowflake'):
from hex_snowflake.model import HexSnowflake
model = HexSnowflake(100, 100)
(model.step() for _ in range(100))

def test_pd_grid(self):
with self.active_example_dir('pd_grid'):
from pd_grid.model import PDModel
model = PDModel(100, 100, "Random")
(model.step() for _ in range(100))

def test_shape_example(self):
with self.active_example_dir('shape_example'):
from shape_model.model import ShapesModel
Expand Down

0 comments on commit 86d6cfa

Please sign in to comment.