[quote=“Kevin Granade, post:12, topic:1516”]I wanted, and still want to make another scent system on top of the existing one that works like gtaguy described, leaves a trail, but the current system is still a cloud centered on the player.
Basically for each square in range it does a calculation where each square gets the average of its value and all surrounding squares, this is a simple diffusion simulation assuming particle mixing in a homogenous environment. The tricky part is excluding scent barriers (walls for example) in a simple way, because the very simple version of just skipping barriers when doing calculations means the average gets skewed and walls effectively eat scent instead of it flowing around them.
Adding wind to this would selectively apply an offset to the calculation so that the cloud as a whole would also migrate in the direction of the wind, possibly it would be applied stochastically so that it can represent a wide range of wind speeds. The real complication though is walls, scent would tend to pile up against walls and have no good way of moving around them other than lateral diffusion, which is really too slow, so we might have to do something to detect being blocked by walls and shift the scent laterally instead. Also the offset wouldn’t be applied inside buildings, so might need some special handling for hat, though I can’t see any major issues like with it piling up against walls.
For players smelling zombies in particular I wasn’t planning on making it require particularly acute senses as I assume the zombies are a bit… ripe 0_0[/quote]
Is the scent simulation even accurate? The impulse response doesn’t appear Gaussian. Every other turn there is a depression or hole in the origin, and there seem to be ripples every other turn as well. Also, it doesn’t obey conservation of matter. If you turn on olfactory mask and move to a fresh location, deactivate it for one turn, reactivate it and observe the evolution of the scent cloud, on the very first turn you’ll see that the origin has a scent of 300, and it’s surrounded by squares that all have scent 200. Shouldn’t the total scent add up to 600 (assuming this is a linear scale), since that’s how much scent you emitted?
Wouldn’t a simpler (and easier to understand) algorithm be something like every update, x% of the scent on a square is spread equally among its neighbors, i.e. each neighbor gets x%/8 scent added. I believe this has the virtue of resulting in Gaussian scent clouds which is what I would expect the impulse response of the diffusion equation to be. It also makes scent a conserved quantity. You could also make walls “refund” the scent given to them so they don’t act as sinks.
Lastly, the calculation could be made a lot faster, at least for long activities like sleep, if you stopped calculating scent once it reaches its steady state. With the current algorithm, that takes ~5 minutes. If you sleep for 8 hours, update_scent() is doing a whole lot of spinning its wheels.