1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

AI heroes won't trash for objects when exploring area together.

String logging for goal types. Fixes.
This commit is contained in:
DjWarmonger 2012-03-13 20:33:00 +00:00
parent 9518474ec7
commit c8c4c5b682
2 changed files with 51 additions and 17 deletions

View File

@ -52,6 +52,29 @@ const int ALLOWED_ROAMING_HEROES = 8;
const int GOLD_MINE_PRODUCTION = 1000, WOOD_ORE_MINE_PRODUCTION = 2, RESOURCE_MINE_PRODUCTION = 1;
std::string goalName(EGoals goalType)
{
switch (goalType)
{
case INVALID:
return "INVALID";
case WIN:
return "WIN";
case CONQUER:
return "CONQUER";
case EXPLORE:
return "EXPLORE";
case GATHER_ARMY:
return "GATHER ARMY";
case VISIT_TILE:
return "VISIT TILE";
case CLEAR_WAY_TO:
return "CLEAR WAY TO";
default:
return boost::lexical_cast<std::string>(goalType);
}
}
bool compareHeroStrength(const CGHeroInstance *h1, const CGHeroInstance *h2)
{
return h1->getTotalStrength() < h2->getTotalStrength();
@ -866,6 +889,7 @@ void VCAI::makeTurn()
}
}
}
break;
case 7: //reconsider strategy
{
const CGHeroInstance * h = primaryHero();
@ -889,6 +913,7 @@ void VCAI::makeTurn()
}
}
}
break;
}
if(cb->getSelectedHero())
cb->recalculatePaths();
@ -912,8 +937,7 @@ void VCAI::makeTurnInternal()
striveToGoal(CGoal(WIN));
for (auto hg = lockedHeroes.begin(); hg != lockedHeroes.end(); hg++) //continue our goals
{
if (!hg->second.invalid())
striveToGoal (hg->second);
striveToGoal (hg->second);
}
striveToGoal(CGoal(BUILD)); //TODO: smarter building management
}
@ -1100,16 +1124,18 @@ void VCAI::wander(const CGHeroInstance * h)
while(1)
{
auto dests = getPossibleDestinations(h);
if(!dests.size()) //TODO: merge with GATHER_ARMY goal
if(!dests.size())
{
PNLOG("Nowhere more to go...\n");
setGoal (h, INVALID);
break;
}
if(!goVisitObj(dests.front(), h))
const CGObjectInstance * obj = dests.front();
if(!goVisitObj(obj, h))
{
BNLOG("Hero %s apparently used all MPs (%d left)\n", h->name % h->movement);
alreadyVisited.push_back(obj); //reserve that object - we predict it will be reached soon
setGoal(h, CGoal(VISIT_TILE).sethero(h).settile(obj->visitablePos()));
break;
}
@ -1545,6 +1571,8 @@ void VCAI::endTurn()
void VCAI::striveToGoal(const CGoal &ultimateGoal)
{
if (ultimateGoal.invalid())
return;
while(1)
{
CGoal goal = ultimateGoal;
@ -1553,7 +1581,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
while(!goal.isElementar && maxGoals)
{
INDENT;
BNLOG("Considering goal %d.", goal.goalType);
BNLOG("Considering goal %s", goalName(goal.goalType));
try
{
boost::this_thread::interruption_point();
@ -1562,7 +1590,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
}
catch(std::exception &e)
{
BNLOG("Goal %d decomposition failed: %s", goal.goalType % e.what());
BNLOG("Goal %s decomposition failed: %s", goalName(goal.goalType) % e.what());
return;
}
}

View File

@ -62,12 +62,17 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)</OutDir>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)_VC9\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)_VC9\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">..\..\RD</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(Configuration)_VC9\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(SolutionDir)$(Configuration)\bin\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">G:\Programowanie\VCMI\RD</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(SolutionDir)$(Configuration)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(Configuration)\</IntDir>
@ -107,8 +112,8 @@
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>VCMI_lib.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../..;../../libs;../;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
</Link>
@ -155,13 +160,14 @@
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>G:\Programowanie\VCMI\libs;$(OutDir);G:\Programowanie\VCMI\RD;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<Profile>true</Profile>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RD|x64'">
@ -172,7 +178,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>F:\Programowanie\VCMI\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
@ -185,13 +191,12 @@
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>VCMI_lib.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>F:\Programowanie\VCMI\libs;F:\Programowanie\VCMI\RD;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<Profile>true</Profile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -215,6 +220,7 @@
<ItemGroup>
<ProjectReference Include="..\lib\VCMI_lib.vcxproj">
<Project>{b952ffc5-3039-4de1-9f08-90acda483d8f}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />