Question: Help me to do this question with python! Coming back to setting up our forest The final step we want to figure out before we

 Help me to do this question with python! Coming back to Help me to do this question with python!

Coming back to setting up our "forest" The final step we want to figure out before we get to class is how to set up our forest so that we can model the spread of fire. Remember, we want the forest to be an NxN square where O is "empty', 1 is tree", and 2 is "fire. The "density of the forest or fraction of the forest initially covered in trees, free art, should be defined by the probability that a given cell starts off with a tree in it. Start off the board so that the leftmost column of the board is initialized to be 'on fire"l Task: Write a function that creates the initial forest. The function should take in the size of the forest (N) and the probability that a given cell will contain a tree, rree start, and then return the forest. Test out your function by plotting your forest array after you create it Hint: The np.zeros function is a great way to initialize a 2D array full of zeros. Another hint: To decide if a tree should exist in a cell, you can pick a random number between O and 1, and if the number is less than the value of free mart put a tree in the cell. it's higher, don't put a tree there. Final hint: Once you've created an array of zeros, you just need to loop over all of the cells in the array and decide if a tree should go in the cell. When you're done doing that, go back and set the leftmost column to be on firel # Define your "create-forest" function that takes in the value of "N" and the value of "ftreestart" and returns the forest array def create forest

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!