Skip to content
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

Equivalent for BWAPI C++'s UnitFilter? #90

Open
adakitesystems opened this issue Nov 17, 2018 · 1 comment
Open

Equivalent for BWAPI C++'s UnitFilter? #90

adakitesystems opened this issue Nov 17, 2018 · 1 comment
Labels
discussion missing A feature is absent from BWAPI4J but not the original C++ BWAPI.

Comments

@adakitesystems
Copy link
Collaborator

Thanks to @SonkoMagnus for mentioning the lack of BWAPI C++'s UnitFilter equivalent in BWAPI4J. Example:

Unit supplyBuilder = 
  u->getClosestUnit(GetType == supplyProviderType.whatBuilds().first 
    && (IsIdle || IsGatheringMinerals) 
    && IsOwned);

where getClosestUnit is declared as:

Unit UnitInterface::getClosestUnit(const UnitFilter &pred, int radius) const

As per @SonkoMagnus's suggestion, we could use Predicate as the equivalent.

@adakitesystems adakitesystems added missing A feature is absent from BWAPI4J but not the original C++ BWAPI. discussion labels Nov 17, 2018
@Bytekeeper
Copy link
Collaborator

Another option would be Stream style:

Unit supplyBuilder = u.unitsSortedByDistance()
    .filter(u -> u.isIdle() || u.isGatheringMinerals)
    .first()

Where unitsSortedByDistance could also take a maxRadius parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion missing A feature is absent from BWAPI4J but not the original C++ BWAPI.
Projects
None yet
Development

No branches or pull requests

2 participants