Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Snowdrops: Cloudrip Mountain

It’s probably simple I just can’t think of this last part for if it = 0.

for (var i = 0; i < cells.length; i++) {
var row = cells[i].row;
var col = cells[i].col;
// If row is less than forestMap length:
if (row < forestMap.length) {

    // If col is less than forestMap[row] length:
    if (col < forestMap[row].length) {
        // Now, we know the cell exists.
        // If it is 0, say where to shoot:
        hero.say(row + " " + col);


Greetings @brotherofall,

Is this all of your code? I do not see where you’ve defined the cells array.



Hi, I see what you have here.
Remember in the previous levels that teach you about grids? At the start of the code, there is an array, and what is special about it? Answer, it’s an array of which each element is another array or an array of arrays!
Below is the long answer, if you want a short answer, check TL;DR.

Long answer

Now the way to represent an array is as follows: arrayForLife[5], so let us represent it as a variable: var array4Life5 = arrayForLife[5]. So that is an element in an array. But remember, each individual element is another array. So if we want to find the 1st element in array4Life5, the code will be array4Life5[0], and since array4Life5 = arrayForLife[5], it means array4Life5[0] is equal to arrayForLife[5][0]! If we plug that into your code, your hero should say hero.say(row + " " + col); only if (forestMap[row][col] === 0) (remember if you want to check if a value is equal to 0 (and also true, false, and null), you need to use ‘strictly equals to’ or ‘===’).


The way to represent an array in another array is arrayArrayArray[arrayIndex1][arrayIndex2], so your hero should say hero.say(row + " " + col); only if (forestMap[row][col] === 0.

Hopefully this has been helpful to you.

1 Like

Thanks for explaining it. I solved it. I was thinking about the problem in the wrong perspective.

1 Like
# Summon some soldiers, then direct them to your base.

# Each soldier costs 20 gold.
if > hero.costOf("soldier"):
soldiers = hero.findFriends()
soldierIndex = 0
# Add a while loop to command all the soldiers.
while soldierIndex < len(soldiers):
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soldierIndex += 1

# Go join your comrades!
hero.moveXY(51, 41)

I need help is there anything wrong with the code? The problem is that my hero only summons one soldier and run to the X. Never mind, I restarted and it worked :slightly_smiling_face: :upside_down_face: