Search in sources :

Example 36 with Unit

use of bwapi.Unit in project BWJSAL by RobinsonMann.

the class UnitsMutexTest method lockUnit_unitPreviouslyLocked_returnsFalse.

@Test
public void lockUnit_unitPreviouslyLocked_returnsFalse() {
    final Unit unit = UnitBuilder.mockUnit();
    assertThat(this.target.isUnitLocked(unit)).as("Sanity test that unit unlocked").isFalse();
    assertThat(this.target.lockUnit(unit)).as("lock acquired").isTrue();
    assertThat(this.target.lockUnit(unit)).as("lock was already acquired").isFalse();
    assertThat(this.target.isUnitLocked(unit)).isTrue();
}
Also used : Unit(bwapi.Unit) Test(org.junit.Test)

Example 37 with Unit

use of bwapi.Unit in project BWJSAL by RobinsonMann.

the class UnitsMutexTest method isUnitLocked_unitIsFree_returnsFalse.

@Test
public void isUnitLocked_unitIsFree_returnsFalse() {
    final Unit unit = UnitBuilder.mockUnit();
    assertThat(this.target.isUnitLocked(unit)).isFalse();
}
Also used : Unit(bwapi.Unit) Test(org.junit.Test)

Example 38 with Unit

use of bwapi.Unit in project BWJSAL by RobinsonMann.

the class EnemyBaseTrackerTest method onUnitDiscover_firstBuildingObservedInsidePossibleEnemyStartingLocation_markBaseLocationAsEnemies.

@Test
public void onUnitDiscover_firstBuildingObservedInsidePossibleEnemyStartingLocation_markBaseLocationAsEnemies() {
    final Unit observedUnit = UnitBuilder.mockUnit(UnitType.Protoss_Pylon, this.mockEnemy);
    replaceUnitTypeWithMock("Protoss_Pylon");
}
Also used : Unit(bwapi.Unit) Test(org.junit.Test)

Example 39 with Unit

use of bwapi.Unit in project BWJSAL by RobinsonMann.

the class EnhancedUi method drawBases.

private void drawBases() {
    for (BaseLocation baseLocation : bwtaWrapper.getBaseLocations()) {
        Position basePosition = baseLocation.getPosition();
        drawUtils.highlightBaseLocation(baseLocation, BASE_BOX_COLOR);
        for (Unit mineral : baseLocation.getMinerals()) {
            drawUtils.highlightMineralField(mineral, MINERAL_CIRCLE_COLOR);
        }
        // Highlight vespene geysers
        for (Unit geyser : baseLocation.getGeysers()) {
            drawUtils.highlightGeyser(geyser, GEYSER_COLOR);
        }
        // Draw a yellow circle around the base location if it is an island expansion
        if (baseLocation.isIsland()) {
            drawUtils.highlightIslandBaseLocation(baseLocation, BASE_ISLAND_COLOR);
        }
    }
}
Also used : Position(bwapi.Position) Unit(bwapi.Unit) BaseLocation(bwta.BaseLocation)

Example 40 with Unit

use of bwapi.Unit in project BWJSAL by RobinsonMann.

the class EnemyBaseTracker method onUnitDestroy.

@Override
public void onUnitDestroy(final Unit destroyedUnit) {
    if (this.game.self().isEnemy(destroyedUnit.getPlayer()) == false) {
        return;
    }
    // If this is an enemy unit we may need to remove a base location
    if (destroyedUnit.getType().isResourceDepot() == false) {
        return;
    }
    final BaseLocation resourceDepotBaseLocation = this.bwta.getNearestBaseLocation(destroyedUnit.getTilePosition());
    if (this.baseLocationToCenter.containsKey(resourceDepotBaseLocation) == false) {
        return;
    }
    final List<Unit> resourceDepotsAtNearestBaseLocation = this.baseLocationToCenter.get(resourceDepotBaseLocation);
    if (resourceDepotsAtNearestBaseLocation.contains(destroyedUnit) == false) {
        return;
    }
    resourceDepotsAtNearestBaseLocation.remove(destroyedUnit);
    if (resourceDepotsAtNearestBaseLocation.isEmpty()) {
        this.enemyBaseLocations.remove(resourceDepotBaseLocation);
    }
}
Also used : Unit(bwapi.Unit) BaseLocation(bwta.BaseLocation)

Aggregations

Unit (bwapi.Unit)73 GameState (ecgberht.GameState)36 Test (org.junit.Test)21 Position (bwapi.Position)14 TilePosition (bwapi.TilePosition)10 BaseLocation (bwta.BaseLocation)7 Pair (bwapi.Pair)6 UnitType (bwapi.UnitType)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Player (bwapi.Player)3 EnemyBuilding (ecgberht.EnemyBuilding)3 RaceUtils.createMockRace (BWJSAL.utils.RaceUtils.createMockRace)2 UnitTypeUtils.mockResourceDepotUnitType (BWJSAL.utils.UnitTypeUtils.mockResourceDepotUnitType)2 Race (bwapi.Race)2 Squad (ecgberht.Squad)2 Game (bwapi.Game)1 UnitCommand (bwapi.UnitCommand)1 Region (bwta.Region)1 Random (java.util.Random)1