Help level: Zoo keeper


#1

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);
        }
    }
}

#2

Please read the FAQ before posting. I added the ``` before and after your code this time…

Please help us help you by telling us what happens when you run/submit it?


#3

you didn’t identify what gold is.


#4
this.command(friend, "move", point.pos);

You need a {x,y} structure which is point. point.pos is not even defined


#5

This post is over nine months old. Would you think that if this person had not solved this problem, he would not have continued posting? Keep the dead resting.