Skip to content

Commit

Permalink
Merge pull request Dentosal#103 from Dentosal/develop
Browse files Browse the repository at this point in the history
Add already_pending for upgrades
Fix cost of zerg structures and building morph cost - this should fix self.can_afford()
Add headless linux tests
Add comments and mypy type checking
Update maps to latest sc2 season mappool
Make mass reaper example expand once
  • Loading branch information
BurnySc2 authored Aug 1, 2018
2 parents efb7e52 + c0067ad commit 207d4f6
Show file tree
Hide file tree
Showing 25 changed files with 606 additions and 402 deletions.
32 changes: 14 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
language: python

# sudo false implies containerized builds
sudo: false
sudo: required

# python 3.7 not yet available on linux
python:
- 3.6
language: python

# add the cloned directory to python path
env: PYTHONPATH=$PYTHONPATH:$TRAVIS_BUILD_DIR
services:
- docker

# install libraries needed to run
install:
- pip install s2clientprotocol async-timeout portpicker websockets aiohttp
before_install:
# Debugging
- echo Current path
- pwd
- echo Project dir contents
- ls
# Build docker image
- docker build -t test_image -f test/Dockerfile .

# run my unit tests
script:
python test/test_position.py
script:
python test/test_unit.py
script:
python test/test_units.py
# Run tests
- docker run test_image -c "python test/travis_test_script.py test/test_bot.py"
2 changes: 1 addition & 1 deletion examples/protoss/cannon_rush.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def on_step(self, iteration):
break

def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Protoss, CannonRushBot()),
Computer(Race.Protoss, Difficulty.Medium)
], realtime=False)
Expand Down
2 changes: 1 addition & 1 deletion examples/protoss/threebase_voidray.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def on_step(self, iteration):
await self.do(sg.train(VOIDRAY))

def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Protoss, ThreebaseVoidrayBot()),
Computer(Race.Protoss, Difficulty.Easy)
], realtime=False)
Expand Down
2 changes: 1 addition & 1 deletion examples/protoss/warpgate_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def on_step(self, iteration):


def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Protoss, WarpGateBot()),
Computer(Race.Protoss, Difficulty.Easy)
], realtime=False)
Expand Down
2 changes: 1 addition & 1 deletion examples/terran/cyclone_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def on_step(self, iteration):
await self.do(scv.gather(self.state.mineral_field.closest_to(cc)))

def main():
sc2.run_game(sc2.maps.get("Sequencer LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
# Human(Race.Terran),
Bot(Race.Terran, ProxyRaxBot()),
Computer(Race.Zerg, Difficulty.Easy)
Expand Down
19 changes: 17 additions & 2 deletions examples/terran/mass_reaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,25 @@ async def on_step(self, iteration):
self.combinedActions.append(depot(AbilityId.MORPH_SUPPLYDEPOT_LOWER))

# morph commandcenter to orbitalcommand
if self.units(UnitTypeId.BARRACKS).ready.exists and self.can_afford(UnitTypeId.BARRACKS): # we dont check if we can afford because the price for morphing units was/is bugged - doesn't work with "await self.do()"
if self.units(UnitTypeId.BARRACKS).ready.exists and self.can_afford(UnitTypeId.ORBITALCOMMAND): # check if orbital is affordable
for cc in self.units(UnitTypeId.COMMANDCENTER).idle: # .idle filters idle command centers
self.combinedActions.append(cc(AbilityId.UPGRADETOORBITAL_ORBITALCOMMAND))

# expand if we can afford and have less than 2 bases
if 1 <= self.townhalls.amount < 2 and self.already_pending(UnitTypeId.COMMANDCENTER) == 0 and self.can_afford(UnitTypeId.COMMANDCENTER):
# get_next_expansion returns the center of the mineral fields of the next nearby expansion
next_expo = await self.get_next_expansion()
# from the center of mineral fields, we need to find a valid place to place the command center
location = await self.find_placement(UnitTypeId.COMMANDCENTER, next_expo, placement_step=1)
if location:
# now we "select" (or choose) the nearest worker to that found location
w = self.select_build_worker(location)
if w and self.can_afford(UnitTypeId.COMMANDCENTER):
# the worker will be commanded to build the command center
error = await self.do(w.build(UnitTypeId.COMMANDCENTER, location))
if error:
print(error)

# make up to 4 barracks if we can afford them
# check if we have a supply depot (tech requirement) before trying to make barracks
if self.units.of_type([UnitTypeId.SUPPLYDEPOT, UnitTypeId.SUPPLYDEPOTLOWERED, UnitTypeId.SUPPLYDEPOTDROP]).ready.exists and self.units(UnitTypeId.BARRACKS).amount + self.already_pending(UnitTypeId.BARRACKS) < 4 and self.can_afford(UnitTypeId.BARRACKS):
Expand Down Expand Up @@ -117,7 +132,7 @@ async def on_step(self, iteration):
enemyGroundUnitsInGrenadeRange = self.known_enemy_units.not_structure.not_flying.exclude_type([UnitTypeId.LARVA, UnitTypeId.EGG]).closer_than(reaperGrenadeRange, r)
if enemyGroundUnitsInGrenadeRange.exists and (r.is_attacking or r.is_moving):
# if AbilityId.KD8CHARGE_KD8CHARGE in abilities, we check that to see if the reaper grenade is off cooldown
abilities = await self.get_available_abilities(r)
abilities = (await self.get_available_abilities(r))
enemyGroundUnitsInGrenadeRange = enemyGroundUnitsInGrenadeRange.sorted(lambda x: x.distance_to(r), reverse=True)
furthestEnemy = None
for enemy in enemyGroundUnitsInGrenadeRange:
Expand Down
2 changes: 1 addition & 1 deletion examples/terran/onebase_battlecruiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def on_step(self, iteration):
await self.do(scv.gather(self.state.mineral_field.closest_to(cc)))

def main():
sc2.run_game(sc2.maps.get("Sequencer LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
# Human(Race.Terran),
Bot(Race.Terran, ProxyRaxBot()),
Computer(Race.Zerg, Difficulty.Hard)
Expand Down
2 changes: 1 addition & 1 deletion examples/terran/proxy_rax.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def on_step(self, iteration):
self.attack_groups.remove(ac)

def main():
sc2.run_game(sc2.maps.get("Sequencer LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Terran, ProxyRaxBot()),
Computer(Race.Zerg, Difficulty.Hard)
], realtime=False)
Expand Down
2 changes: 1 addition & 1 deletion examples/zerg/hydralisk_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def on_step(self, iteration):
await self.do(larvae.random.train(ZERGLING))

def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Zerg, Hydralisk()),
Computer(Race.Terran, Difficulty.Medium)
], realtime=False, save_replay_as="ZvT.SC2Replay")
Expand Down
2 changes: 1 addition & 1 deletion examples/zerg/onebase_broodlord.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def on_step(self, iteration):
await self.do(larvae.random.train(ZERGLING))

def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Zerg, BroodlordBot()),
Computer(Race.Terran, Difficulty.Medium)
], realtime=False, save_replay_as="ZvT.SC2Replay")
Expand Down
2 changes: 1 addition & 1 deletion examples/zerg/zerg_rush.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def on_step(self, iteration):
self.queeen_started = True

def main():
sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
Bot(Race.Zerg, ZergRushBot()),
Computer(Race.Terran, Difficulty.Medium)
], realtime=False, save_replay_as="ZvT.SC2Replay")
Expand Down
Loading

0 comments on commit 207d4f6

Please sign in to comment.