Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed Nov 21, 2021
1 parent 05ffd73 commit 0b2c8db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
!model_graphs/.gitkeep
!batch_graphs/.gitkeep

.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
22 changes: 11 additions & 11 deletions fire_evacuation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ def __init__(
for (x, y), value in np.ndenumerate(floorplan):
value = str(value)
floor_object = None
if value is "W":
if value == "W":
floor_object = Wall((x, y), self)
elif value is "E":
elif value == "E":
floor_object = FireExit((x, y), self)
self.fire_exit_list.append((x, y))
self.door_list.append(
(x, y)
) # Add fire exits to doors as well, since, well, they are
elif value is "F":
elif value == "F":
floor_object = Furniture((x, y), self)
self.furniture_list.append((x, y))
elif value is "D":
elif value == "D":
floor_object = Door((x, y), self)
self.door_list.append((x, y))
elif value is "S":
elif value == "S":
self.spawn_list.append((x, y))

if floor_object:
Expand Down Expand Up @@ -317,9 +317,9 @@ def count_human_status(model, status):
"""
count = 0
for agent in model.schedule.agents:
if isinstance(agent, Human):
if agent.get_status() == status:
count += 1
if isinstance(agent, Human) and agent.get_status() == status:
count += 1

return count

@staticmethod
Expand All @@ -329,7 +329,7 @@ def count_human_mobility(model, mobility):
"""
count = 0
for agent in model.schedule.agents:
if isinstance(agent, Human):
if agent.get_mobility() == mobility:
count += 1
if isinstance(agent, Human) and agent.get_mobility() == mobility:
count += 1

return count

0 comments on commit 0b2c8db

Please sign in to comment.