Help/level/glacier/binary-deployment


#1

`// Recruit soldiers and archers to fill out each squadron.
// Each paladin has a decimal number stored in her deployment attribute.
// Convert these to binary and represent them with line soldiers and archers next to each paladin.
// Soldiers are 0s, archers are 1s.
// For the bonus goal, add griffins as 2s for trinary number lines next to the warlocks.
// Check the guide for help with binary numbers.
this.paladins = this.findByType(“paladin”, this.findFriends());
//this.say(this.paladins.length);
for (var i = 0; i < this.paladins.length; i++) {
var line = this.paladins[i].deployment.toString(2);
for (var j = 0; j < line.length; j++) {
if (line[j] == “0”) {
this.summon(“soldier”);
} else {
this.summon(“archer”);
}
var friend = this.built[this.built.length - 1];
this.command(friend, “move”, {
x: this.paladins[i].pos.x + 8 + 8 * j,
y: this.paladins[i].pos.y
});
}
}

`


#2

Each Paladin needs 8 units, and the binary number 20 is: 10100, so you are missing 3 units in that line. (Same for the line at the top)


#3

FYI, remember to format your code. You can learn how by going to the discourse FAQ.