From a336138ee2ca803f7db31ddb3f635f19d2e03914 Mon Sep 17 00:00:00 2001 From: Boki Date: Fri, 13 Feb 2026 14:42:35 -0500 Subject: [PATCH] test --- src/Poe2Trade.Bot/BotOrchestrator.cs | 1 + .../NavigationExecutor.cs | 1 + src/Poe2Trade.Navigation/NavigationTypes.cs | 6 ++--- src/Poe2Trade.Navigation/WorldMap.cs | 25 ++++++++++++++----- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Poe2Trade.Bot/BotOrchestrator.cs b/src/Poe2Trade.Bot/BotOrchestrator.cs index 97f2734..9a0b831 100644 --- a/src/Poe2Trade.Bot/BotOrchestrator.cs +++ b/src/Poe2Trade.Bot/BotOrchestrator.cs @@ -61,6 +61,7 @@ public class BotOrchestrator : IAsyncDisposable TradeQueue = tradeQueue; Links = links; Navigation = new NavigationExecutor(game); + logWatcher.AreaEntered += _ => Navigation.Reset(); _paused = store.Settings.Paused; } diff --git a/src/Poe2Trade.Navigation/NavigationExecutor.cs b/src/Poe2Trade.Navigation/NavigationExecutor.cs index 04ebf85..888a503 100644 --- a/src/Poe2Trade.Navigation/NavigationExecutor.cs +++ b/src/Poe2Trade.Navigation/NavigationExecutor.cs @@ -49,6 +49,7 @@ public class NavigationExecutor : IDisposable _stuckCounter = 0; _lastPosition = null; SetState(NavigationState.Idle); + Log.Information("Navigation reset (new area)"); } public async Task RunExploreLoop() diff --git a/src/Poe2Trade.Navigation/NavigationTypes.cs b/src/Poe2Trade.Navigation/NavigationTypes.cs index 39b3bb3..f3a6dec 100644 --- a/src/Poe2Trade.Navigation/NavigationTypes.cs +++ b/src/Poe2Trade.Navigation/NavigationTypes.cs @@ -71,9 +71,9 @@ public class MinimapConfig public Scalar PlayerHiHSV { get; set; } = new(25, 255, 255); // Wall detection: target #A2AEE5 (blue-lavender structure lines) - // HSV(115, 75, 229) — blue hue, low saturation, bright - public Scalar WallLoHSV { get; set; } = new(100, 20, 150); - public Scalar WallHiHSV { get; set; } = new(130, 140, 255); + // HSV(115, 75, 229) — blue hue, low-medium saturation, bright + public Scalar WallLoHSV { get; set; } = new(100, 50, 190); + public Scalar WallHiHSV { get; set; } = new(130, 120, 255); // Connected components: minimum area to keep (kills speckle) public int WallMinArea { get; set; } = 30; diff --git a/src/Poe2Trade.Navigation/WorldMap.cs b/src/Poe2Trade.Navigation/WorldMap.cs index bd526f4..917776e 100644 --- a/src/Poe2Trade.Navigation/WorldMap.cs +++ b/src/Poe2Trade.Navigation/WorldMap.cs @@ -34,10 +34,14 @@ public class WorldMap : IDisposable _frameCount++; // Noise gate: skip frames with too many wall pixels (waypoint glow, effects) + // But NOT during warmup or re-bootstrap — we need to stitch something to get started var wallPixels = Cv2.CountNonZero(wallMask); var totalPixels = wallMask.Width * wallMask.Height; var density = (double)wallPixels / totalPixels; - if (density > _config.WallMaxDensity) + var isNoisy = density > _config.WallMaxDensity; + var needsBootstrap = _frameCount <= _config.WarmupFrames || _consecutiveMatchFails >= 30; + + if (isNoisy && !needsBootstrap) { Log.Information("Noise gate: {Density:P1} wall density ({Pixels} px), skipping ({Ms:F1}ms)", density, wallPixels, sw.Elapsed.TotalMilliseconds); @@ -64,12 +68,21 @@ public class WorldMap : IDisposable _prevWallMask?.Dispose(); _prevWallMask = wallMask.Clone(); - // Warmup: stitch at center with boosted confidence to bootstrap canvas - if (_frameCount <= _config.WarmupFrames) + // Warmup / re-bootstrap: stitch at current position to seed the canvas + if (needsBootstrap) { - StitchWithConfidence(classifiedMat, _position, boosted: true); - Log.Information("Warmup frame {N}/{Total}: stitch={Ms:F1}ms", - _frameCount, _config.WarmupFrames, sw.Elapsed.TotalMilliseconds); + StitchWithConfidence(classifiedMat, _position, boosted: _frameCount <= _config.WarmupFrames); + if (_consecutiveMatchFails >= 30) + { + Log.Information("Re-bootstrap: stitching at current position after {Fails} match failures ({Ms:F1}ms)", + _consecutiveMatchFails, sw.Elapsed.TotalMilliseconds); + _consecutiveMatchFails = 0; + } + else + { + Log.Information("Warmup frame {N}/{Total}: stitch={Ms:F1}ms", + _frameCount, _config.WarmupFrames, sw.Elapsed.TotalMilliseconds); + } return _position; }