Comments (5)
Solution would be for here to ignore train commands when the unit's training queue is already full.
There may be some fanciness required to accurately handle the case when the front of the queue will finish training prior to latency-delayed command execution, but I imagine the simpler solution is good-enough. Since there's never an advantage to queuing more than 2 units nobody should be harmed by brief prediction errors in that case.
from jbwapi.
Code is identical to https://github.com/bwapi/bwapi/blob/e4a29d73e6021037901da57ceb06e37248760240/bwapi/include/BWAPI/Client/CommandTemp.h#L878
But Java will throw & C++ will just overwrite the next value in memory?
Ignoring those train commands is probably the "fix'
from jbwapi.
Proposed fix:
diff --git a/src/main/java/bwapi/Unit.java b/src/main/java/bwapi/Unit.java
index 821f648..87524ee 100644
--- a/src/main/java/bwapi/Unit.java
+++ b/src/main/java/bwapi/Unit.java
@@ -2116,6 +2116,13 @@ public class Unit implements Comparable<Unit> {
}
if (game.isLatComEnabled()) {
+ // reject training commands when the trainingQueue is full
+ if (command.type == UnitCommandType.Train) {
+ final Integer queueCount = self().trainingQueueCount.get();
+ if (queueCount != null && queueCount >= self().trainingQueue.length) {
+ return false;
+ }
+ }
new CommandTemp(command, game).execute();
}
@ryanleecode can you check if the fix-training-oob branch fixes it for you?
from jbwapi.
Doesn't seem the work the trainingQueueCount
is out of sync (1) with unitData.getTrainingQueueCount()
(5).
from jbwapi.
OK, seems like I was too optimistic
Debugging a bit more it seems like it's a BWAPI Server latcom bug
Game table mapping not found.
Game table mapping not found.
0 | 2572 | 0 | 99881625
1 | 0 | 0 | 0
2 | 0 | 0 | 0
3 | 0 | 0 | 0
4 | 0 | 0 | 0
5 | 0 | 0 | 0
6 | 0 | 0 | 0
7 | 0 | 0 | 0
Connected
Connection successful
added UnitCommand: 15
added UnitCommand: 15
added UnitCommand: 15
added UnitCommand: 15
######## FRAME 1158 ########
getTrainingQueueCount: 0
before: [null, null, null, null, null], null
after: [Terran_SCV, null, null, null, null], 1
added UnitCommand: 4
training worker: 1
trainingQueue: [Terran_SCV]
######## FRAME 1159 ########
getTrainingQueueCount: 1
before: [Terran_SCV, null, null, null, null], 1
after: [Terran_SCV, Terran_SCV, null, null, null], 1
added UnitCommand: 4
training worker: 2
trainingQueue: [Terran_SCV, Terran_SCV]
######## FRAME 1160 ########
getTrainingQueueCount: 3
before: [Terran_SCV, Terran_SCV, null, null, null], 1
after: [Terran_SCV, Terran_SCV, null, Terran_SCV, null], 1
added UnitCommand: 4
training worker: 3
trainingQueue: [Terran_SCV, Terran_SCV, null, Terran_SCV]
######## FRAME 1161 ########
getTrainingQueueCount: 4
before: [Terran_SCV, Terran_SCV, null, Terran_SCV, null], 1
after: [Terran_SCV, Terran_SCV, null, Terran_SCV, Terran_SCV], 1
added UnitCommand: 4
training worker: 4
trainingQueue: [Terran_SCV, Terran_SCV, null, Terran_SCV, Terran_SCV]
######## FRAME 1162 ########
getTrainingQueueCount: 5
before: [Terran_SCV, Terran_SCV, null, Terran_SCV, Terran_SCV], 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at bwapi.CommandTemp.execute(CommandTemp.java:729)
at bwapi.CommandTemp.execute(CommandTemp.java:43)
at bwapi.Unit.issueCommand(Unit.java:2126)
at bwapi.Unit.train(Unit.java:2238)
at game.TrainingQueueTest.onFrame(TrainingQueueTest.java:40)
at bwapi.EventHandler.operation(EventHandler.java:29)
at bwapi.Client.update(Client.java:269)
at bwapi.BWClient.startGame(BWClient.java:56)
at bwapi.BWClient.startGame(BWClient.java:35)
at game.TrainingQueueTest.<init>(TrainingQueueTest.java:16)
at game.TrainingQueueTest.main(TrainingQueueTest.java:50)
Process finished with exit code 1
the unitData.getTrainingQueueCount()
skips from 1 to 3 for some reason
getTrainingQueueCount: 1
getTrainingQueueCount: 3
With latcom
disabled, this bug does not occur
@N00byEdge any ideas where this could happen?
from jbwapi.
Related Issues (20)
- Renders wrong colors HOT 2
- Game::drawTextScreen(): StringIndexOutOfBoundsException HOT 5
- Crashes in init on playing a replay HOT 1
- Unique identifier for units HOT 5
- [Java9+] sun.nio.ch not visible HOT 2
- (Probably) Leaking memory in WrappedBuffer::Memory allocation HOT 1
- Color should be a flyweight object HOT 1
- Unit.getInterceptors (and maybe getLarva) runs slowly HOT 3
- Game can't issue grouped commands
- Give client bots a handler for pipe disconnection HOT 1
- Update StaticBuilding methods to public HOT 6
- Test all major platforms
- CI Improvements
- twice Comman Issue Unit.Train in command center HOT 6
- Documentation for drawTextMap lacking in regards to adding color
- Investigate BWEM issue with "New Popular Fastest Map"
- Update badges in README.md
- canBuildHere mineral vs depot check is not correct
- Add LastError to Game
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jbwapi.