Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting the simHeat function #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion MicropolisCore/src/MicropolisEngine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,40 @@ void Micropolis::simUpdate()


/**
* ????
* ???? - It seems to be a sort of Cellular Automaton / Averaging(Smoothing) function across the map.
*
* A deeper understanding of what the Map value holds, is required to fully understand what the effect of this function is.
*
* This is how the function works (assuming HeatWrap == 3 (as its a constant of 3), and heatRule == 0 (as its again a constant)):
*
* Step 1. HeatWrap == 3 - Case #3 in first Switch does the following (actual memory layout is different)
*
* e.g. A B -> D C D C
* C D B A B A
* D C D C
* B A B A
*
* 1. Why do we copy the Map?
a. So we can reuse the original values
*
* Step 2. HeatRule == 0 (if HeatRule == 1 then same general logic applies, BUT mutation function is different)
*
* Work our way through the Map reading each square
* -> Save the result of a mutation function to the center of the square on the map
* -> The result is used again each time the mutation function runs, so the value is passed through the whole map
* -> The mutation function is:
*
* a = 0 or previous result
* a = a & 7
* a += sum(all cells in square) + 7
*
* cell[x,y] = ((a >> 3) & LOMASK) | ANIMBIT | BURNBIT | BULLBIT
*
* Square's are processed in the following order:
*
* A B -> A C D B is the order the Squares are processed in
* C D
*
* @todo Why is Micropolis::cellSrc not allocated together with all the other
* variables?
* @todo What is the purpose of this function?
Expand Down