- cleaned up some constants in prep for allowing override of more things in the AI
This commit is contained in:
parent
fa31fed5bd
commit
bb44cfdb7b
|
@ -641,11 +641,11 @@ void Ai::retryTask(const Task *task){
|
||||||
}
|
}
|
||||||
// ==================== expansions ====================
|
// ==================== expansions ====================
|
||||||
|
|
||||||
void Ai::addExpansion(const Vec2i &pos){
|
void Ai::addExpansion(const Vec2i &pos) {
|
||||||
|
|
||||||
//check if there is a nearby expansion
|
//check if there is a nearby expansion
|
||||||
for(Positions::iterator it= expansionPositions.begin(); it!=expansionPositions.end(); ++it){
|
for(Positions::iterator it = expansionPositions.begin(); it != expansionPositions.end(); ++it) {
|
||||||
if((*it).dist(pos)<villageRadius){
|
if((*it).dist(pos) < villageRadius) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -654,7 +654,7 @@ void Ai::addExpansion(const Vec2i &pos){
|
||||||
expansionPositions.push_front(pos);
|
expansionPositions.push_front(pos);
|
||||||
|
|
||||||
//remove expansion if queue is list is full
|
//remove expansion if queue is list is full
|
||||||
if(expansionPositions.size()>maxExpansions){
|
if(expansionPositions.size() > maxExpansions){
|
||||||
expansionPositions.pop_back();
|
expansionPositions.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -870,18 +870,24 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){
|
||||||
|
|
||||||
if( aiInterface->getControlType() == ctCpuEasy ||
|
if( aiInterface->getControlType() == ctCpuEasy ||
|
||||||
aiInterface->getControlType() == ctNetworkCpuEasy) {
|
aiInterface->getControlType() == ctNetworkCpuEasy) {
|
||||||
minWarriors+= 1;
|
minWarriors += minMinWarriorsExpandCpuEasy;
|
||||||
}
|
}
|
||||||
else if(aiInterface->getControlType() == ctCpuMega ||
|
else if(aiInterface->getControlType() == ctCpuMega ||
|
||||||
aiInterface->getControlType() == ctNetworkCpuMega) {
|
aiInterface->getControlType() == ctNetworkCpuMega) {
|
||||||
minWarriors+= 3;
|
minWarriors += minMinWarriorsExpandCpuMega;
|
||||||
if(minWarriors>maxMinWarriors-1 || randomMinWarriorsReached) {
|
if(minWarriors > maxMinWarriors-1 || randomMinWarriorsReached) {
|
||||||
randomMinWarriorsReached=true;
|
randomMinWarriorsReached=true;
|
||||||
minWarriors=random.randRange(maxMinWarriors-10, maxMinWarriors*2);
|
minWarriors=random.randRange(maxMinWarriors-10, maxMinWarriors*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(minWarriors<maxMinWarriors) {
|
else if(minWarriors < maxMinWarriors) {
|
||||||
minWarriors+= 3;
|
if(aiInterface->getControlType() == ctCpuUltra ||
|
||||||
|
aiInterface->getControlType() == ctNetworkCpuUltra) {
|
||||||
|
minWarriors += minMinWarriorsExpandCpuUltra;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
minWarriors+= minMinWarriorsExpandCpuNormal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
aiInterface->printLog(2, "Massive attack to pos: "+ intToStr(pos.x)+", "+intToStr(pos.y)+"\n");
|
aiInterface->printLog(2, "Massive attack to pos: "+ intToStr(pos.x)+", "+intToStr(pos.y)+"\n");
|
||||||
}
|
}
|
||||||
|
@ -891,8 +897,9 @@ void Ai::returnBase(int unitIndex) {
|
||||||
CommandResult r;
|
CommandResult r;
|
||||||
aiInterface->getFactionIndex();
|
aiInterface->getFactionIndex();
|
||||||
pos= Vec2i(
|
pos= Vec2i(
|
||||||
random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) +
|
random.randRange(-villageRadius, villageRadius),
|
||||||
getRandomHomePosition();
|
random.randRange(-villageRadius, villageRadius)) +
|
||||||
|
getRandomHomePosition();
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
r= aiInterface->giveCommand(unitIndex, ccMove, pos);
|
r= aiInterface->giveCommand(unitIndex, ccMove, pos);
|
||||||
|
@ -1068,7 +1075,8 @@ void Ai::unblockUnits() {
|
||||||
|
|
||||||
for(int moveAttempt = 1; moveAttempt <= villageRadius; ++moveAttempt) {
|
for(int moveAttempt = 1; moveAttempt <= villageRadius; ++moveAttempt) {
|
||||||
Vec2i pos= Vec2i(
|
Vec2i pos= Vec2i(
|
||||||
random.randRange(-villageRadius*2, villageRadius*2), random.randRange(-villageRadius*2, villageRadius*2)) +
|
random.randRange(-villageRadius*2, villageRadius*2),
|
||||||
|
random.randRange(-villageRadius*2, villageRadius*2)) +
|
||||||
adjacentUnit->getPos();
|
adjacentUnit->getPos();
|
||||||
|
|
||||||
bool canUnitMoveToCell = map->aproxCanMove(adjacentUnit, adjacentUnit->getPos(), pos);
|
bool canUnitMoveToCell = map->aproxCanMove(adjacentUnit, adjacentUnit->getPos(), pos);
|
||||||
|
|
|
@ -129,12 +129,15 @@ public:
|
||||||
|
|
||||||
class Ai {
|
class Ai {
|
||||||
private:
|
private:
|
||||||
static const int harvesterPercent= 30;
|
|
||||||
static const int maxBuildRadius= 40;
|
static const int maxBuildRadius= 40;
|
||||||
|
|
||||||
static const int minMinWarriors= 7;
|
static const int minMinWarriors= 7;
|
||||||
|
static const int minMinWarriorsExpandCpuEasy= 1;
|
||||||
|
static const int minMinWarriorsExpandCpuMega= 3;
|
||||||
|
static const int minMinWarriorsExpandCpuUltra= 3;
|
||||||
|
static const int minMinWarriorsExpandCpuNormal= 3;
|
||||||
static const int maxMinWarriors= 20;
|
static const int maxMinWarriors= 20;
|
||||||
static const int minStaticResources= 10;
|
|
||||||
static const int minConsumableResources= 20;
|
|
||||||
static const int maxExpansions= 2;
|
static const int maxExpansions= 2;
|
||||||
static const int villageRadius= 15;
|
static const int villageRadius= 15;
|
||||||
|
|
||||||
|
@ -147,7 +150,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//typedef vector<AiRule*> AiRules;
|
|
||||||
typedef vector<AiRule *> AiRules;
|
typedef vector<AiRule *> AiRules;
|
||||||
typedef list<const Task*> Tasks;
|
typedef list<const Task*> Tasks;
|
||||||
typedef deque<Vec2i> Positions;
|
typedef deque<Vec2i> Positions;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user