Skip to content

Commit

Permalink
Merge pull request #234 from merfolk/worker-rush-refactoring
Browse files Browse the repository at this point in the history
Use do_actions in WorkerRushBot
  • Loading branch information
tweakimp committed Feb 17, 2019
2 parents dd3e7b4 + 0a779f1 commit 608bd25
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/worker_rush.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import sc2
from sc2 import run_game, maps, Race, Difficulty
from sc2 import run_game, maps, Race, Difficulty, BotAI
from sc2.player import Bot, Computer

class WorkerRushBot(sc2.BotAI):
class WorkerRushBot(BotAI):
def __init__(self):
super().__init__()
self.actions = []

async def on_step(self, iteration):
self.actions = []

if iteration == 0:
target = self.enemy_start_locations[0]

for worker in self.workers:
await self.do(worker.attack(self.enemy_start_locations[0]))
self.actions.append(worker.attack(target))

await self.do_actions(self.actions)

def main():
run_game(maps.get("Abyssal Reef LE"), [
Expand Down

0 comments on commit 608bd25

Please sign in to comment.