@@ -2481,14 +2481,13 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
2481
2481
2482
2482
int3 VCAI::explorationNewPoint (HeroPtr h)
2483
2483
{
2484
- // logAi->debugStream() << "Looking for an another place for exploration...";
2485
2484
int radius = h->getSightRadious ();
2485
+ CCallback * cbp = cb.get ();
2486
+ const CGHeroInstance * hero = h.get ();
2486
2487
2487
2488
std::vector<std::vector<int3> > tiles; // tiles[distance_to_fow]
2488
2489
tiles.resize (radius);
2489
2490
2490
- CCallback * cbp = cb.get ();
2491
-
2492
2491
foreach_tile_pos ([&](const int3 &pos)
2493
2492
{
2494
2493
if (!cbp->isVisible (pos))
@@ -2497,6 +2496,7 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
2497
2496
2498
2497
float bestValue = 0 ; // discovered tile to node distance ratio
2499
2498
int3 bestTile (-1 ,-1 ,-1 );
2499
+ int3 ourPos = h->convertPosition (h->pos , false );
2500
2500
2501
2501
for (int i = 1 ; i < radius; i++)
2502
2502
{
@@ -2505,11 +2505,13 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
2505
2505
2506
2506
for (const int3 &tile : tiles[i])
2507
2507
{
2508
- if (!cb->getPathsInfo (h.get ())->getPathInfo (tile)->reachable ()) // this will remove tiles that are guarded by monsters (or removable objects)
2508
+ if (tile == ourPos) // shouldn't happen, but it does
2509
+ continue ;
2510
+ if (!cb->getPathsInfo (hero)->getPathInfo (tile)->reachable ()) // this will remove tiles that are guarded by monsters (or removable objects)
2509
2511
continue ;
2510
2512
2511
2513
CGPath path;
2512
- cb->getPathsInfo (h. get () )->getPath (tile, path);
2514
+ cb->getPathsInfo (hero )->getPath (tile, path);
2513
2515
float ourValue = (float )howManyTilesWillBeDiscovered (tile, radius, cbp) / (path.nodes .size () + 1 ); // +1 prevents erratic jumps
2514
2516
2515
2517
if (ourValue > bestValue) // avoid costly checks of tiles that don't reveal much
0 commit comments