c++ help. You are going to create a forest fire simulation. The simulation will
ID: 3773222 • Letter: C
Question
c++ help.
You are going to create a forest fire simulation. The simulation will take place on a 30 x 30 grid. Each square is populated with either a tree or rock. When you start the simulation, you will place 1-3 fires (*). Each tree(ˆ ) adjacent to a fire square has a chance of catching fire. Rocks(’ ’) do not burn. The fire turns a tree to ash(.) in 1 turn - which also does not burn. Your task is to run the simulation for 40 turns or until the fires all burn out. You will incorporate the following variables into your program:
• Probability of an adjacent tree catching fire.
• Probability of lightning strike starting another fire in a random square.
Explanation / Answer
// Initialize Forest AND one on fire
// Show the Forest
//Function to determmine is neighboring tree is on fire
Here are the complete code and explaining by comments : #include <iostream>
#include <iomanip>
#include <time.h>
#include <stdio.h>
using namespace std;
const int M= 30; const char TREE = '+';
const char BURNINGTREE = '#';
const char BURNEDTREE = '.';
void burnForest(char forest [M][M], int& pFactor);
void showForest(char [M][M]);
void Input(int& rowTree, int& colTree);
void Probability(int& pFactor);
void initForest(char forest[M][M],int row, int column);
void Simulate(char forest [M][M], int& pFactor);
bool TreeOnFire(char forest [M][M]);
bool NeighborTreeOnFire(char forest[M][M], int row, int column);
void Report(char forest[M][M], int pFactor, int burnCyc);
void printRequired246Headings();
void updateForest(char forest [M][M]);
void wait(int sec);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.