diff --git a/AI/BattleAI/BattleAI.vcxproj b/AI/BattleAI/BattleAI.vcxproj
index 455c26afe..2d78b1787 100644
--- a/AI/BattleAI/BattleAI.vcxproj
+++ b/AI/BattleAI/BattleAI.vcxproj
@@ -76,7 +76,7 @@
$(LibraryPath)
- $(SolutionDir)$(Configuration)\bin\AI\
+ G:\Programowanie\VCMI\RD\AI\
$(IncludePath)
$(LibraryPath)
@@ -122,7 +122,7 @@
MaxSpeed
true
true
- %(AdditionalIncludeDirectories)
+ ..\..\..\include\fuzzyLite;..\..\..\include\fuzzyLite\fuzzylite
Use
StdInc.h
@@ -131,7 +131,7 @@
true
true
VCMI_lib.lib;%(AdditionalDependencies)
- $(OutDir)..;%(AdditionalLibraryDirectories)
+ G:\Programowanie\VCMI\libs;G:\Programowanie\VCMI\RD;../;%(AdditionalLibraryDirectories)
$(OutDir)BattleAI.dll
diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp
index 0fc3672d3..3c31ffb31 100644
--- a/AI/VCAI/VCAI.cpp
+++ b/AI/VCAI/VCAI.cpp
@@ -3,6 +3,7 @@
#include "../../lib/UnlockGuard.h"
#include "../../lib/CObjectHandler.h"
#include "../../lib/CConfigHandler.h"
+#include "../../lib/CHerohandler.h"
#define I_AM_ELEMENTAR return CGoal(*this).setisElementar(true)
CLogger &aiLogger = tlog6;
@@ -73,7 +74,7 @@ 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)
+std::string CGoal::name() const
{
switch (goalType)
{
@@ -93,26 +94,30 @@ std::string goalName(EGoals goalType)
return "GATHER ARMY";
case BOOST_HERO:
return "BOOST_HERO (unsupported)";
+ case RECRUIT_HERO:
+ return "RECRUIT HERO";
case BUILD_STRUCTURE:
return "BUILD STRUCTURE";
case COLLECT_RES:
return "COLLECT RESOURCE";
+ case GATHER_TROOPS:
+ return "GATHER TROOPS";
case GET_OBJ:
- return "GET OBJECT";
+ return "GET OBJECT " + objid;
case FIND_OBJ:
- return "FIND OBJECT";
+ return "FIND OBJECT " + objid;
case VISIT_HERO:
- return "VISIT HERO";
+ return "VISIT HERO " + VLC->heroh->heroes[objid]->name;
case GET_ART_TYPE:
- return "GET ARTIFACT OF TYPE";
+ return "GET ARTIFACT OF TYPE " + VLC->arth->artifacts[aid]->Name();
case ISSUE_COMMAND:
return "ISSUE COMMAND (unsupported)";
case VISIT_TILE:
- return "VISIT TILE";
+ return "VISIT TILE " + tile();
case CLEAR_WAY_TO:
- return "CLEAR WAY TO";
+ return "CLEAR WAY TO " + tile();
case DIG_AT_TILE:
- return "DIG AT TILE";
+ return "DIG AT TILE " + tile();
default:
return boost::lexical_cast(goalType);
}
@@ -1858,7 +1863,7 @@ void getVisibleNeighbours(const std::vector &tiles, std::vector &out
void VCAI::tryRealize(CGoal g)
{
- BNLOG("Attempting realizing goal with code %s", goalName(g.goalType));
+ BNLOG("Attempting realizing goal with code %s", g.name());
switch(g.goalType)
{
case EXPLORE:
@@ -2079,12 +2084,12 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
while(1)
{
CGoal goal = ultimateGoal;
- BNLOG("Striving to goal of type %s", goalName(ultimateGoal.goalType));
+ BNLOG("Striving to goal of type %s", ultimateGoal.name());
int maxGoals = 100; //preventing deadlock for mutually dependent goals
while(!goal.isElementar && !goal.isAbstract && maxGoals)
{
INDENT;
- BNLOG("Considering goal %s", goalName(goal.goalType));
+ BNLOG("Considering goal %s", goal.name());
try
{
boost::this_thread::interruption_point();
@@ -2093,7 +2098,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
}
catch(std::exception &e)
{
- BNLOG("Goal %s decomposition failed: %s", goalName(goal.goalType) % e.what());
+ BNLOG("Goal %s decomposition failed: %s", goal.name() % e.what());
//setGoal (goal.hero, INVALID); //test: if we don't know how to realize goal, we should abandon it for now
return;
}
@@ -2118,7 +2123,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
if (goal.isAbstract)
{
abstractGoal = goal; //allow only one abstract goal per call
- BNLOG("Choosing abstract goal %s", goalName(goal.goalType));
+ BNLOG("Choosing abstract goal %s", goal.name());
break;
}
else
@@ -2139,7 +2144,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
}
catch(std::exception &e)
{
- BNLOG("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.", goalName(goal.goalType) % goalName(ultimateGoal.goalType));
+ BNLOG("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.", goal.name() % ultimateGoal.name());
BNLOG("The error message was: %s", e.what());
break;
}
@@ -2162,7 +2167,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
}
catch(std::exception &e)
{
- BNLOG("Goal %s decomposition failed: %s", goalName(goal.goalType) % e.what());
+ BNLOG("Goal %s decomposition failed: %s", goal.name() % e.what());
//setGoal (goal.hero, INVALID);
return;
}
@@ -2186,7 +2191,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
}
catch(std::exception &e)
{
- BNLOG("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.", goalName(goal.goalType) % goalName(ultimateGoal.goalType));
+ BNLOG("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.", goal.name() % ultimateGoal.name());
BNLOG("The error message was: %s", e.what());
break;
}
@@ -2733,7 +2738,7 @@ int3 whereToExplore(HeroPtr h)
TSubgoal CGoal::whatToDoToAchieve()
{
- BNLOG("Decomposing goal of type %s", goalName(goalType));
+ BNLOG("Decomposing goal of type %s", name());
INDENT;
switch(goalType)
{
diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h
index a0f47f004..865f71be0 100644
--- a/AI/VCAI/VCAI.h
+++ b/AI/VCAI/VCAI.h
@@ -128,6 +128,7 @@ struct CGoal
bool isElementar; SETTER(bool, isElementar)
bool isAbstract; SETTER(bool, isAbstract) //allows to remember abstract goals
int priority; SETTER(bool, priority)
+ std::string name() const;
virtual TSubgoal whatToDoToAchieve();
@@ -403,8 +404,6 @@ public:
void requestActionASAP(boost::function whatToDo);
};
-std::string goalName(EGoals goalType); //TODO: move to CGoal class?
-
class cannotFulfillGoalException : public std::exception
{
std::string msg;
@@ -437,7 +436,7 @@ public:
const char *what() const throw () OVERRIDE
{
- return goalName(goal.goalType).c_str();
+ return goal.name().c_str();
}
};
diff --git a/lib/int3.h b/lib/int3.h
index 0472ea648..c13fe8714 100644
--- a/lib/int3.h
+++ b/lib/int3.h
@@ -78,6 +78,12 @@ public:
return false;
return false;
}
+ inline std::string operator ()() const
+ {
+ return "(" + boost::lexical_cast(x) +
+ " " + boost::lexical_cast(y) +
+ " " + boost::lexical_cast(z) + ")";
+ }
template void serialize(Handler &h, const int version)
{
h & x & y & z;