anarchid / zkgbai Goto Github PK
View Code? Open in Web Editor NEWZero-K Graph-Based AI
License: GNU General Public License v2.0
Zero-K Graph-Based AI
License: GNU General Public License v2.0
[f=0068025] <SkirmishAI: ZKGBAI (team 5)>: exception(java.lang.NullPointerException
at zkgbai.kgbutil.Pathfinder.findPath(Pathfinder.java:96)
at zkgbai.military.fighterhandlers.RetreatHandler.retreatCowards(RetreatHandler.java:117)
at zkgbai.military.fighterhandlers.RetreatHandler.update(RetreatHandler.java:76)
at zkgbai.military.MilitaryManager.update(MilitaryManager.java:1233)
at zkgbai.ZKGraphBasedAI.update(ZKGraphBasedAI.java:250)
) java.lang.NullPointerException
After spawning, saying glhf, analyzing the map, parsing the json metalmap message, and merging all its commanders, the AI attempts no further actions. There are no exceptions in infolog. I didnt check kgbdebug
. This is an engine compatibility and not a game compatibility issue, because same game version on older engine works.
Circuit doesn't seem to have this problem so it's likely some kind of a logical change.
Hello again, I hope you don't mind the issue spam.
diff --git a/build.xml b/build.xml
index 17ff208..9bc5ced 100644
--- a/build.xml
+++ b/build.xml
@@ -41,15 +41,10 @@
</target>
<target name="install" depends="dist">
- <exec executable="mkdir">
- <arg value="-p"/>
- <arg value="${installDir}"/>
- </exec>
- <exec executable="cp">
- <arg value="-r"/>
- <arg value="${dist}/"/>
- <arg value="${installDir}"/>
- </exec>
+ <mkdir dir="${installDir}" />
+ <copy overwrite="true" todir="${installDir}">
+ <fileset dir="${dist}/" />
+ </copy>
</target>
<target name="clean"
Pretty much what title says. Sometimes it begins to lag at the very start, but always at the end of match.
AI is (10af1d0) built from source by javac 1.7.0_91
JRE is openjdk 7
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.2) (7u91-2.6.2-1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
Hardware is 2.3 ghz 8-core i7.
After I added the new porc algorithm suddenly everything broke horribly. After a thorough investigation I found out that graphmanager started shifting metal spots around randomly, causing mexes to be placed off center and other shenanigans. The only thing I changed in graph manager was to add getMexes() (a one liner), which I wasn't using originally when it started breaking. It doesn't throw errors consistently, but sometimes it shows array out of bounds.
I've got a few exceptions (about 4 more like these), I thought they worth a new issue.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: ZK boxes detected
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: LosManager initialized.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Detected 130 metal spots in GRP
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: GraphManager initialized.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: EconomyManager initialized.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: MilitaryManager initialized.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: FactoryManager initialized.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Large Map Detected: Enabling Air Starts.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Checking Veh Pathability..
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Path Check Failed: unreachable mexes.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Average Relative Path Cost: 1.4227375
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Checking Hover Pathability..
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Path Check Failed: unreachable mexes.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Average Relative Path Cost: 1.4432367
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Checking Bot Pathability..
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Average Relative Path Cost: 1.4145821
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Path Check Failed: high path costs.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Checking Spider Pathability..
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Average Relative Path Cost: 1.1526521
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Terrain Analysis: Spider path check succeeded, enabling spiders and jumps!
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Selected Commander: Zweihander level 0.
[f=0000000] <SkirmishAI: ZKGBAI 0.5 (team 1)>: Start Position Selected!
...
[f=0034187] game_message: Reaper is under attack
[f=0034337] game_message: Reaper is under attack
[f=0034487] game_message: Reaper is under attack
[f=0034638] game_message: Banisher is under attack
[f=0035218] game_message: Reaper is under attack
[f=0035940] <SkirmishAI: ZKGBAI 0.5 (team 1)>: exception(java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.IntegerInterleavedRaster.getDataElements(Unknown Source)
at java.awt.image.BufferedImage.getRGB(Unknown Source)
at zkgbai.military.MilitaryManager.getEffectiveThreat(MilitaryManager.java:275)
at zkgbai.military.MilitaryManager.assignRaiders(MilitaryManager.java:369)
at zkgbai.military.MilitaryManager.update(MilitaryManager.java:908)
at zkgbai.ZKGraphBasedAI.update(ZKGraphBasedAI.java:201)
) java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
[f=0035955] <SkirmishAI: ZKGBAI 0.5 (team 1)>: exception(java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.IntegerInterleavedRaster.getDataElements(Unknown Source)
at java.awt.image.BufferedImage.getRGB(Unknown Source)
at zkgbai.military.MilitaryManager.getEffectiveThreat(MilitaryManager.java:275)
at zkgbai.military.MilitaryManager.assignRaiders(MilitaryManager.java:369)
at zkgbai.military.MilitaryManager.update(MilitaryManager.java:908)
at zkgbai.ZKGraphBasedAI.update(ZKGraphBasedAI.java:201)
) java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
...
Quite a long time ago, ZK renamed all of its units to something more consistent. This, of course, breaks the ai.
A C# tool was written to mass-replace those: https://pastebin.com/RqnQXjyy
A CSV containing a map of previous names to new ones exists: https://cdn.discordapp.com/attachments/278908415756206080/339723824243408898/internalrename_toconvert2.csv
Somebody did a code review of kgb. See #ai for more info.
[19:55] bky: I did a code review of a piece of it as essentially a training exercise.
[19:56] bky: One of the things I noticed is a pattern that will make it randomly crash on some JVMs.
[19:57] bky: Line 310-315 of MilitaryManager
[19:59] bky: join() can experience interrupts from the JVM rather than a user thread.
[19:59] bky: This trips a System.exit(-1) to intentionally crash the AI
[20:03] Sprung: @Anarchid ^
[20:05] bky: I don't know what the fix should be because I don't know why it's intentionally crashing.
[20:06] bky: But it'd involve conditionally retrying the join().
[20:16] Sprung:
boolean ok = false;
while (!ok) {
try {
thread.join();
ok = true;
} catch (InterruptedException e) {
// ignore, JVM is just being a dolt
} catch (Exception e) {
// something more brutal happened
ai.printException(e);
System.exit(-1);
}
}
[20:16] Sprung: something like this presumably
[20:16] bky: yeah
[20:17] bky: There's also a separate concurrency issue if the AI experiences 15 frames of lag before the join() succeeds.
[20:18] bky: Potentially.
[20:18] bky: You might have two simultaneously running invocations of the same method fighting over the same threatmap.
[20:19] bky: I can't tell whether that actually happens without knowing whether the Module superclass tries to handle severe lag by not updating on some frames.
When the commander is destroyed and all storage is lost, the AI starts building a lot of generators. This is probably because it sees that the energy storage has gone to zero. So it will keep overcommitting resources to generators, until it will eventually lose the game.
What it should do instead is build some storage, probably even before the commander is killed.
the new startbox inference fix requires a StartBox class which was not included in any of your commits, which has left kgb uncompilable.
might be unrelated, but 3 humans vs 2 circuit + 2 zkgb => window freeze when com plopp should be, infolog attached.
KGB seems to try Picket pushing where the Pickets can't actually fire at their targets:
It also really, really wants to finish Pickets, even if this costs it their commander:
KGB apparently calculates line of sight shadows for other attacks. I'm not sure how to add this here, though.
http://zero-k.info/Battles/Detail/427877
At 10th minute air player's (zkgb 0.8.1) cons stuck at non-reclaimable features.
Map Zed 2.2 is suitable for tests - has non-reclaimable features around mex spots.
Log:
% ant dist
Buildfile: /home/user/tmp/spring/zkgbai-build/zkgbai2/build.xml
init:
[mkdir] Created dir: /home/user/tmp/spring/zkgbai-build/zkgbai2/build
compile:
[javac] /home/user/tmp/spring/zkgbai-build/zkgbai2/build.xml:23: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 88 source files to /home/user/tmp/spring/zkgbai-build/zkgbai2/build
[javac] /home/user/tmp/spring/zkgbai-build/zkgbai2/src/zkgbai/kgbutil/Pathfinder.java:14: warning: Bool is internal proprietary API and may be removed in a future release
[javac] import com.sun.org.apache.xpath.internal.operations.Bool;
[javac] ^
[javac] /home/user/tmp/spring/zkgbai-build/zkgbai2/src/zkgbai/ZKStartLocation.java:13: error: cannot find symbol
[javac] public class ZKStartLocation extends StartArea {
[javac] ^
[javac] symbol: class StartArea
[javac] /home/user/tmp/spring/zkgbai-build/zkgbai2/src/zkgbai/ZKStartLocation.java:22: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /home/user/tmp/spring/zkgbai-build/zkgbai2/src/zkgbai/ZKStartLocation.java:32: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] Note: /home/user/tmp/spring/zkgbai-build/zkgbai2/src/zkgbai/graph/GraphManager.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 3 errors
[javac] 1 warning
BUILD FAILED
/home/user/tmp/spring/zkgbai-build/zkgbai2/build.xml:23: Compile failed; see the compiler error output for details.
Total time: 1 second
Hello!
compile:
[javac] F:\projects\zkgbai\build.xml:23: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 82 source files to F:\projects\zkgbai\build
[javac] F:\projects\zkgbai\src\zkgbai\gui\AdditiveComposite.java:16: error: as of release 9, '_' is a keyword, and may not be used as an identifier
[javac] public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints _) {
[javac] ^
[javac] 1 error
After replacing _
with __
here things are find and compiling.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.