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

Drop The Flag Level Help in Backwoods Forest

Put flags where you want to build traps.

When you’re not building traps, pick up coins!

while True:
flag = hero.findFlag()
if flag:
# How do we get flagX and flagY from the flag’s pos?
# (Look below at how to get x and y from items.)

    hero.buildXY("fire-trap", flagX, flagY)
    hero.pickUpFlag(flag)
else:
    item = hero.findNearestItem()
    if item:
        itemPos = item.pos
        itemX = itemPos.x
        itemY = itemPos.y
        hero.moveXY(itemX, itemY)

there an issue i cant get pass this level im stumped!!!

Don’t forget to define flagX and flagY.

1 Like

Please send me the answer! I still can’t get this! The hero is not responding to the flags the way I want!!! Please help!

Post the code you have so far and people here will be happy to help you. Be sure to post using the </> button.

# Put flags where you want to build traps.
# When you're not building traps, pick up coins!

while True:
    flag = hero.findFlag()
    if flag:
        # How do we get flagX and flagY from the flag's pos?
        # (Look below at how to get x and y from items.)
        flag = hero.findFlag("green")
        hero.buildXY("fire-trap", flagX, flagY)
        hero.pickUpFlag(flag)
    else:
        item = hero.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            hero.moveXY(itemX, itemY)

HELLLLPPPPP PLEASE! I need this!!!1

Immediately after your conditional if flag: statement; you have defined the variable, flag, a second time. This second assignment is unnecessary and should be removed. Also, look at the way you have defined itemX and itemY . Do you think it might be a good idea to do this for flagX and flagY as well?

1 Like

I think the level has a flaw. If you are sufficiently fast you have no need to build anything and to win without fighting. When possible I don’t use flag except in rare occasions. So I rewrote the level in coffee-script and in midway to finish it I saw the screen:


I had passed the level normally long time ago.

There are other levels where you can achieve success with just a line or two of code. There are other levels where flags can be used where they are not intended and it makes for an easy way to complete the level. Yes, it allows the completion of the level, but the point of the lesson is missed. One only cheats oneself if done this way.

Wow, I posted this 4 years ago and people are still commenting.
Didn’t really expect anyone to still be playing this to be totally honest.

1 Like

More and more people are playing
This ought to be the most ongoing topic since the ice age.

MunkeyShynes has the right of it – the game is mostly about teaching, but you can beat most levels in lots of different ways.

1 Like

I mean if you cheat, what’s the point of doing coding? Nobody, even Albert Einstein won’t learn if he cheats. :wink:

1 Like

Albert Einstein is the creator of the famous equations which made atomic bombs, or, put it another way, he made atomic bombs.

Adding that to the level I have no idea how to save progress in and adding thangs.

OFC I know Albert Einstein. I’m just saying that he won’t learn if he cheats.

1 Like

I need help

Line 9 you have the variable name “flag.Pos”, but when you use the variable you are missing the “.”.

Please don’t use a topic made 4 years ago for your issue. Next Time make another topic

:fox_face::fox_face::fox_face:
-@Luke10

@Luke10. Necroposting is ok as long as the post is relevant to the current thread. Necroposting is actually better than bunch of topics with the same thing.

I did this and it aint working