I'm making a simple heat distribution program. It's a $2D$ matrix with cells holding heat value. Every iteration looks for cells near current which have lower heat value and gives them some of its heat. Each cell gets different amount of heat (based on heat difference and conductivity).
The problem is with the stage where the distributed amount of heat needs to be multiplied by a certain number to account for up to three nearby cells that don't accept heat (hotter than current cell). I can't figure out how to calculate that multiplier.