what wrong with my code:
// Protect the cage.
// Put a soldier at each X.
var points = []; //mang array
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 (this.gold < 80) {
var coint = this.findNearest(this.findItems());
if (coint) {
this.move(coint.pos);
}
}
// 2. Build 4 soldiers.
for(var i=0; i < 4; i++) {
this.summon("soldier");
}
// 3. Send your soldiers into position.
loop {
var friends = this.findFriends();
for(var j=0; j < friends.length; j++) {
var point = points[j];
var friend = friends[j];
var enemy = friend.findNearestEnemy();
if(enemy && enemy.team == "ogres" && friend.distanceTo(enemy) < 5) {
// Command friend to attack.
this.command(friend, "attack", enemy);
} else {
// Command friend to move to point.
this.command(friend, "move", point.pos);
}
}
}