mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
New object target handling in wander
This commit is contained in:
parent
01709bd196
commit
616a6bbdf7
@ -1142,7 +1142,7 @@ TGoalVec Goals::CollectRes::getAllPossibleSubgoals()
|
||||
if (dest != t) //there is something blocking our way
|
||||
ret.push_back(sptr(Goals::ClearWayTo(dest, h).setisAbstract(true)));
|
||||
else
|
||||
ret.push_back(sptr(Goals::VisitTile(dest).sethero(h).setisAbstract(true)));
|
||||
ret.push_back(sptr(Goals::GetObj(obj->id.getNum()).sethero(h).setisAbstract(true)));
|
||||
}
|
||||
else //we need to get army in order to pick that object
|
||||
ret.push_back(sptr(Goals::GatherArmy(evaluateDanger(dest, h) * SAFE_ATTACK_CONSTANT).sethero(h).setisAbstract(true)));
|
||||
|
@ -1461,16 +1461,17 @@ void VCAI::wander(HeroPtr h)
|
||||
|
||||
if(dests.size()) //performance improvement
|
||||
{
|
||||
auto fuzzyLogicSorter = [h](const ObjectIdRef & l, const ObjectIdRef & r) -> bool //TODO: create elementar GetObj goal usable for goal decomposition and Wander based on VisitTile logic and object value on top of it
|
||||
Goals::TGoalVec targetObjectGoals;
|
||||
for(auto destination : dests)
|
||||
{
|
||||
return fh->getWanderTargetObjectValue( *h.get(), l) < fh->getWanderTargetObjectValue(*h.get(), r);
|
||||
};
|
||||
|
||||
const ObjectIdRef & dest = *boost::max_element(dests, fuzzyLogicSorter); //find best object to visit based on fuzzy logic evaluation, TODO: use elementar version of GetObj here in future
|
||||
targetObjectGoals.push_back(sptr(Goals::GetObj(destination.id.getNum()).sethero(h).setisAbstract(true)));
|
||||
}
|
||||
auto bestObjectGoal = fh->chooseSolution(targetObjectGoals);
|
||||
decomposeGoal(bestObjectGoal)->accept(this);
|
||||
|
||||
//wander should not cause heroes to be reserved - they are always considered free
|
||||
logAi->debug("Of all %d destinations, object oid=%d seems nice", dests.size(), dest.id.getNum());
|
||||
if (!goVisitObj(dest, h))
|
||||
logAi->debug("Of all %d destinations, object oid=%d seems nice", dests.size(), bestObjectGoal->objid);
|
||||
/*if (!goVisitObj(dest, h))
|
||||
{
|
||||
if (!dest)
|
||||
{
|
||||
@ -1483,7 +1484,7 @@ void VCAI::wander(HeroPtr h)
|
||||
}
|
||||
}
|
||||
else //we reached our destination
|
||||
visitTownIfAny(h);
|
||||
visitTownIfAny(h);*/
|
||||
}
|
||||
}
|
||||
visitTownIfAny(h); //in case hero is just sitting in town
|
||||
|
Loading…
x
Reference in New Issue
Block a user