en:pfw:simulation-forest_fire
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:pfw:simulation-forest_fire [2023-09-04 18:18] – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | en:pfw:simulation-forest_fire [2023-09-04 18:18] (current) – ↷ Seite von pfw:simulation-forest_fire nach en:pfw:simulation-forest_fire verschoben uho | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{pfw: | ||
+ | ===== Simulation, Forest fire ===== | ||
+ | |||
+ | This program simulates the way a forest fire develops after a lightning-strike, | ||
+ | |||
+ | The program functions as follows: | ||
+ | |||
+ | The central part of the program is a toroidal grid of 512x384 bytes. Execution starts with clearing the grid, corresponding to an area without trees. | ||
+ | |||
+ | Next an endless loop is started. In each loop the following is done: | ||
+ | |||
+ | < | ||
+ | Select a random cell in the grid | ||
+ | Check te content if that cell | ||
+ | if the content is empty | ||
+ | there is a change of 1:500 that a new tree is generated | ||
+ | else | ||
+ | if the content of the cell is a tree: | ||
+ | check if any of the neighbours is a tree on fire | ||
+ | if yes -> also go on fire | ||
+ | if no -> a 1:1000000 change that ' | ||
+ | raise the age of the tree with 1 (up to 255) | ||
+ | else | ||
+ | lower the age of a fire with 1 (until 0 is reached) | ||
+ | then | ||
+ | then | ||
+ | update the screen for the tree or fire based on the age of the tree or fire | ||
+ | next loop | ||
+ | </ | ||
+ | |||
+ | The program is not very fast. Executing 10.000 loops takes between 8.5 and 10.5 ms. With a grid of 512x384 and the default settings it takes about 115 million loops) before a major forest-fire develops. | ||
+ | |||
+ | It is interesting to play around with the different settings of the program to see what happens. If you raise the chance of a lightning-strike you will see that there will be more fires, but never very big. If you raise the chance of a new tree growing there will be a high density of trees quickly, resulting in larger fires. It is also possible to raise the time it takes for a tree to catch fire from a neighbouring tree by changing the definition **(ONFIRE? | ||
+ | |||
+ | **[[https:// | ||
+ | |||
+ | {{https:// | ||