Skip to content
Permalink
Browse files

Fixed #2317

  • Loading branch information
DjWarmonger committed Oct 25, 2015
1 parent c47c08a commit 520e42bcd7dd79d42cd7603592410b373ab0c78f
Showing with 7 additions and 5 deletions.
  1. +7 −5 AI/VCAI/VCAI.cpp
@@ -2481,14 +2481,13 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)

int3 VCAI::explorationNewPoint(HeroPtr h)
{
//logAi->debugStream() << "Looking for an another place for exploration...";
int radius = h->getSightRadious();
CCallback * cbp = cb.get();
const CGHeroInstance * hero = h.get();

std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow]
tiles.resize(radius);

CCallback * cbp = cb.get();

foreach_tile_pos([&](const int3 &pos)
{
if(!cbp->isVisible(pos))
@@ -2497,6 +2496,7 @@ int3 VCAI::explorationNewPoint(HeroPtr h)

float bestValue = 0; //discovered tile to node distance ratio
int3 bestTile(-1,-1,-1);
int3 ourPos = h->convertPosition(h->pos, false);

for (int i = 1; i < radius; i++)
{
@@ -2505,11 +2505,13 @@ int3 VCAI::explorationNewPoint(HeroPtr h)

for(const int3 &tile : tiles[i])
{
if (!cb->getPathsInfo(h.get())->getPathInfo(tile)->reachable()) //this will remove tiles that are guarded by monsters (or removable objects)
if (tile == ourPos) //shouldn't happen, but it does
continue;
if (!cb->getPathsInfo(hero)->getPathInfo(tile)->reachable()) //this will remove tiles that are guarded by monsters (or removable objects)
continue;

CGPath path;
cb->getPathsInfo(h.get())->getPath(tile, path);
cb->getPathsInfo(hero)->getPath(tile, path);
float ourValue = (float)howManyTilesWillBeDiscovered(tile, radius, cbp) / (path.nodes.size() + 1); //+1 prevents erratic jumps

if (ourValue > bestValue) //avoid costly checks of tiles that don't reveal much

0 comments on commit 520e42b

Please sign in to comment.
You can’t perform that action at this time.