new commit
This commit is contained in:
parent
800090bbcc
commit
d5bded151e
1
core/.gitignore
vendored
1
core/.gitignore
vendored
@ -18,4 +18,3 @@
|
||||
/textRenderer.class
|
||||
/texture.class
|
||||
/vector.class
|
||||
/mainThread$MathOperation.class
|
||||
|
@ -54,6 +54,7 @@ public class grid {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -496,7 +496,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
|
||||
while(System.currentTimeMillis()-lastDraw<frameInterval){
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
sleepTime++;
|
||||
sleepTime++;
|
||||
} catch (InterruptedException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
|
@ -49,7 +49,7 @@ public class polygon3D {
|
||||
public solidObject parentObject;
|
||||
|
||||
//A pool of vectors which will be used for vector arithmetic
|
||||
public static vector
|
||||
public vector
|
||||
tempVector1 = new vector(0,0,0),
|
||||
tempVector2 = new vector(0,0,0),
|
||||
tempVector3 = new vector(0,0,0),
|
||||
@ -83,7 +83,7 @@ public class polygon3D {
|
||||
public byte[] diffuse = new byte[3];
|
||||
|
||||
//default light source
|
||||
public static vector lightDirection = sunLight.lightDirection;
|
||||
public vector lightDirection = sunLight.lightDirection;
|
||||
|
||||
//the color of polygon if it is defined as soild
|
||||
public int color;
|
||||
|
@ -107,6 +107,8 @@ public class defenseManagerAI {
|
||||
}
|
||||
}
|
||||
|
||||
//go through all the player units on the mini map and deal with them accordingly
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class enemyCommander {
|
||||
thinkHardLikeHumanPlayer();
|
||||
|
||||
|
||||
//drawVisionMap();
|
||||
drawVisionMap();
|
||||
|
||||
//reset tempBitmap;
|
||||
for(int i = 0 ;i < tempBitmap.length; i++){
|
||||
|
@ -5,6 +5,7 @@ import core.baseInfo;
|
||||
import core.mainThread;
|
||||
import entity.goldMine;
|
||||
import entity.solidObject;
|
||||
import core.vector;
|
||||
|
||||
//1. scan revealed area for player's units and building
|
||||
//2. keep track of player's units
|
||||
@ -55,6 +56,12 @@ public class mapAwarenessAI {
|
||||
public int[] playerExpensionInfo;
|
||||
public int numberOfplayerMiningBases;
|
||||
|
||||
public vector mainPlayerForceLocation;
|
||||
public vector mainPlayerForceDirection;
|
||||
public int mainPlayerForceSize;
|
||||
public vector[] playerForceLocations;
|
||||
public vector[] playerForceDirections;
|
||||
public int[] playerForceSize;
|
||||
|
||||
public mapAwarenessAI(baseInfo theBaseInfo, boolean[] visionMap){
|
||||
this.theBaseInfo = theBaseInfo;
|
||||
@ -67,6 +74,20 @@ public class mapAwarenessAI {
|
||||
|
||||
goldMines = mainThread.theAssetManager.goldMines;
|
||||
playerExpensionInfo = new int[goldMines.length];
|
||||
|
||||
mainPlayerForceLocation = new vector(0,0,0);
|
||||
mainPlayerForceDirection = new vector(0,0,0);
|
||||
mainPlayerForceSize = 0;
|
||||
playerForceLocations = new vector[3];
|
||||
playerForceDirections = new vector[3];
|
||||
playerForceSize = new int[3];
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
playerForceLocations[i] = new vector(0,0,0);
|
||||
playerForceDirections[i] = new vector(0,0,0);
|
||||
playerForceSize[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void processAI(){
|
||||
@ -386,6 +407,8 @@ public class mapAwarenessAI {
|
||||
|
||||
|
||||
findTheMostVulnerablePlayerBase();
|
||||
|
||||
findPlayerForceLocation();
|
||||
|
||||
}
|
||||
|
||||
@ -510,6 +533,60 @@ public class mapAwarenessAI {
|
||||
|
||||
return playexpensionDefenseScore;
|
||||
}
|
||||
|
||||
//find the center of the biggest cluster of player units that are visible on the minimap. It will tells the AI which area is in danger of being attacked.
|
||||
public void findPlayerForceLocation(){
|
||||
mainPlayerForceLocation.set(0,0,0);
|
||||
mainPlayerForceDirection.set(0,0,0);
|
||||
mainPlayerForceSize = 0;
|
||||
|
||||
for(int i = 0; i < playerForceLocations.length; i++) {
|
||||
playerForceLocations[i].set(0,0,0);
|
||||
playerForceDirections[i].set(0,0,0);
|
||||
playerForceSize[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
if(numberOfPlayerUnitsOnMinimap < 5)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < playerUnitInMinimap.length; i++) {
|
||||
if(playerUnitInMinimap[i] == null)
|
||||
continue;
|
||||
float xPos = playerUnitInMinimap[i].centre.x;
|
||||
float zPos = playerUnitInMinimap[i].centre.z;
|
||||
|
||||
for(int j = 0; j < playerForceLocations.length; j++) {
|
||||
//always add the player unit location to the empty list
|
||||
if(playerForceLocations[j].x == 0) {
|
||||
playerForceLocations[j].add(playerUnitInMinimap[i].centre);
|
||||
playerForceSize[j]++;
|
||||
playerForceDirections[j].add(playerUnitInMinimap[i].movement);
|
||||
break;
|
||||
}
|
||||
float centerX = playerForceLocations[j].x/playerForceSize[j];
|
||||
float centerZ = playerForceLocations[j].z/playerForceSize[j];
|
||||
float d = (centerX - xPos) * (centerX - xPos) + (centerZ - zPos) * (centerZ - zPos);
|
||||
//if the player unit is close enough to the force center then add it to the list
|
||||
if(d < 4) {
|
||||
playerForceLocations[j].add(playerUnitInMinimap[i].centre);
|
||||
playerForceSize[j]++;
|
||||
playerForceDirections[j].add(playerUnitInMinimap[i].movement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < playerForceLocations.length; i++) {
|
||||
if(playerForceSize[i] > mainPlayerForceSize) {
|
||||
mainPlayerForceSize = playerForceSize[i];
|
||||
mainPlayerForceLocation.set(playerForceLocations[i].x/mainPlayerForceSize,0,playerForceLocations[i].z/mainPlayerForceSize);
|
||||
mainPlayerForceDirection.set(playerForceDirections[i].x/mainPlayerForceSize, 0, playerForceDirections[i].z/mainPlayerForceSize);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(mainPlayerForceSize + " " + mainPlayerForceLocation + " " + mainPlayerForceDirection);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class unitProductionAI {
|
||||
public void processAI(){
|
||||
frameAI++;
|
||||
|
||||
//set the rally point to near the construction yard which is closest to the player's starting position
|
||||
//set the rally point to near the construction yard which is closest to the AI player's starting position
|
||||
float x = 0;
|
||||
float z = 999999;
|
||||
|
||||
@ -81,7 +81,7 @@ public class unitProductionAI {
|
||||
for(int i = 0; i < mainThread.theAssetManager.constructionYards.length; i++){
|
||||
if(mainThread.theAssetManager.constructionYards[i] != null && mainThread.theAssetManager.constructionYards[i].currentHP > 0 && mainThread.theAssetManager.constructionYards[i].teamNo != 0){
|
||||
index = i;
|
||||
if(mainThread.theAssetManager.constructionYards[i].centre.z < z && mainThread.theAssetManager.constructionYards[i].centre.z > 5 && mainThread.theAssetManager.constructionYards[i].centre.x > 5){
|
||||
if(mainThread.theAssetManager.constructionYards[i].centre.z < z && mainThread.theAssetManager.constructionYards[i].centre.z > 7 && mainThread.theAssetManager.constructionYards[i].centre.x > 7){
|
||||
x = mainThread.theAssetManager.constructionYards[i].centre.x;
|
||||
z = mainThread.theAssetManager.constructionYards[i].centre.z;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user