MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / createNewForest

Function createNewForest

src/gamesbyexample/forestfiresim.py:78–87  ·  view source on GitHub ↗

Returns a dictionary for a new forest data structure.

()

Source from the content-addressed store, hash-verified

76
77
78def createNewForest():
79 """Returns a dictionary for a new forest data structure."""
80 forest = {'width': WIDTH, 'height': HEIGHT}
81 for x in range(WIDTH):
82 for y in range(HEIGHT):
83 if (random.random() * 100) <= INITIAL_TREE_DENSITY:
84 forest[(x, y)] = TREE # Start as a tree.
85 else:
86 forest[(x, y)] = EMPTY # Start as an empty space.
87 return forest
88
89
90def displayForest(forest):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected