minimap working much better

This commit is contained in:
Boki 2026-02-13 13:48:31 -05:00
parent 7fd80b1645
commit 07fe46c596
2 changed files with 18 additions and 64 deletions

View file

@ -173,35 +173,27 @@ public class WorldMap : IDisposable
var confRoi = new Mat(_confidence, dstRect);
var confInc = (short)_config.ConfidenceInc;
var confDec = (short)_config.ConfidenceDec;
var confThreshold = (short)_config.ConfidenceThreshold;
var confMax = (short)_config.ConfidenceMax;
// Only increment confidence for wall pixels. Don't decay on non-wall pixels because
// temporal smoothing (3/5 vote) kills walls during movement — the minimap scrolls so
// wall pixels shift across frames and fail the vote. "Not wall" in the smoothed mat
// during movement means "couldn't confirm" not "definitely not a wall".
for (var row = 0; row < h; row++)
for (var col = 0; col < w; col++)
{
var srcVal = srcRoi.At<byte>(row, col);
if (srcVal != (byte)MapCell.Wall) continue;
var conf = confRoi.At<short>(row, col);
if (srcVal == (byte)MapCell.Wall)
{
if (boosted)
conf = confMax; // warmup: max confidence so walls survive initial movement
else
conf = Math.Min((short)(conf + confInc), confMax);
}
else
{
// Pixel is in visible area but not wall — decay confidence
conf = Math.Max((short)(conf - confDec), (short)0);
}
conf = boosted
? confMax
: Math.Min((short)(conf + confInc), confMax);
confRoi.Set(row, col, conf);
if (conf >= confThreshold)
dstRoi.Set(row, col, (byte)MapCell.Wall);
else if (dstRoi.At<byte>(row, col) == (byte)MapCell.Wall)
dstRoi.Set(row, col, (byte)MapCell.Explored); // lost confidence, downgrade
}
// Mark explored area: circle around player, only overwrite Unknown