This commit is contained in:
Pan 2019-05-19 19:18:17 +12:00
parent ba28e46f2f
commit 08f3717542
6 changed files with 260 additions and 227 deletions

View File

@ -162,6 +162,10 @@ public class baseExpensionAI {
} }
} }
if(mainThread.ec.difficulty == 1)
lowGoldmineThreshold = 22500;
else if(mainThread.ec.difficulty == 0)
lowGoldmineThreshold = 15000;
if(myMCV == null && expensionGoldMine.goldDeposite >= 17500 && (mainThread.ec.theEconomyManagerAI.preferedGoldMine.goldDeposite < lowGoldmineThreshold || if(myMCV == null && expensionGoldMine.goldDeposite >= 17500 && (mainThread.ec.theEconomyManagerAI.preferedGoldMine.goldDeposite < lowGoldmineThreshold ||
(!hasRefineryNearTheGoldmine(mainThread.ec.theEconomyManagerAI.preferedGoldMine) && !hasConstructionYardNearGoldMine(mainThread.ec.theEconomyManagerAI.preferedGoldMine)) || (!hasRefineryNearTheGoldmine(mainThread.ec.theEconomyManagerAI.preferedGoldMine) && !hasConstructionYardNearGoldMine(mainThread.ec.theEconomyManagerAI.preferedGoldMine)) ||
@ -428,6 +432,9 @@ public class baseExpensionAI {
//3 stealth tanks will make a perfect scout team for the base expansion exploration //3 stealth tanks will make a perfect scout team for the base expansion exploration
public boolean needStealthTank(){ public boolean needStealthTank(){
if(mainThread.ec.difficulty == 0)
return false;
for(int i = 0; i < scouts.length; i++){ for(int i = 0; i < scouts.length; i++){
if((scouts[i] == null || scouts[i].currentHP <=0) && frameAI > 800){ if((scouts[i] == null || scouts[i].currentHP <=0) && frameAI > 800){
return true; return true;

View File

@ -173,7 +173,7 @@ public class buildingManagerAI {
//build more factory if we have plenty of money in the bank //build more factory if we have plenty of money in the bank
if(theBaseInfo.currentCredit > 2200 && theBaseInfo.canBuildFactory && theBaseInfo.numberOfFactory < 5 && theBaseInfo.numberOfFactory <= mainThread.ec.theEconomyManagerAI.numberOfharvesters/2){ if(theBaseInfo.currentCredit > 2200 && mainThread.ec.difficulty > 0 && theBaseInfo.canBuildFactory && theBaseInfo.numberOfFactory < 5 && theBaseInfo.numberOfFactory <= mainThread.ec.theEconomyManagerAI.numberOfharvesters/2){
addBuildingToQueue(105); addBuildingToQueue(105);
} }

View File

@ -130,15 +130,6 @@ public class combatManagerAI {
combatCenterZ = mainThread.ec.theUnitProductionAI.combatAICenterZ; combatCenterZ = mainThread.ec.theUnitProductionAI.combatAICenterZ;
//System.out.println(combatCenterX + " " + combatCenterZ + " " + currentState + " " + numberOfUnitInCombatRadius);
if(Float.isNaN(combatCenterX) || Float.isNaN(combatCenterZ)) {
// combatCenterX = 0;
// combatCenterZ= 0;
}
boolean frontalTroopIverwhelmed = false; boolean frontalTroopIverwhelmed = false;
boolean shouldAttack = false; boolean shouldAttack = false;
boolean playerHasBecomeStrongerThanAIDuringMarching = false; boolean playerHasBecomeStrongerThanAIDuringMarching = false;
@ -161,7 +152,7 @@ public class combatManagerAI {
if(currentState == booming){ if(currentState == booming){
//enemy AI compares its own force with player's force, then make a decision whether it should attack or not //enemy AI compares its own force with player's force, then make a decision whether it should attack or not
attackTime = standardAttackTime; attackTime = standardAttackTime;
if(mainThread.ec.theMapAwarenessAI.canRushPlayer) if(mainThread.ec.theMapAwarenessAI.canRushPlayer && mainThread.ec.difficulty > 0)
attackTime = rushAttackTime; attackTime = rushAttackTime;
int targetPlayerExpension = mainThread.ec.theMapAwarenessAI.targetPlayerExpension; int targetPlayerExpension = mainThread.ec.theMapAwarenessAI.targetPlayerExpension;
@ -403,8 +394,12 @@ public class combatManagerAI {
} }
} }
if(mainThread.ec.difficulty < 1)
staticDefenseAhead = false;
//if a rush tactics is denied by the player (e.g player builds static defenses around natural), then briefly suspend the attacking force (wait for rocket tanks to take out the static defenses) //if a rush tactics is denied by the player (e.g player builds static defenses around natural), then briefly suspend the attacking force (wait for rocket tanks to take out the static defenses)
if(frameAI < standardAttackTime && mainThread.ec.theMapAwarenessAI.canRushPlayer && distanceToTower < 2){ if(frameAI < standardAttackTime && mainThread.ec.theMapAwarenessAI.canRushPlayer && distanceToTower < 2 && mainThread.ec.difficulty > 0){
if(Math.abs(attackPosition.x - myRallyPointX) > 12 || Math.abs(attackPosition.z - myRallyPointZ) > 12) { if(Math.abs(attackPosition.x - myRallyPointX) > 12 || Math.abs(attackPosition.z - myRallyPointZ) > 12) {
for(int i = 0; i < troopsControlledByCombatAI.length; i++) { for(int i = 0; i < troopsControlledByCombatAI.length; i++) {
if(troopsControlledByCombatAI[i] != null && troopsControlledByCombatAI[i].currentHP > 0 && troopsControlledByCombatAI[i].type != 1) { if(troopsControlledByCombatAI[i] != null && troopsControlledByCombatAI[i].currentHP > 0 && troopsControlledByCombatAI[i].type != 1) {
@ -625,46 +620,53 @@ public class combatManagerAI {
for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){ for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){
if(team[i] != null && team[i].currentHP > 0){ if(team[i] != null && team[i].currentHP > 0){
//stop chasing player unit if it has got out of sight
if(team[i].targetObject != null && team[i].targetObject.currentHP >0) {
int targetPositionIndex = (int)(team[i].targetObject.centre.x*64)/16 + (127 - (int)(team[i].targetObject.centre.z*64)/16)*128;
if(team[i].attackStatus != solidObject.isAttacking && team[i].underAttackCountDown == 0 && (!mainThread.ec.visionMap[targetPositionIndex] || team[i].targetObject.isCloaked)) if(mainThread.ec.difficulty > 0) {
team[i].targetObject = null; //stop chasing player unit if it has got out of sight
} if(team[i].targetObject != null && team[i].targetObject.currentHP >0) {
int targetPositionIndex = (int)(team[i].targetObject.centre.x*64)/16 + (127 - (int)(team[i].targetObject.centre.z*64)/16)*128;
//marching forward if(team[i].attackStatus != solidObject.isAttacking && team[i].underAttackCountDown == 0 && (!mainThread.ec.visionMap[targetPositionIndex] || team[i].targetObject.isCloaked))
if(team[i].targetObject == null || team[i].targetObject.currentHP <=0){ team[i].targetObject = null;
if(staticDefenseAhead) {
if(team[i].type == 1) {
team[i].attackMoveTo(team[i].centre.x + attackDirection.x*teamRadius, team[i].centre.z + attackDirection.z*teamRadius);
}else {
team[i].attackMoveTo(combatCenterX, combatCenterZ);
}
}else if(!(team[i].currentMovementStatus == solidObject.hugRight || team[i].currentMovementStatus == solidObject.hugLeft)){
double d = Math.sqrt((team[i].centre.x - combatCenterX)*(team[i].centre.x - combatCenterX) + (team[i].centre.z - combatCenterZ)*(team[i].centre.z - combatCenterZ))*3;
if(d > teamRadius){
if(staticDefenseNearAttackPosition || !playerForceIsMuchWeakerThanAI || mainThread.ec.theMapAwarenessAI.playerAssetDestoryedCountDown == 0)
team[i].attackMoveTo(gatherPoint.x, gatherPoint.z);
else
team[i].attackMoveTo(attackPosition.x, attackPosition.z);
}else{
team[i].attackMoveTo(team[i].centre.x + attackDirection.x*teamRadius, team[i].centre.z + attackDirection.z*teamRadius);
}
} }
//marching forward
if(team[i].targetObject == null || team[i].targetObject.currentHP <=0){
if(staticDefenseAhead) {
if(team[i].type == 1) {
team[i].attackMoveTo(team[i].centre.x + attackDirection.x*teamRadius, team[i].centre.z + attackDirection.z*teamRadius);
}else {
team[i].attackMoveTo(combatCenterX, combatCenterZ);
}
}else if(!(team[i].currentMovementStatus == solidObject.hugRight || team[i].currentMovementStatus == solidObject.hugLeft)){
double d = Math.sqrt((team[i].centre.x - combatCenterX)*(team[i].centre.x - combatCenterX) + (team[i].centre.z - combatCenterZ)*(team[i].centre.z - combatCenterZ))*3;
if(d > teamRadius){
if(staticDefenseNearAttackPosition || !playerForceIsMuchWeakerThanAI || mainThread.ec.theMapAwarenessAI.playerAssetDestoryedCountDown == 0)
team[i].attackMoveTo(gatherPoint.x, gatherPoint.z);
else
team[i].attackMoveTo(attackPosition.x, attackPosition.z);
}else{
team[i].attackMoveTo(team[i].centre.x + attackDirection.x*teamRadius, team[i].centre.z + attackDirection.z*teamRadius);
}
}
team[i].currentCommand = solidObject.attackMove;
team[i].secondaryCommand = solidObject.attackMove;
}
}else {
team[i].attackMoveTo(attackPosition.x, attackPosition.z);
team[i].currentCommand = solidObject.attackMove; team[i].currentCommand = solidObject.attackMove;
team[i].secondaryCommand = solidObject.attackMove; team[i].secondaryCommand = solidObject.attackMove;
} }
} }
} }
@ -729,6 +731,8 @@ public class combatManagerAI {
public boolean checkIfAIHasBiggerForce(float ratio){ public boolean checkIfAIHasBiggerForce(float ratio){
int numberOfLightTanks_AI = mainThread.ec.theUnitProductionAI.numberOfLightTanksControlledByCombatAI; int numberOfLightTanks_AI = mainThread.ec.theUnitProductionAI.numberOfLightTanksControlledByCombatAI;
int numberOfRocketTanks_AI = mainThread.ec.theUnitProductionAI.numberOfRocketTanksControlledByCombatAI; int numberOfRocketTanks_AI = mainThread.ec.theUnitProductionAI.numberOfRocketTanksControlledByCombatAI;
int numberOfStealthTanks_AI = mainThread.ec.theUnitProductionAI.numberOfStealthTanksControlledByCombatAI; int numberOfStealthTanks_AI = mainThread.ec.theUnitProductionAI.numberOfStealthTanksControlledByCombatAI;
@ -767,6 +771,8 @@ public class combatManagerAI {
//System.out.println("unrevealedPlayerForceStrength" + unrevealedPlayerForceStrength + " " + "enemyAIForceStrength " + enemyAIForceStrength + " " + "playerForceStrength" + playerForceStrength); //System.out.println("unrevealedPlayerForceStrength" + unrevealedPlayerForceStrength + " " + "enemyAIForceStrength " + enemyAIForceStrength + " " + "playerForceStrength" + playerForceStrength);
return enemyAIForceStrength > 0 && playerForceStrength/enemyAIForceStrength < ratio; return enemyAIForceStrength > 0 && playerForceStrength/enemyAIForceStrength < ratio;
} }

View File

@ -80,98 +80,100 @@ public class defenseManagerAI {
lightTanksControlledByCombatAI = mainThread.ec.theUnitProductionAI.lightTanksControlledByCombatAI; lightTanksControlledByCombatAI = mainThread.ec.theUnitProductionAI.lightTanksControlledByCombatAI;
//after 500 seconds mark, borrow 2 stealth tanks from combat manager, and send them to guard western and southern side of the main base //after 500 seconds mark, borrow 2 stealth tanks from combat manager, and send them to guard western and southern side of the main base
if(frameAI >= 450 && mainThread.ec.theCombatManagerAI.checkIfAIHasBiggerForce(0.8f)) { if(mainThread.ec.difficulty == 2) {
for(int i = 0; i < 2; i++) { if(frameAI >= 450 && mainThread.ec.theCombatManagerAI.checkIfAIHasBiggerForce(0.8f)) {
if(observers[i] == null || observers[i].currentHP <=0) { for(int i = 0; i < 2; i++) {
for(int j = 0; j < stealthTanksControlledByCombatAI.length; j++) { if(observers[i] == null || observers[i].currentHP <=0) {
if(stealthTanksControlledByCombatAI[j] != null && stealthTanksControlledByCombatAI[j].currentHP == 80 && stealthTanksControlledByCombatAI[j].attackStatus != solidObject.isAttacking) { for(int j = 0; j < stealthTanksControlledByCombatAI.length; j++) {
observers[i] = stealthTanksControlledByCombatAI[j]; if(stealthTanksControlledByCombatAI[j] != null && stealthTanksControlledByCombatAI[j].currentHP == 80 && stealthTanksControlledByCombatAI[j].attackStatus != solidObject.isAttacking) {
stealthTanksControlledByCombatAI[j] = null; observers[i] = stealthTanksControlledByCombatAI[j];
float xPos = 20f; stealthTanksControlledByCombatAI[j] = null;
float zPos = 30.5f; float xPos = 20f;
float zPos = 30.5f;
if(i == 1) {
xPos = 30f;
zPos = 20f;
}
if(frameAI > 1000) {
xPos = 0.25f;
zPos = 20.5f;
if(i == 1) { if(i == 1) {
xPos = 18.75f; xPos = 30f;
zPos = 5f; zPos = 20f;
} }
}
observers[i].moveTo(xPos, zPos);
observers[i].currentCommand = solidObject.move; if(frameAI > 1000) {
observers[i].secondaryCommand = solidObject.StandBy; xPos = 0.25f;
break; zPos = 20.5f;
if(i == 1) {
xPos = 18.75f;
zPos = 5f;
}
}
observers[i].moveTo(xPos, zPos);
observers[i].currentCommand = solidObject.move;
observers[i].secondaryCommand = solidObject.StandBy;
break;
}
} }
} }
} }
} }
}
//keep an eye on player units and avoid being detected //keep an eye on player units and avoid being detected
for(int i = 0; i < observers.length; i++) { for(int i = 0; i < observers.length; i++) {
if(observers[i] != null) { if(observers[i] != null) {
if(!evadePlayerUnit(i)) { if(!evadePlayerUnit(i)) {
float xPos = 0; float xPos = 0;
float zPos = 0; float zPos = 0;
//if there is no player units in sight, return to patrol position //if there is no player units in sight, return to patrol position
if(i == 0) { if(i == 0) {
if(frameAI%28 < 14) { if(frameAI%28 < 14) {
xPos = 15.5f; xPos = 15.5f;
zPos = 30.5f; zPos = 30.5f;
}else {
xPos = 15.5f;
zPos = 24.5f;
}
if(frameAI > 1000) {
if(frameAI%18 < 9) {
xPos = 0.25f;
zPos = 20.5f;
}else { }else {
xPos = 5f; xPos = 15.5f;
zPos = 20.5f; zPos = 24.5f;
} }
if(frameAI > 1000) {
if(frameAI%18 < 9) {
xPos = 0.25f;
zPos = 20.5f;
}else {
xPos = 5f;
zPos = 20.5f;
}
}
} }
if(i == 1) {
if(frameAI%30 < 15) {
xPos = 29.25f;
zPos = 17f;
}else {
xPos = 29.25f;
zPos = 10f;
}
if(frameAI > 1000) {
if(frameAI%14 < 7) {
xPos = 18.75f;
zPos = 5f;
}else {
xPos = 18.75f;
zPos = 0.5f;
}
}
}
observers[i].moveTo(xPos, zPos);
observers[i].currentCommand = solidObject.move;
observers[i].secondaryCommand = solidObject.StandBy;
} }
if(i == 1) {
if(frameAI%30 < 15) {
xPos = 29.25f;
zPos = 17f;
}else {
xPos = 29.25f;
zPos = 10f;
}
if(frameAI > 1000) {
if(frameAI%14 < 7) {
xPos = 18.75f;
zPos = 5f;
}else {
xPos = 18.75f;
zPos = 0.5f;
}
}
}
observers[i].moveTo(xPos, zPos);
observers[i].currentCommand = solidObject.move;
observers[i].secondaryCommand = solidObject.StandBy;
} }
} }
} }

View File

@ -105,7 +105,8 @@ public class enemyCommander {
} }
if(mainThread.gameFrame % 30 == 3){ if(mainThread.gameFrame % 30 == 3){
theScoutingManagerAI.processAI(); if(difficulty > 0)
theScoutingManagerAI.processAI();
} }
if(mainThread.gameFrame % 30 == 4){ if(mainThread.gameFrame % 30 == 4){
@ -121,16 +122,18 @@ public class enemyCommander {
} }
if(mainThread.gameFrame % 30 == 7){ if(mainThread.gameFrame % 30 == 7){
theDefenseManagerAI.processAI(); if(difficulty > 0)
theDefenseManagerAI.processAI();
} }
if(difficulty == 2){
theHarassmentAI.processAI(); theHarassmentAI.processAI();
//if(mainThread.frameIndex % 5 == 0){
theMicroManagementAI.processAI(); theMicroManagementAI.processAI();
//} }
} }

View File

@ -112,7 +112,7 @@ public class unitProductionAI {
rallyPoint.set(x - 2f, 0, z - 1.5f); rallyPoint.set(x - 2f, 0, z - 1.5f);
if(frameAI < 240) { if(frameAI < 240 && mainThread.ec.difficulty == 2) {
rallyPoint.set(mainThread.theAssetManager.goldMines[5].centre); rallyPoint.set(mainThread.theAssetManager.goldMines[5].centre);
} }
}else { }else {
@ -147,114 +147,128 @@ public class unitProductionAI {
} }
//make decision on what unit to produce if(mainThread.ec.difficulty > 0) {
int numberOfPlayerGunTurrets= mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player; //make decision on what unit to produce
int numberOfPlayerMissileTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player; int numberOfPlayerGunTurrets= mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player;
int numberOfLightTanks_player = mainThread.ec.theMapAwarenessAI.numberOfLightTanks_player; int numberOfPlayerMissileTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player;
int numberOfRocketTanks_player = mainThread.ec.theMapAwarenessAI.numberOfRocketTanks_player; int numberOfLightTanks_player = mainThread.ec.theMapAwarenessAI.numberOfLightTanks_player;
int numberOfStealthTanks_player = mainThread.ec.theMapAwarenessAI.numberOfStealthTanks_player; int numberOfRocketTanks_player = mainThread.ec.theMapAwarenessAI.numberOfRocketTanks_player;
int numberOfHeavyTanks_player = mainThread.ec.theMapAwarenessAI.numberOfHeavyTanks_player; int numberOfStealthTanks_player = mainThread.ec.theMapAwarenessAI.numberOfStealthTanks_player;
int maxNumberOfStealthTanks_playerInLastFiveMinutes = mainThread.ec.theMapAwarenessAI.maxNumberOfStealthTanks_playerInLastFiveMinutes; int numberOfHeavyTanks_player = mainThread.ec.theMapAwarenessAI.numberOfHeavyTanks_player;
int maxNumberOfStealthTanks_playerInLastFiveMinutes = mainThread.ec.theMapAwarenessAI.maxNumberOfStealthTanks_playerInLastFiveMinutes;
boolean playerHasMostlyLightTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyLightTanks; boolean playerHasMostlyLightTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyLightTanks;
boolean playerHasMostlyHeavyTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyHeavyTanks; boolean playerHasMostlyHeavyTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyHeavyTanks;
boolean playIsRushingHighTierUnits = mainThread.ec.theMapAwarenessAI.playIsRushingHighTierUnits; boolean playIsRushingHighTierUnits = mainThread.ec.theMapAwarenessAI.playIsRushingHighTierUnits;
boolean playerLikelyCanNotProduceHighTierUnits = mainThread.ec.theMapAwarenessAI.playerLikelyCanNotProduceHighTierUnits; boolean playerLikelyCanNotProduceHighTierUnits = mainThread.ec.theMapAwarenessAI.playerLikelyCanNotProduceHighTierUnits;
boolean playerDoesntHaveMassHeavyTanks = mainThread.ec.theMapAwarenessAI.playerDoesntHaveMassHeavyTanks; boolean playerDoesntHaveMassHeavyTanks = mainThread.ec.theMapAwarenessAI.playerDoesntHaveMassHeavyTanks;
boolean playerHasManyLightTanksButNoHeavyTank = mainThread.ec.theMapAwarenessAI.playerHasManyLightTanksButNoHeavyTank; boolean playerHasManyLightTanksButNoHeavyTank = mainThread.ec.theMapAwarenessAI.playerHasManyLightTanksButNoHeavyTank;
boolean playerHasMostlyHeavyAndStealthTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyHeavyAndStealthTanks; boolean playerHasMostlyHeavyAndStealthTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyHeavyAndStealthTanks;
boolean playerHasMostlyLightAndStealthTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyLightAndStealthTanks; boolean playerHasMostlyLightAndStealthTanks = mainThread.ec.theMapAwarenessAI.playerHasMostlyLightAndStealthTanks;
boolean playerArmyCanBeCounteredWithLightTanks = mainThread.ec.theMapAwarenessAI.playerArmyCanBeCounteredWithLightTanks; boolean playerArmyCanBeCounteredWithLightTanks = mainThread.ec.theMapAwarenessAI.playerArmyCanBeCounteredWithLightTanks;
boolean playerArmyCanBeCounteredWithStealthTanks = mainThread.ec.theMapAwarenessAI.playerArmyCanBeCounteredWithStealthTanks; boolean playerArmyCanBeCounteredWithStealthTanks = mainThread.ec.theMapAwarenessAI.playerArmyCanBeCounteredWithStealthTanks;
int timeToBuildHeavyTank = 500; int timeToBuildHeavyTank = 500;
int timeToBuildStealthTank = 200; int timeToBuildStealthTank = 200;
if(mainThread.ec.theMapAwarenessAI.canRushPlayer) { if(mainThread.ec.theMapAwarenessAI.canRushPlayer) {
//when AI decides to rush the player, then dont build higher tier units so it can mass produce light tanks //when AI decides to rush the player, then dont build higher tier units so it can mass produce light tanks
timeToBuildHeavyTank = 500; timeToBuildHeavyTank = 500;
timeToBuildStealthTank = 300; timeToBuildStealthTank = 300;
} }
boolean b1 = (numberOfRocketTanks_AI < 3 && !playerHasMostlyHeavyTanks && (frameAI > 400 || frameAI > 170 && frameAI < 240 && mainThread.ec.theMapAwarenessAI.numberOfConstructionYard_player > 0) && !playerHasMostlyLightTanks); boolean b1 = (numberOfRocketTanks_AI < 3 && !playerHasMostlyHeavyTanks && (frameAI > 400 || frameAI > 170 && frameAI < 240 && mainThread.ec.theMapAwarenessAI.numberOfConstructionYard_player > 0) && !playerHasMostlyLightTanks);
boolean b2 = (numberOfRocketTanks_AI < numberOfPlayerGunTurrets + numberOfPlayerMissileTurrets*1.5); boolean b2 = (numberOfRocketTanks_AI < numberOfPlayerGunTurrets + numberOfPlayerMissileTurrets*1.5);
if( b1 || b2){ if( b1 || b2){
currentProductionOrder = produceRocketTank; currentProductionOrder = produceRocketTank;
}else if(theBaseInfo.canBuildHeavyTank && numberOfHeavyTanksControlledByCombatAI < 20 && !(numberOfStealthTanksControlledByCombatAI < 1) && !playerHasMostlyHeavyTanks && !playerHasMostlyLightTanks && !playerHasMostlyLightAndStealthTanks && !playerArmyCanBeCounteredWithLightTanks && !playerArmyCanBeCounteredWithStealthTanks && }else if(theBaseInfo.canBuildHeavyTank && numberOfHeavyTanksControlledByCombatAI < 20 && !(numberOfStealthTanksControlledByCombatAI < 1) && !playerHasMostlyHeavyTanks && !playerHasMostlyLightTanks && !playerHasMostlyLightAndStealthTanks && !playerArmyCanBeCounteredWithLightTanks && !playerArmyCanBeCounteredWithStealthTanks &&
(playerHasMostlyHeavyAndStealthTanks || (frameAI > timeToBuildHeavyTank && numberOfHeavyTanks_AI < 3) || (playerHasMostlyHeavyAndStealthTanks || (frameAI > timeToBuildHeavyTank && numberOfHeavyTanks_AI < 3) ||
!playerHasManyLightTanksButNoHeavyTank !playerHasManyLightTanksButNoHeavyTank
&& !(numberOfHeavyTanks_player == 0 && maxNumberOfStealthTanks_playerInLastFiveMinutes < 3 && frameAI > 600) && !(numberOfHeavyTanks_player == 0 && maxNumberOfStealthTanks_playerInLastFiveMinutes < 3 && frameAI > 600)
&& !(playerHasMostlyHeavyTanks && numberOfStealthTanks_player < numberOfHeavyTanks_AI*2) && !(playerHasMostlyHeavyTanks && numberOfStealthTanks_player < numberOfHeavyTanks_AI*2)
&& (playIsRushingHighTierUnits || maxNumberOfStealthTanks_playerInLastFiveMinutes*4 > numberOfHeavyTanks_AI))){ && (playIsRushingHighTierUnits || maxNumberOfStealthTanks_playerInLastFiveMinutes*4 > numberOfHeavyTanks_AI))){
currentProductionOrder = produceHeavyTank; currentProductionOrder = produceHeavyTank;
}else if(theBaseInfo.canBuildStealthTank && ((numberOfStealthTanksControlledByCombatAI < 1) || (playerDoesntHaveMassHeavyTanks && !playerHasMostlyHeavyTanks && !playerArmyCanBeCounteredWithLightTanks && !(numberOfStealthTanksControlledByCombatAI >= 9 && frameAI < 600) && !(numberOfStealthTanksControlledByCombatAI >= 18 && frameAI > 600) }else if(theBaseInfo.canBuildStealthTank && ((numberOfStealthTanksControlledByCombatAI < 1) || (playerDoesntHaveMassHeavyTanks && !playerHasMostlyHeavyTanks && !playerArmyCanBeCounteredWithLightTanks && !(numberOfStealthTanksControlledByCombatAI >= 9 && frameAI < 600) && !(numberOfStealthTanksControlledByCombatAI >= 18 && frameAI > 600)
&& (playerHasMostlyLightTanks || playerLikelyCanNotProduceHighTierUnits || playerDoesntHaveMassHeavyTanks || playerHasMostlyLightAndStealthTanks) && !playerHasMostlyHeavyTanks && (frameAI > timeToBuildStealthTank || numberOfLightTanks_player > 8)))){ && (playerHasMostlyLightTanks || playerLikelyCanNotProduceHighTierUnits || playerDoesntHaveMassHeavyTanks || playerHasMostlyLightAndStealthTanks) && !playerHasMostlyHeavyTanks && (frameAI > timeToBuildStealthTank || numberOfLightTanks_player > 8)))){
currentProductionOrder = produceStealthTank; currentProductionOrder = produceStealthTank;
}else{ }else{
currentProductionOrder = produceLightTank; currentProductionOrder = produceLightTank;
} }
//make decision on what tech to research //make decision on what tech to research
if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfCommunicationCenter > 0) { if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfCommunicationCenter > 0 && mainThread.ec.difficulty > 1) {
if(mainThread.ec.theDefenseManagerAI.needMissileTurret || theBaseInfo.currentCredit > 1500 && frameAI > 450) { if(mainThread.ec.theDefenseManagerAI.needMissileTurret || theBaseInfo.currentCredit > 1500 && frameAI > 450) {
if(!communicationCenter.rapidfireResearched_enemy) { if(!communicationCenter.rapidfireResearched_enemy) {
if(communicationCenter.rapidfireResearchProgress_enemy == 255){ if(communicationCenter.rapidfireResearchProgress_enemy == 255){
communicationCenter.researchRapidfire(1); communicationCenter.researchRapidfire(1);
System.out.println("----------------------------AI starts researching rapid fire ability------------------------------------"); System.out.println("----------------------------AI starts researching rapid fire ability------------------------------------");
}
}
}
if(mainThread.ec.theEconomyManagerAI.numberOfharvesters >= 6 && theBaseInfo.currentCredit > 1500 && mainThread.ec.difficulty > 1) {
if(!communicationCenter.harvesterSpeedResearched_enemy) {
if(communicationCenter.harvesterSpeedResearchProgress_enemy == 255){
communicationCenter.researchHarvesterSpeed(1);
System.out.println("----------------------------AI starts researching harvester speed ability------------------------------------");
}
} }
} }
} }
if(mainThread.ec.theEconomyManagerAI.numberOfharvesters >= 6 && theBaseInfo.currentCredit > 1500) { if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfTechCenter > 0){
if(!communicationCenter.harvesterSpeedResearched_enemy) {
if(communicationCenter.harvesterSpeedResearchProgress_enemy == 255){ //Immediately start stealth tank upgrades when a tech center is built
communicationCenter.researchHarvesterSpeed(1); if(!techCenter.stealthTankResearched_enemy){
System.out.println("----------------------------AI starts researching harvester speed ability------------------------------------"); if(techCenter.stealthTankResearchProgress_enemy == 255){
techCenter.cancelResearch(1);
techCenter.researchStealthTank(1);
System.out.println("----------------------------AI starts researching stealth tank------------------------------------");
} }
} }
}
}
if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfTechCenter > 0){
//Immediately start stealth tank upgrades when a tech center is built
if(!techCenter.stealthTankResearched_enemy){
if(techCenter.stealthTankResearchProgress_enemy == 255){
techCenter.cancelResearch(1);
techCenter.researchStealthTank(1);
System.out.println("----------------------------AI starts researching stealth tank------------------------------------");
}
}
if(numberOfLightTanks_AI >= 15 && theBaseInfo.currentCredit > 1000){ if(numberOfLightTanks_AI >= 15 && theBaseInfo.currentCredit > 1000){
if(!techCenter.lightTankResearched_enemy){ if(!techCenter.lightTankResearched_enemy){
if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){ if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){
techCenter.researchLightTank(1); techCenter.researchLightTank(1);
System.out.println("----------------------------AI starts researching light tank------------------------------------"); System.out.println("----------------------------AI starts researching light tank------------------------------------");
}
} }
} }
}
if(numberOfRocketTanks_AI > 2 && theBaseInfo.currentCredit > 1250 && (numberOfPlayerGunTurrets > 0 || numberOfPlayerMissileTurrets > 0 || frameAI > 600)){ if(numberOfRocketTanks_AI > 2 && theBaseInfo.currentCredit > 1250 && (numberOfPlayerGunTurrets > 0 || numberOfPlayerMissileTurrets > 0 || frameAI > 600)){
if(!techCenter.rocketTankResearched_enemy){ if(!techCenter.rocketTankResearched_enemy){
if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){ if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){
techCenter.researchRocketTank(1); techCenter.researchRocketTank(1);
System.out.println("----------------------------AI starts researching rocket tank------------------------------------"); System.out.println("----------------------------AI starts researching rocket tank------------------------------------");
}
} }
} }
}
if(numberOfHeavyTanks_AI > 5 && theBaseInfo.currentCredit > 1000){ if(numberOfHeavyTanks_AI > 5 && theBaseInfo.currentCredit > 1000){
if(!techCenter.heavyTankResearched_enemy){ if(!techCenter.heavyTankResearched_enemy){
if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){ if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){
techCenter.researchHeavyTank(1); techCenter.researchHeavyTank(1);
System.out.println("----------------------------AI starts researching heavy tank------------------------------------"); System.out.println("----------------------------AI starts researching heavy tank------------------------------------");
}
} }
} }
}
}
}else {
int roll = gameData.getRandom();
if(roll < 612) {
currentProductionOrder = produceLightTank;
}else if(roll >= 612 && roll < 700) {
currentProductionOrder = produceRocketTank;
}else if(roll >= 700 && roll < 900) {
currentProductionOrder = produceStealthTank;
}else {
currentProductionOrder = produceHeavyTank;
}
} }
@ -301,7 +315,8 @@ public class unitProductionAI {
for(int i = 0; i < lightTanksControlledByCombatAI.length; i++){ for(int i = 0; i < lightTanksControlledByCombatAI.length; i++){
if(lightTanksControlledByCombatAI[i] == null || (lightTanksControlledByCombatAI[i] != null && lightTanksControlledByCombatAI[i].currentHP <=0)){ if(lightTanksControlledByCombatAI[i] == null || (lightTanksControlledByCombatAI[i] != null && lightTanksControlledByCombatAI[i].currentHP <=0)){
lightTanksControlledByCombatAI[i] = o; lightTanksControlledByCombatAI[i] = o;
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o); if(mainThread.ec.difficulty > 0)
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o);
break; break;
} }
} }
@ -340,8 +355,8 @@ public class unitProductionAI {
for(int i = 0; i < stealthTanksControlledByCombatAI.length; i++){ for(int i = 0; i < stealthTanksControlledByCombatAI.length; i++){
if(stealthTanksControlledByCombatAI[i] == null || (stealthTanksControlledByCombatAI[i] != null && stealthTanksControlledByCombatAI[i].currentHP <=0)){ if(stealthTanksControlledByCombatAI[i] == null || (stealthTanksControlledByCombatAI[i] != null && stealthTanksControlledByCombatAI[i].currentHP <=0)){
stealthTanksControlledByCombatAI[i] = o; stealthTanksControlledByCombatAI[i] = o;
if(mainThread.ec.difficulty > 0)
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o); mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o);
break; break;
} }
} }