Returns a dictionary for a new forest data structure.
()
| 76 | |
| 77 | |
| 78 | def 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 | |
| 90 | def displayForest(forest): |