-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't find same function in bwapi4j as unit.getplayer() in bwapi #89
Comments
Hi, @RoySRose! If I understand your situation correctly, your team was using BWMirror before? Currently, BWAPI4J's API is very different from BWMirror and converting a BWMirror bot to BWAPI4J could be a lot of work depending on the size of your bot's codebase. BWAPI4J has a lot of typesafe features. For example, the BWAPI4J/BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/UnitImpl.java Lines 258 to 260 in 733e173
PlayerUnit seen here... BWAPI4J/BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/PlayerUnitImpl.java Lines 124 to 126 in 733e173
We don't have a guide to port a bot from BWMirror to BWAPI4J. Lots of functionality has just been divided into separate classes such as a BWAPI4J/BWAPI4J/src/test/java/bwem/TestListenerBwem.java Lines 60 to 68 in 733e173
This approach has received mixed feedback. Some people prefer the typesafe features; others not. Because of this, I have been working on refactoring BWAPI4J so its API is much closer to BWMirror and porting a bot from BWMirror to BWAPI4J should be much easier. However, I don't have an estimated completion date as I am the only one working on it currently. To summarize, there are a few options:
I hope this helps. Happy coding! |
if (unit instanceof PlayerUnit) {
PlayerUnit playerUnit = (PlayerUnit) unit;
Player player = playerUnit.getPlayer();
} |
For option 3 from @adakitesystems suggestions, you can look at https://github.com/JasperGeurtz/VioletLily/tree/master/src/main/org/openbw/bwapi4j (shameless plug). |
Hello, @adakitesystems @JasperGeurtz Thank you both for kind answer. But since
I'll definitely take a closer look at BWAPI4J this weekend.
import org.openbw.bwapi4j.DefaultBWListener;
import org.openbw.bwapi4j.Game;
import org.openbw.bwapi4j.InteractionHandler;
import org.openbw.bwapi4j.Mirror;
Love to contribute to BWAPI4J too, If we get the chance. |
1,2) A (terran) good bot written using BWAPI4J is Jabbo's: https://github.com/Jabbo16/Ecgberht bwem = new BWEM(bw);
bwem.initialize();
bwem.getMap().assignStartingLocationsToSuitableBases(); Regions from BWTA are Area's in BWEM, for the rest they are pretty similar |
@JasperGeurtz, Thank you for so much information! You've saved a lot of my time:) |
I've started converting.
Any Ideas? |
if (unit instanceof PlayerUnit) {
PlayerUnit playerUnit = (PlayerUnit) unit;
Player player = playerUnit.getPlayer();
}
else {
//unit is neutral like Mineral, Geyser, Blocking Building etc.
}
I invite you to the BWAPI4J discord: https://discord.gg/QbMdnQJ as Adakite suggested if there are more questions! |
My team already has a bot with all the dependencies to BWAPI
We are kind of rebooting the project and found your project.
Glad to see the updates for bwapi4.2.
I was trying to convert the code to meet API of BWAPI4J.
I couldn't find any method that does the same thing as Unit.getplayer() in BWAPI.
Am I missing something?
---added---
import bwapi.DefaultBWListener;
import bwapi.Game;
import bwapi.Mirror;
couldn't find any replacements for this too. is there any guide that I can take a look to get started?
The text was updated successfully, but these errors were encountered: