Apologies, but I’m going to dump my full code here. I can’t tell what’s happening - I’m freezing before the first 4 are summoned. [Update: I reloaded the level completely, recoded it (in some slightly different ways) and won. Sigh. Still no clue what went wrong with the below.
# Protect the cage.
# Put a soldier at each X.
points = []
points[0] = {"x": 33, "y": 42}
points[1] = {"x": 47, "y": 42}
points[2] = {"x": 33, "y": 26}
points[3] = {"x": 47, "y": 26}
# 1. Collect 80 gold.
while self.gold < 80:
coin = self.findNearest(self.findByType("coin"))
if coin:
self.move(coin.pos)
# 2. Build 4 soldiers.
countX = 0
while countX < 4:
if self.gold > self.costOf("soldier"):
self.summon("soldier")
countX = countX + 1
# 3. Send your soldiers into position.
loop:
friends = self.findByType("soldier", self.findFriends())
PtCounter = 0
counter = 0
while counter < len(friends):
point = points[PtCounter]
friend = friends[counter]
self.command(friend,"move",point)
counter = counter + 1
PtCounter = PtCounter + 1
if PtCounter > 3:
PtCounter = 0
counter = 0
friends = self.findByType("soldier", self.findFriends())
while counter < len(friends):
friend = friends[counter]
enemy = friend.findNearestEnemy()
if enemy:
if enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
# Command friend to attack.
self.command(friend, "attack", enemy)
coinCount = self.gold
while coinCount = self.gold:
coin = self.findNearest(self.findbyType("coin")
if coin:
self.move(coin.pos)
else:
coinCount = coinCount - 1
if self.gold > self.costOf("soldier"):
self.summon("soldier")