Fixed Base AI not working sometimes
This commit is contained in:
@@ -12,10 +12,8 @@ import mindustry.game.*;
|
|||||||
import mindustry.game.Schematic.*;
|
import mindustry.game.Schematic.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.maps.generators.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.defense.*;
|
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
import mindustry.world.blocks.production.*;
|
import mindustry.world.blocks.production.*;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
@@ -35,7 +33,7 @@ public class BaseBuilderAI{
|
|||||||
private static int correct = 0, incorrect = 0;
|
private static int correct = 0, incorrect = 0;
|
||||||
|
|
||||||
private int lastX, lastY, lastW, lastH;
|
private int lastX, lastY, lastW, lastH;
|
||||||
private boolean triedWalls, foundPath;
|
private boolean foundPath;
|
||||||
|
|
||||||
final TeamData data;
|
final TeamData data;
|
||||||
final Interval timer = new Interval(4);
|
final Interval timer = new Interval(4);
|
||||||
@@ -46,7 +44,6 @@ public class BaseBuilderAI{
|
|||||||
boolean calculating, startedCalculating;
|
boolean calculating, startedCalculating;
|
||||||
int calcCount = 0;
|
int calcCount = 0;
|
||||||
int totalCalcs = 0;
|
int totalCalcs = 0;
|
||||||
Block wallType;
|
|
||||||
|
|
||||||
public BaseBuilderAI(TeamData data){
|
public BaseBuilderAI(TeamData data){
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@@ -62,10 +59,6 @@ public class BaseBuilderAI{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wallType == null){
|
|
||||||
wallType = BaseGenerator.getDifficultyWall(1, data.team.rules().buildAiTier / 0.8f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 6f) && data.hasCore()){
|
if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 6f) && data.hasCore()){
|
||||||
CoreBlock block = (CoreBlock)data.core().block;
|
CoreBlock block = (CoreBlock)data.core().block;
|
||||||
int coreUnits = data.countType(block.unitType);
|
int coreUnits = data.countType(block.unitType);
|
||||||
@@ -104,8 +97,8 @@ public class BaseBuilderAI{
|
|||||||
}else{
|
}else{
|
||||||
var field = pathfinder.getField(data.team, Pathfinder.costGround, Pathfinder.fieldCore);
|
var field = pathfinder.getField(data.team, Pathfinder.costGround, Pathfinder.fieldCore);
|
||||||
|
|
||||||
if(field.weights != null){
|
if(field.hasCompleteWeights()){
|
||||||
int[] weights = field.weights;
|
int[] weights = field.completeWeights;
|
||||||
for(int i = 0; i < pathStep; i++){
|
for(int i = 0; i < pathStep; i++){
|
||||||
int minCost = Integer.MAX_VALUE;
|
int minCost = Integer.MAX_VALUE;
|
||||||
int cx = calcTile.x, cy = calcTile.y;
|
int cx = calcTile.x, cy = calcTile.y;
|
||||||
@@ -154,12 +147,7 @@ public class BaseBuilderAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//only schedule when there's something to build.
|
//only schedule when there's something to build.
|
||||||
if(foundPath && data.plans.isEmpty() && timer.get(timerStep, Mathf.lerp(placeIntervalMin, placeIntervalMax, data.team.rules().buildAiTier))){
|
if((foundPath || (!calculating && !foundPath)) && data.plans.isEmpty() && timer.get(timerStep, Mathf.lerp(placeIntervalMin, placeIntervalMax, data.team.rules().buildAiTier))){
|
||||||
//TODO walls are silly, no walls
|
|
||||||
//if(!triedWalls){
|
|
||||||
// tryWalls();
|
|
||||||
// triedWalls = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
for(int i = 0; i < attempts; i++){
|
for(int i = 0; i < attempts; i++){
|
||||||
int range = 150;
|
int range = 150;
|
||||||
@@ -279,47 +267,6 @@ public class BaseBuilderAI{
|
|||||||
lastW = result.width + 2;
|
lastW = result.width + 2;
|
||||||
lastH = result.height + 2;
|
lastH = result.height + 2;
|
||||||
|
|
||||||
triedWalls = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryWalls(){
|
|
||||||
Block wall = wallType;
|
|
||||||
Building spawnt = state.rules.defaultTeam.core() != null ? state.rules.defaultTeam.core() : data.team.core();
|
|
||||||
Tile spawn = spawnt == null ? null : spawnt.tile;
|
|
||||||
|
|
||||||
if(spawn == null) return;
|
|
||||||
|
|
||||||
for(int wx = lastX; wx <= lastX + lastW; wx++){
|
|
||||||
outer:
|
|
||||||
for(int wy = lastY; wy <= lastY + lastH; wy++){
|
|
||||||
Tile tile = world.tile(wx, wy);
|
|
||||||
|
|
||||||
if(tile == null || !tile.block().alwaysReplace) continue;
|
|
||||||
|
|
||||||
boolean any = false;
|
|
||||||
|
|
||||||
for(Point2 p : Geometry.d8){
|
|
||||||
if(Angles.angleDist(Angles.angle(p.x, p.y), spawn.angleTo(tile)) > 70){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile o = world.tile(tile.x + p.x, tile.y + p.y);
|
|
||||||
if(o != null && (o.block() instanceof PayloadBlock || o.block() instanceof PayloadConveyor || o.block() instanceof ShockMine)){
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(o != null && o.team() == data.team && !(o.block() instanceof Wall)){
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpTiles.clear();
|
|
||||||
if(any && Build.validPlace(wall, data.team, tile.x, tile.y, 0) && !tile.getLinkedTilesAs(wall, tmpTiles).contains(t -> path.contains(t.pos()))){
|
|
||||||
data.plans.add(new BlockPlan(tile.x, tile.y, (short)0, wall.id, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -522,6 +522,10 @@ public class Pathfinder implements Runnable{
|
|||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasCompleteWeights(){
|
||||||
|
return hasComplete && completeWeights != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateTargetPositions(){
|
public void updateTargetPositions(){
|
||||||
targets.clear();
|
targets.clear();
|
||||||
getPositions(targets);
|
getPositions(targets);
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
if(bloom != null){
|
if(bloom != null){
|
||||||
bloom.resize(graphics.getWidth(), graphics.getHeight());
|
bloom.resize(graphics.getWidth(), graphics.getHeight());
|
||||||
bloom.setBloomIntesity(settings.getInt("bloomintensity", 6) / 4f + 1f);
|
bloom.setBloomIntensity(settings.getInt("bloomintensity", 6) / 4f + 1f);
|
||||||
bloom.blurPasses = settings.getInt("bloomblur", 1);
|
bloom.blurPasses = settings.getInt("bloomblur", 1);
|
||||||
Draw.draw(Layer.bullet - 0.02f, bloom::capture);
|
Draw.draw(Layer.bullet - 0.02f, bloom::capture);
|
||||||
Draw.draw(Layer.effect + 0.02f, bloom::render);
|
Draw.draw(Layer.effect + 0.02f, bloom::render);
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=d8cd7a6003
|
archash=6433d83dbd
|
||||||
|
|||||||
Reference in New Issue
Block a user