var coin=this.findNearest(this.findItems());
if (coin) {
this.move(coin.pos); }
if (this.gold > this.costOf("soldier")) {
this.summon("soldier");
}
var enemy = this.findNearest(this.findEnemies());
if (enemy) {
var soldiers = this.findFriends();
var soldierIndex = 0;
while (soldierIndex<soldiers.length) {
var soldier = soldiers[soldierIndex];
this.command(soldier, "attack", enemy);
soldierIndex++;
}
}
Please post your code( formatted properly ) onto your post and explain what you’ve already tried what’s happening in more detail and any other things that happened when you ran the program e.g. errors or freezing so that people can help you.
Thank you
Look carefully the code in the first post. The solution of your problem is there. You don’t need multiple topics with the same question - delete the other post. ( hero = this )