Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simulate the percolation of fire through a forest in which the outermost row of trees has ignited. If the forest is very dense, percolation will

Simulate the percolation of fire through a forest in which the outermost row of trees has ignited. If the forest is very dense, percolation will cause much of the forest to burn and the fire will travel through the entire forest into human-populated areas. If the forest is very sparse, a smaller percentage of trees will catch and the fire will die out before reaching the human boundary. Your goal is to simulate fire in a random 15 x 15 unit forest (one tree possible per unit) with a given density.

a. This problem uses a two-dimensional array. The forest is populated randomly using the specified density. The burn occurs from the top (row 0) down. A tree ignites in row r column c if and only if there is a burning tree in row r-1 at columns c-1, c, or c+1. The prevailing wind in the forest is from north (first row) to south (last row). Trees do not ignite laterally.

b. The rand( ) function returns a random integer between 0 and system constant RAND_MAX. A random double value between 0.0 and 1.0 can be generated using formula:

double r = (double)rand( ) / RAND_MAX; ** Use this formula

c. Code should ask the user for the density, randomly populate the forest, displays initial forest, ignite the first row, run the burn, and display the final forest. Report the initial actual percent of trees and after the burn report the percent of trees burned in the fire and whether the fire burned out. Display percentages to three decimals.

d. Display two outputs. The first uses a density of 0.45 with a case in which the fire burns out and the second uses a density of 0.60 with a case in which the fire does not burn out.

Sample outputs:

image text in transcribed

Forest Fire SiBulation by Progasser nase Enter density 45 Initial forest TT TT TT TT TT TT TT TT TT TT TT TT TT TT T TT T TT TT T TT T, T TT TT TT TT TT T Actual tree density: 6. Burned forest BB TT BB TT TT TT TT TT BB B B B B TT TT, TT B BB BBT TT TT BB TT TT Percentage of trees burned: 0.374 Zire burned out orest Fire Simulation by Proganser name Enter density: .60 nitial forest TT T T T T TT TT T TT TT T T T T T T TT T T T TT TT T TT TT TT TT TT Actual tre density: 0.55 Burned forest TT B BB BB BT BB B BB B BB BB BT BB ercentage of trees burned

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

Students also viewed these Databases questions