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,6 +620,8 @@ 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){
if(mainThread.ec.difficulty > 0) {
//stop chasing player unit if it has got out of sight //stop chasing player unit if it has got out of sight
if(team[i].targetObject != null && team[i].targetObject.currentHP >0) { 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; int targetPositionIndex = (int)(team[i].targetObject.centre.x*64)/16 + (127 - (int)(team[i].targetObject.centre.z*64)/16)*128;
@ -666,6 +663,11 @@ public class combatManagerAI {
team[i].secondaryCommand = solidObject.attackMove; team[i].secondaryCommand = solidObject.attackMove;
} }
}else {
team[i].attackMoveTo(attackPosition.x, attackPosition.z);
team[i].currentCommand = 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,6 +80,7 @@ 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(mainThread.ec.difficulty == 2) {
if(frameAI >= 450 && mainThread.ec.theCombatManagerAI.checkIfAIHasBiggerForce(0.8f)) { if(frameAI >= 450 && mainThread.ec.theCombatManagerAI.checkIfAIHasBiggerForce(0.8f)) {
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
if(observers[i] == null || observers[i].currentHP <=0) { if(observers[i] == null || observers[i].currentHP <=0) {
@ -174,6 +175,7 @@ public class defenseManagerAI {
} }
} }
}
//send units to deal with minor threat on the map if there is any //send units to deal with minor threat on the map if there is any
vector mainPlayerForceLocation = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation; vector mainPlayerForceLocation = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation;

View File

@ -105,6 +105,7 @@ public class enemyCommander {
} }
if(mainThread.gameFrame % 30 == 3){ if(mainThread.gameFrame % 30 == 3){
if(difficulty > 0)
theScoutingManagerAI.processAI(); theScoutingManagerAI.processAI();
} }
@ -121,16 +122,18 @@ public class enemyCommander {
} }
if(mainThread.gameFrame % 30 == 7){ if(mainThread.gameFrame % 30 == 7){
if(difficulty > 0)
theDefenseManagerAI.processAI(); 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,6 +147,7 @@ public class unitProductionAI {
} }
if(mainThread.ec.difficulty > 0) {
//make decision on what unit to produce //make decision on what unit to produce
int numberOfPlayerGunTurrets= mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player; int numberOfPlayerGunTurrets= mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player;
int numberOfPlayerMissileTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player; int numberOfPlayerMissileTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player;
@ -194,7 +195,7 @@ public class unitProductionAI {
} }
//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){
@ -204,7 +205,7 @@ public class unitProductionAI {
} }
} }
if(mainThread.ec.theEconomyManagerAI.numberOfharvesters >= 6 && theBaseInfo.currentCredit > 1500) { if(mainThread.ec.theEconomyManagerAI.numberOfharvesters >= 6 && theBaseInfo.currentCredit > 1500 && mainThread.ec.difficulty > 1) {
if(!communicationCenter.harvesterSpeedResearched_enemy) { if(!communicationCenter.harvesterSpeedResearched_enemy) {
if(communicationCenter.harvesterSpeedResearchProgress_enemy == 255){ if(communicationCenter.harvesterSpeedResearchProgress_enemy == 255){
communicationCenter.researchHarvesterSpeed(1); communicationCenter.researchHarvesterSpeed(1);
@ -256,6 +257,19 @@ public class unitProductionAI {
} }
}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;
}
}
for(int i = 0; i < mainThread.theAssetManager.factories.length; i++){ for(int i = 0; i < mainThread.theAssetManager.factories.length; i++){
@ -301,6 +315,7 @@ 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;
if(mainThread.ec.difficulty > 0)
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o); mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o);
break; break;
} }
@ -340,7 +355,7 @@ 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;
} }