From the course: Complete Guide to Generative AI for Data Analysis and Data Science

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Solution: Simulating forest fires

Solution: Simulating forest fires

(gentle rhythmic music) - [Instructor] Let's work with a solution to the challenge of building a forest fire simulation. Now, I've gone ahead and pasted it in a prompt 'cause it's fairly long, but I do want to go through it here. The first thing we want to do is create an agent-based model in Python to model a forest fire spread. We're going to use a 1,000 by 1,000 grid, with one tree in each cell. Actually, that should say cell, not grid. Trees can be in one of three states: unburnt, burning, and burnt. Okay? Those are the basics. Now, a burning tree will cause a neighboring tree to burn in the next time interval. Trees burn for one time interval. After burning for one time interval, a burning tree transitions to the burnt state. Now, what we want to do is at the start of the simulation, randomly select one tree to burn and run for at most 200 intervals. At the end of the simulation, print the number of time intervals in the simulation and the number of burnt, unburnt, and burning…

Contents