Question: Write a program that simulates the following model for fire growth. We assume that we have a rectangular grid with a fixed number of rows
Write a program that simulates the following model for fire growth. We assume that we have a rectangular grid with a fixed number of rows and columns. Initially, the grid is presumed to have trees that can fuel a fire. We then simulate a fire that starts at a specified cell off the grid. At each step, the fire burns out all of the fuel of its current cell, while moving to an adjacent cell that still has fuel (horizontally or vertically; not diagonally). In particular, if there is a choice of neighboring cells having fuel, it picks one of those choices uniformly at random for the next step. A trial should end when the fire either reaches a cell at the boundary of the grid, or when it reaches a location in which all neighboring squares have already been visited, in which case the fire bums out. Create a file fire, m implementing a function with the following specifications. function outcomes = fire (numRows, numCols, startRow, startcol,) % Simulate the spread of a fire. % USAGE: outcomes = fire (numRow, numcols, start Row, startcol.) % The simulation will be performed on a grid with % specified number of rows and columns, assumed to be numbered % starting at (1, 1) at the top-left, The fire begins at location % (StartRow, startcol) within that grid A series of frames from a trial of fire(7, 7, 4, 4) The next step goes to the left exiting the grid. The final frame of a trial fire(2e, se, 1e, 1s) in which the fire reaches the bottom edge of the region
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
