fire spreads to neighboring trees if forest get(( ixy iy)=tree nextforest[( ixy iy)fire the tree has burned down nowso erase it nextforest[(xy)empty else just copy the existing object nextforest[(xy)forest[(xy) forest nextforest time sleep(pause_length def createnewforest() """returns dictionary for new forest data structure "" forest {'width'width'height'height for in range(width) for in range(height) if (random random( <initial_tree_density forest[(xy)tree start as tree else forest[(xy)empty start as an empty space return forest def displayforest(forest) """display the forest data structure on the screen "" bext goto( for in range(forest['height']) for in range(forest['width']) if forest[(xy)=tree bext fg('green' print(treeend='' elif forest[(xy)=fire bext fg('red' print(fireend='' elif forest[(xy)=empty print(emptyend='' print( bext fg('reset'use the default font color print('grow chance{}format(grow_chance )end='' print('lightning chance{}format(fire_chance )end='' print('press ctrl- to quit ' if this program was run (instead of imported)run the game if __name__ ='__main__' try main( except keyboardinterrupt sys exit(when ctrl- is pressedend the program forest fire sim