Problem in Level: return to thorn bush farm (Backwoods Forest)

After I built a fence at the top entrance to block the master outside, another villager come from the road and was killed by the monster… If I don’t block the road, villager inside will die, if I block it, villager outside will die…What should I do?

You shouldnt be blocking in that level, you should be using fire-traps

# Patrol the village entrances.
# Build a "fire-trap" when you see an ogre.
# Don't blow up any peasants

these comments were in my section in the code they gave me

1 Like

Thx, man. I didn’t notice the difference between fence and fire-trap.

please help, i have been stuck for 2 days

while True:
    hero.moveXY(43, 50)
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.buildXY("fire-trap", 43, 50)
    else:
        hero.moveXY(25, 34)
    hero.moveXY(25, 34)
    if enemy:
        hero.buildXY("arrow-tower", 25, 34)
    else:
        hero.moveXY(43, 20)
    hero.moveXY(43, 20)
    if enemy:
        hero.buildXY("fire-trap", 43, 20)
    else:
        hero.moveXY(43, 50)
    hero.moveXY(43, 50)

Try restarting the level and following the comments. It works for me when I follow the comments.
Lydia

1 Like

my hero dosent build the fire trap at the top

def maybeBuildTrap(x, y):
    # Use x and y as the coordinates to move to.
    hero.moveXY(x, y)
    enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()
if enemy:
    # Use buildXY to build a “fire-trap” at the given x and y.
    hero.buildXY("fire-trap", x, y)
while True:
    # This calls maybeBuildTrap, with the coordinates of the top entrance.
    maybeBuildTrap(43, 50)
    # Now use maybeBuildTrap at the left entrance!
    maybeBuildTrap(25, 35)
    # Now use maybeBuildTrap at the bottom entrance!
    maybeBuildTrap(42, 20)

i dont build arrow towers

MidnightWolf39

4m

What if you don’t have enough for an arrow-tower?
im not building arrow-towers

You need to put the if statement inside the def maybeBuildTrap(x, y):
And you don’t need this, delete it.

[quote=“cheddarcheese, post:8, topic:8169”]

enemy = hero.findNearestEnemy()

Lydia

thanks @Lydia_Song (20 chars)

though it still dosent work

Just indent the “if” and delete the extra “hero.findNearestEnemy”
Lydia

thanks, @Lydia_Song (20 chars)

1 Like

your awesome i completed the level you can put [SOLVED] now

1 Like