1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00

First batch of AI fixes:

- wiped not actually used set/get selection
- replaced isReachable with VCAI::isAccessible
This commit is contained in:
Ivan Savenko 2014-09-21 17:03:20 +03:00
parent 380c100783
commit b67618ab53
5 changed files with 2 additions and 24 deletions

View File

@ -353,7 +353,6 @@ bool canBeEmbarkmentPoint(const TerrainTile *t, bool fromWater)
int3 whereToExplore(HeroPtr h)
{
TimeCheck tc ("where to explore");
ai->setSelection(*h);
int radius = h->getSightRadious();
int3 hpos = h->visitablePos();

View File

@ -405,7 +405,6 @@ float FuzzyHelper::evaluate (Goals::VisitTile & g)
return 0;
//assert(cb->isInTheMap(g.tile));
ai->setSelection (g.hero.h);
float turns = 0;
float distance = cb->getMovementCost(g.hero.h, g.tile);
if (!distance) //we stand on that tile

View File

@ -353,7 +353,7 @@ TSubgoal FindObj::whatToDoToAchieve()
}
}
}
if (o)// FIXME: re-enable with *some* hero && isReachable(o)) //we don't use isAccessibleForHero as we don't know which hero it is
if (o && ai->isAccessible(o->pos)) //we don't use isAccessibleForHero as we don't know which hero it is
return sptr (Goals::GetObj(o->id.getNum()));
else
return sptr (Goals::Explore());
@ -377,7 +377,7 @@ TSubgoal GetObj::whatToDoToAchieve()
}
else
{
//if (isReachable(obj)) //FIXME: re-enable with some hero
if (ai->isAccessible(obj->pos))
return sptr (Goals::VisitTile(pos).sethero(hero)); //we must visit object with same hero, if any
}
return sptr (Goals::ClearWayTo(pos).sethero(hero));

View File

@ -95,7 +95,6 @@ VCAI::VCAI(void)
{
LOG_TRACE(logAi);
makingTurn = nullptr;
currentSelection = nullptr;
}
VCAI::~VCAI(void)
@ -695,7 +694,6 @@ void VCAI::makeTurnInternal()
continue;
}
setSelection(hero.first.get());
std::vector<const CGObjectInstance *> vec(hero.second.begin(), hero.second.end());
boost::sort (vec, CDistanceSorter(hero.first.get()));
for (auto obj : vec)
@ -1254,7 +1252,6 @@ bool VCAI::canRecruitAnyHero (const CGTownInstance * t) const
void VCAI::wander(HeroPtr h)
{
setSelection(*h);
//unclaim objects that are now dangerous for us
auto reservedObjsSetCopy = reservedHeroesMap[h];
for (auto obj : reservedObjsSetCopy)
@ -1631,7 +1628,6 @@ bool VCAI::isAccessibleForHero(const int3 & pos, HeroPtr h, bool includeAllies /
bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
{
setSelection(h.h); //make sure we are using the RIGHT pathfinder
logAi->debugStream() << boost::format("Moving hero %s to tile %s") % h->name % dst;
int3 startHpos = h->visitablePos();
bool ret = false;
@ -2185,16 +2181,6 @@ void VCAI::striveToQuest (const QuestInfo &q)
}
}
const CArmedInstance * VCAI::getSelection()
{
return currentSelection;
}
void VCAI::setSelection(const CArmedInstance * obj)
{
currentSelection = obj;
}
void VCAI::performTypicalActions()
{
for(auto h : getUnblockedHeroes())
@ -2250,7 +2236,6 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
int3 VCAI::explorationNewPoint(HeroPtr h)
{
//logAi->debugStream() << "Looking for an another place for exploration...";
setSelection(h.h);
int radius = h->getSightRadious();
std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow]
@ -2658,7 +2643,6 @@ SectorMap::SectorMap()
SectorMap::SectorMap(HeroPtr h)
{
ai->setSelection(h.h);
update();
makeParentBFS(h->visitablePos());
}

View File

@ -124,7 +124,6 @@ const BuildingID extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, Bu
class VCAI : public CAdventureAI
{
const CArmedInstance * currentSelection;
public:
//internal methods for town development
@ -259,9 +258,6 @@ public:
void completeGoal (Goals::TSubgoal goal); //safely removes goal from reserved hero
void striveToQuest (const QuestInfo &q);
const CArmedInstance * getSelection();
void setSelection(const CArmedInstance * obj);
void recruitHero(const CGTownInstance * t, bool throwing = false);
bool isGoodForVisit(const CGObjectInstance *obj, HeroPtr h);
std::vector<const CGObjectInstance *> getPossibleDestinations(HeroPtr h);