My code finds coins and summons soldiers perfectly, but the commanding is on the fritz. If I put a self.say(“test”) below my command-to-attack line, it runs, so it’s apparently noticing the enemies and getting down to that part of the code ( I initially thought this was a problem with detecting enemies), but my guys appear to be not listening to me. Where am I going wrong?
loop: # Move to the nearest coin. # Use move instead of moveXY so you can command constantly. coin = self.findNearest(self.findItems()) self.move(coin.pos) # If you have funds for a soldier, summon one. if self.gold > self.costOf("soldier"): self.summon("soldier") enemy = self.findNearest(self.findEnemies()) if enemy: # Loop over all your soldiers and order them to attack. soldiers = self.findFriends() soldierIndex = 0 soldier = soldiers[soldierIndex] while soldierIndex < len(soldiers): # Use the 'attack' command to make your soldiers attack. self.command(soldier, "attack", enemy) soldierIndex = soldierIndex+1