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

Drop The Flag Level Help in Backwoods Forest

check this out https://vimeo.com/117966670

2 Likes

I’m also stuck on this level. Got the code to win for me? Please. I use Python.

2 Likes

We do not give out code as a regular policy. This site is meant for you to learn.

Give us more information. Your code, formatted properly. If there is an error, describe it.

3 Likes

HI guys what i got work so use it to look of of your code!:grinning:
[redacted, we don’t post correct code]

2 Likes

Just a tip for those having trouble.

Keep an eye on your capital letters. An X instead of an x or vice versa will ruin your code.

2 Likes

Put flags where you want to build traps.

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

loop:
flag = self.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.)

    var flagPos = flag.pos;
    var fx = flagPos.y;
    var fy = flagPos.y;
    self.buildXY("fire-trap", flagX, flagY)
    self.pickUpFlag(flag)
else:
    item = self.findNearestItem()
    if item:
        itemPos = item.pos
        itemX = itemPos.x
        itemY = itemPos.y
        self.moveXY(itemX, itemY)

I NEED HELP

2 Likes

You don’t say what the problem is…

Does nothing happen, does your hero run in circles, screaming and shouting, does he run to a corner and sit and pout? Please, help us help you.

2 Likes

Also remember to format your code according to the discourse FAQ. And FYI, you used a mixture of python and javascript.

2 Likes

ive been trying to do this level for EVER and i keep hitting my Fire-traps or not getting there in time PLZ help!

2 Likes

Again, what Vlevo said:

You don’t say what the problem is…

Does nothing happen, does your hero run in circles, screaming and shouting, does he run to a corner and sit and pout? Please, help us help you.

Tell us your problem and your code.

2 Likes

I can`t set the flag. There are no icons with flags on the screen. I use javascript. My code
// Поместите флаги в те места, где хотите построить ловушки.
// Когда Вы не строите ловушки, собирайте монеты.

while(true) {
var flag = hero.findFlag();
if (flag) {
// Как можно получить flagX и flagY координаты флага?
// (Внизу показан способ получения х и у координат предмета.)
var flagPos = flag.pos;
var flagX = flagPos.x;
var flagY = flagPos.y;
hero.buildXY(“fire-trap”, flagX, flagY);
hero.pickUpFlag(flag);
}
else {
var item = hero.findNearestItem();
if (item) {
var itemPos = item.pos;
var itemX = itemPos.x;
var itemY = itemPos.y;
hero.moveXY(itemX, itemY);
}
}
}

2 Likes

Tip: remember that you need to press Submit before you can place flags.

3 Likes

can you send me the solution please?

Here on CodeCombat Discourse, we do not post solutions. If you require help, however, you can post your current code and we may be able to help. :slight_smile:

2 Likes

I need help with the mind the trap level:

while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()

if flag:
    # Pick up the flag.
    hero.pickUpFlag(flag)
    hero.say("I should pick up the flag.")
elif enemy:
    # Only attack if the enemy distance is < 10 meters
    if enemy < 10:
        hero.attack(enemy)

this is my current code

Since you didn’t post all of your code in the proper format I can’t really tell if the structure is correct. Next time, please put all if it in the proper format.

Other than that, the elif conditional is incorrect.

if enemy < 10:

if enemy what is less than 10? Did you mean distance? You haven’t defined distance or used it. If everything is inside the while True loop, then just changing this one line is all that’s needed to make it work properly.

1 Like

thankyou!
sorry it wasn’t in the proper format-I am very new to this!!!

what is the “proper format”?

To format your code properly for this board you must copy it from the game (not from here) use the </> button button. Put ALL of your code in between the triple back ticks, not just some of it.

ok thankyou so much!!!