MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / game_logic

Function game_logic

example_code/item_071.py:132–141  ·  view source on GitHub ↗
(state, neighbors)

Source from the content-addressed store, hash-verified

130
131print("Example 5")
132def game_logic(state, neighbors):
133 if state == ALIVE:
134 if neighbors < 2:
135 return EMPTY # Die: Too few
136 elif neighbors > 3:
137 return EMPTY # Die: Too many
138 else:
139 if neighbors == 3:
140 return ALIVE # Regenerate
141 return state
142
143assert game_logic(ALIVE, 0) == EMPTY
144assert game_logic(ALIVE, 1) == EMPTY

Callers 2

item_071.pyFile · 0.70
step_cellFunction · 0.70

Calls 1

recvMethod · 0.80

Tested by

no test coverage detected