add diffusion explanation to gdd
This commit is contained in:
parent
fa1449b412
commit
2b02ccfe33
21
gdd.md
21
gdd.md
|
@ -28,6 +28,27 @@ Add a tick counter as a UI element.
|
||||||
Diffusing should use 'pull' operations; tiles should pull values from surrounding tiles.
|
Diffusing should use 'pull' operations; tiles should pull values from surrounding tiles.
|
||||||
This is an attempt to think forwards to parallelising computation of diffusiong - ideally using the GPU.
|
This is an attempt to think forwards to parallelising computation of diffusiong - ideally using the GPU.
|
||||||
|
|
||||||
|
#### Diffusion Algorithm
|
||||||
|
|
||||||
|
Diffusion is modelled as two-dimensional steady-state heat conduction.
|
||||||
|
This means that the amount of a value does not change between the start and end of the computation of the diffusion step.
|
||||||
|
The value at one 2D location is calculated based on the values of itself and its neighbours in the previous step.
|
||||||
|
A diffusion coefficient controls the rate of diffusion.
|
||||||
|
|
||||||
|
[Video explanation](https://www.youtube.com/watch?v=RGbV7T_iWT8)
|
||||||
|
[Derivation](https://www.tec-science.com/thermodynamics/heat/heat-equation-diffusion-equation/)
|
||||||
|
|
||||||
|
Implementation:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
private float TransferHeat(float t0, float alpha, float nx, float ny, float px, float py)
|
||||||
|
{
|
||||||
|
float d2tdx2 = nx - 2 * t0 + px;
|
||||||
|
float d2tdy2 = ny - 2 * t0 + py;
|
||||||
|
return t0 + alpha * (d2tdx2 + d2tdy2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Tile Types
|
### Tile Types
|
||||||
|
|
||||||
Tiles start as wild tiles.
|
Tiles start as wild tiles.
|
||||||
|
|
Loading…
Reference in New Issue