AI in custom game attack mode

This commit is contained in:
Anuken 2020-06-16 16:04:25 -04:00
parent d1de976dc4
commit a7ca632c09
4 changed files with 26 additions and 4 deletions

View File

@ -10,10 +10,12 @@ import mindustry.content.*;
import mindustry.game.*;
import mindustry.game.Schematic.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.defense.*;
import mindustry.world.blocks.production.*;
import mindustry.world.blocks.storage.*;
import static mindustry.Vars.*;
@ -23,6 +25,7 @@ public class BaseAI{
private static final float step = 5;
private static final int attempts = 5;
private static final float emptyChance = 0.01f;
private final static int timerStep = 0, timerSpawn = 1;
private static int correct = 0, incorrect = 0;
@ -30,16 +33,27 @@ public class BaseAI{
private boolean triedWalls;
TeamData data;
Interval timer = new Interval();
Interval timer = new Interval(4);
public BaseAI(TeamData data){
this.data = data;
}
public void update(){
if(timer.get(timerSpawn, 60) && data.hasCore()){
CoreBlock block = (CoreBlock)data.core().block;
//create AI core unit
if(!Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){
Unitc unit = block.unitType.create(data.team);
unit.set(data.core());
unit.add();
Fx.spawn.at(unit);
}
}
//only schedule when there's something to build.
if(data.blocks.isEmpty() && timer.get(step)){
if(data.blocks.isEmpty() && timer.get(timerStep, step)){
if(!triedWalls){
tryWalls();
triedWalls = true;

View File

@ -487,6 +487,10 @@ public class UnitTypes implements ContentList{
}};
alpha = new UnitType("alpha"){{
//TODO maybe these should be changed
defaultController = BuilderAI::new;
isCounted = false;
flying = true;
mineSpeed = 2f;
buildSpeed = 0.5f;
@ -513,7 +517,7 @@ public class UnitTypes implements ContentList{
lifetime = 60f;
shootEffect = Fx.shootSmall;
smokeEffect = Fx.shootSmallSmoke;
tileDamageMultiplier = 0.15f;
tileDamageMultiplier = 0.1f;
}};
}});
}};

View File

@ -21,6 +21,10 @@ public enum Gamemode{
rules.attackMode = true;
rules.waves = true;
rules.waveTimer = true;
rules.waveSpacing /= 2f;
rules.teams.get(rules.waveTeam).ai = true;
rules.teams.get(rules.waveTeam).infiniteResources = true;
}, map -> map.teams.contains(state.rules.waveTeam.id)),
pvp(rules -> {
rules.pvp = true;

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=662afc44313c42b637f9cfd9d21da7f280b27d65
archash=30796daec8eba235f9cde3723537431df4e4f6f5