Sowing Fire help

Hello!I have a bit weird problem in this level.My hero detonates the first column after building it.
My code:

# Цель: построй три ряда из 9 ловушек.

# Возвращает "retreat", "attack", "start-next-trap-column" или "build-next-trap-in-column"
def chooseStrategy():
    enemies = hero.findEnemies()
    
    # В случае превосходящих сил противника верни "retreat" (отступление).
    if len(enemies) > 20:
        return "retreat"
    
    # Если есть несколько огров, верни "attack" (атаковать).
    if len(enemies) > 0:
        return 'attack'
    # Сравни `x % 9` с 0, чтобы проверить делимость x на 9.
    # Используй `len(self.built)` для определения количества построенных ловуше.
    # Если ты закончил колонку из 9 ловушек, верни "start-next-trap-column" (начать новую колонку).
    if len(self.built) % 9 == 0:
        return 'start-next-trap-column'
    # Иначе верни "build-next-trap-in-column" (построить следующую ловушку в ряду).
    else:
        return "build-next-trap-in-column"

trapsInColumn = 9
startX = 40
columnX = startX

# Построй следующую ловушку в ряду на правильном месте.
def buildNextTrapInColumn(columnX,numTraps):
    # Измени `newY` на использование `%`, чтобы зациклиться и строить `trapsInColumn` (9) ловушек в ряду.
    newY = 7 * (numTraps % 9) + 10 # ∆ Измени это, используя `% 9`!
    if hero.pos.y > newY:
        hero.move({"x": columnX - 5, "y": newY})
    else:
        buildTrap(columnX,newY)

# Начни новую колонку ловушек.
def startNextTrapColumn(columnX, numTraps):
    newX = startX - (Math.floor(numTraps / trapsInColumn) * 6)
    if hero.pos.y > 10:
        hero.move({"x": newX - 5, "y": 10})
        return columnX
    else:
        buildTrap(newX,10)
        return newX

def buildTrap(x, y):
    hero.buildXY("fire-trap", x, y)

def commandAttack():
    # Пусть твои всадники на гриффинах отгонят атакующих.
    griffins = hero.findByType("griffin-rider")
    enemy = hero.findNearestEnemy()
    for griffin in griffins:
        hero.command(griffin, "attack", enemy)
    pass

def commandRetreat():
    hero.say("Retreat!")
    # Ты вместе со всадниками отступаешь в безопасную область за ловушками.
    hero.moveXY(4, 42)

while True:
    strategy = chooseStrategy()
    if strategy == "attack":
        commandAttack()
    elif strategy == "build-next-trap-in-column":
        buildNextTrapInColumn(columnX, len(hero.built))
    elif strategy == "start-next-trap-column":
        columnX = startNextTrapColumn(columnX, len(hero.built))
    elif strategy == "retreat":
        commandRetreat()
1 Like

Can you send a link?
Lydia

https://codecombat.com/play/level/sowing-fire?

1 Like

Sorry, I can’t help, it is a subscriber level.
Lydia

1 Like

It’s ok, don’t worry.:slight_smile:

1 Like

What is your gear for this level?

What does it mean ‘gear’.

Your items, like your armor, weapons, rings, stuff like that. Can you take a screenshot, or if yo can’t then write them down.

Ok, here:

You need better glasses, your glasses are the Hardened Steel Glasses if I am not wrong. Those glasses do not have the ability hero.findEnemies(). You need to get glasses that have this ability.

1 Like

I put on the glasses, that have this ability, but nothing changed.

try getting the infinite range glasses?

I put on exactly them.

hmm dat aint right try asking @Support

in this case @ryan or the other customer support specalist

How to ask them?Can I ask them here?

sure just @ them like this @cheddarcheese then tell them your problem

just do @ stephanie or @ ryan but without the spaces

I see now, I tested your code, and the same thing happened to me, it goes finishes one column, and then heads back down and fails right?

@Anonym, I think this part is wrong. I think that the > is supposed to be a < symbol.

2 Likes