# You must escort a powerful magical ring back to town to be studied.
# The goal is to escape, not fight. More ogres lurk in the surrounding mountains!
# Make a circle of soldiers around the peasant!
# We give you two functions to help with this:
# findSoldierOffset figures out the position a soldier should stand at in relation to the peasant.
# The first argument 'soldiers' should be an array of your soldiers.
# The second argument 'i' is the index of the soldier (in soldiers) you want to find the position for.
def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)
return radialToCartesian(5, angle)
# This function does the math to determine the offset a soldier should stand at.
def radialToCartesian(radius, degrees):
radians = Math.PI / 180 * degrees
xOffset = radius * Math.cos(radians)
yOffset = radius * Math.sin(radians)
return {"x": xOffset, "y": yOffset}
peasant = self.findByType("peasant")[0]
self.findByType("soldier")
loop:
for soldier in soldier:
def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)
return radialToCartesian(5, angle)
moveTo = {x: peasant.pos.x + offset.x, y: peasant.pos.y + offset.y}
self.command(soldier, "move", moveTo)
# The hero should keep pace with the peasant!
self.move({"x": self.pos.x + .3, "y": self.pos.y})

what am i doing wrong? the soldiers donâ€™t move until Hectorâ€™s dead.

# You must escort a powerful magical ring back to town to be studied.
# The goal is to escape, not fight. More ogres lurk in the surrounding mountains!
# Make a circle of soldiers around the peasant!
# We give you two functions to help with this:
# findSoldierOffset figures out the position a soldier should stand at in relation to the peasant.
# The first argument 'soldiers' should be an array of your soldiers.
# The second argument 'i' is the index of the soldier (in soldiers) you want to find the position for.
def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)
return radialToCartesian(5, angle)
# This function does the math to determine the offset a soldier should stand at.
def radialToCartesian(radius, degrees):
radians = Math.PI / 180 * degrees
xOffset = radius * Math.cos(radians)
yOffset = radius * Math.sin(radians)
return {"x": xOffset, "y": yOffset}
peasant = self.findByType("peasant")[0]
self.findByType("soldier")
loop:
for i in range(0, len(soldiers)):
offset = findSoldierOffset(soldiers, i)
moveTo = {x: peasant.pos.x + offset.x, y: peasant.pos.y + offset.y}
self.command(soldier, "move", moveTo)
# The hero should keep pace with the peasant!
self.move({"x": self.pos.x + .3, "y": self.pos.y})

# You must escort a powerful magical ring back to town to be studied.
# The goal is to escape, not fight. More ogres lurk in the surrounding mountains!
# Make a circle of soldiers around the peasant!
# We give you two functions to help with this:
# findSoldierOffset figures out the position a soldier should stand at in relation to the peasant.
# The first argument 'soldiers' should be an array of your soldiers.
# The second argument 'i' is the index of the soldier (in soldiers) you want to find the position for.
def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)
return radialToCartesian(5, angle)
# This function does the math to determine the offset a soldier should stand at.
def radialToCartesian(radius, degrees):
radians = Math.PI / 180 * degrees
xOffset = radius * Math.cos(radians)
yOffset = radius * Math.sin(radians)
return {"x": xOffset, "y": yOffset}
peasant = self.findByType("peasant")[0]
loop:
self.findByType("soldier")
for soldier in soldier:
offset = findSoldierOffset(soldiers, i)
moveTo = {x: peasant.pos.x + offset.x, y: peasant.pos.y + offset.y}
self.command(soldier, "move", moveTo)
# The hero should keep pace with the peasant!
self.move({"x": self.pos.x + .3, "y": self.pos.y})

Got it, thanks! In an ideal world, weâ€™d split up codeLanguage and spokenLanguage in the guides, too, so we could get any code snippets right in all languages, but it adds a lot of complication to the translations and the code for that, so we have been trying to make fairly code-language-ambiguous guides so far.

soldiers = this.findByType("soldiers");
// Use findByType to get an array of your soldiers.
loop {
// Use a for-loop to iterate over your array of soldiers.
for(i=0;i<soldiers.length;i++){
offset = this.findSoldierOffset(soldiers,i);
offset.x = offset.x +peasant.pos.x;
offset.y = offset.y +peasant.pos.y;
this.command(soldiers[i], "move",offset);
}

function findSoldierOffset(soldiers, i) {
var soldier = soldiers[i];
var angle = i * 360 / soldiers.length;
return radialToCartesian(5, angle);
}
// This function does the math to determine the offset a soldier should stand at.
function radialToCartesian(radius, degrees) {
var radians = Math.PI / 180 * degrees;
var xOffset = radius * Math.cos(radians);
var yOffset = radius * Math.sin(radians);
return {x: xOffset, y: yOffset};
}
var peasant = this.findByType("peasant");
soldiers = this.findByType("soldiers");
// Use findByType to get an array of your soldiers.
loop {
// Use a for-loop to iterate over your array of soldiers.
for(i=0;i<soldiers.length;i++){
offset = this.findSoldierOffset(soldiers,i);
this.say(offset);
offset.x = offset.x +peasant.pos.x;
offset.y = offset.y +peasant.pos.y;
this.command(soldiers[i], "move",offset);
}
// Find the offset for a soldier.
// Add the offset.x and offset.y to the peasant's pos.x and pos.y.
// Command the soldier to move to the new offset position.
// The hero should keep pace with the peasant!
this.move({x: this.pos.x + 0.2, y: this.pos.y});
}

This is the whole code and pikanaw description is also correct.

Hmm, could it be the say? Donâ€™t use say here after youâ€™re done using it to debug. It takes one second, so your code will be delayed instead of running every frame.