New Level: Deadly Pursuit

Check out Deadly Pursuit! More flag practice, but this time basically from scratch. The goal is to collect all the coins, but prevent the ogres from slaying your hero after you’ve finished. We have a few things that need to be cleaned up here, but it’s playable and we would be really interested to hear what people thing. Is it intuitive when you need to place the flags? Are you getting any weird errors?

it is strange that my hero sometimes place a fire-trap then pick up the flag, but sometimes just pick up the flag without building a fire-trap. anyone encounter the same problem?
Does hero need to be ready to build a fire-trap?

I solved this. just let my “find-item” function appear along with the the “find-flag” function. then, do the next steps.

So many flags to be placed, Is it right? Too much?

我已经堵住所有的路,并收集所有宝石,但游戏并没有过关,提示运行超时
I have blocked all the way, and to collect all the gems, but the game did not pass, prompt operation timeout

我无法过这一关。
I can’t pass this pass.

不需要住所有的路,只要看哪儿有敌人,就把 flag 放在那人。
You don’t need to place flags everywhere; just put them down whenever you seen an enemy coming down that path.

亲,可以帮我过关吗,我的账号密码是1681cc qwezzc
Dear, can you help me to pass, I account password is 1681cc qwezzc

这关的对象如此之多,浏览器都快卡死
This objects so many,my browsers going to die.

放栅栏非常容易把英雄卡在敌人的那边
Put a fence is very easy to push the hero on the enemy’s side

就算我做好步骤,还是不过关
Even if I done good job steps, did not pass

不要放栅栏,要放"fire-trap"就好。
Build “fire-trap” instead of “fence”.

Can anyone tell me why I have a bad code, very new to coding so can’t figure it out, especially as it works and I have completed the level??

We have to fix this bug with the level–sometimes there is no item at the end, so reading item.pos fails (with a bad error message). You would probably want elif item: instead of else:.

Thanks, makes me feel a whole lot better :slight_smile:

I don’t understand what you mean by "let the ‘find-item’ function appear along with the ‘find-flag’ function. Could you please explain? I am having the same problem, where sometimes the hero places a trap where the flag was and sometimes it doesn’t.

hey guys i need some help with my code, the automated item picking up works before i place the traps, but after i place a single trap it stops going back to the coins automatically, is there a problem with my code?

loop {
    flag = this.findFlag();
    item = this.findNearestItem();
    if (flag) {
       this.findFlag("green");
        fx = flag.pos.x;
        fy = flag.pos.y;
        this.buildXY("fire-trap", fx, fy);
        
    }
    else if (item) {
        this.findNearestItem();
        var pos = item.pos;
        var x = pos.x;
        var y = pos.y;
        this.moveXY(x, y);     
    }
}

Instead of this.findFlag("green");, you probably want to pick up the flag instead.

thanks nick, after I seen what you said I figured out that you would want to pick up the flag and move on rather then just find the flag and stay next to it, really helped thankyou :smile:

Hi, am new to code please i need help in this stage —deadly pursuit— have tried all in coding this level , i don’t know what is wrong

if flag:
        fx = flag.pos.x
        fy = flag.pos.x
        self.buildXY("fire-trap", fx, fy)
        self.pickUpFlag(flag)
    elif item:
        a = item.pos.x
        b = item.pos.x
        self.moveXY(a, b)

It looks like your if and elif aren’t lined up, and you don’t have loop:, or an assignment of flag = self.findNearestFlag() or item = self.findNearestItem(). (Maybe you have those parts, but they are not in your code?)

You also assigned fy = flag.pos.x when it should be flag.pos.y. Typos like that can be hard to figure out! Same for the item pos.

1 Like

you are realy Good and thanks , is working, Am hoping to be like you… thanks again…

please i also dont know what is wrong with my new code in the stage of Rich Forager:

loop:
    flag = self.findFlag()
    enemy = self.findNearestEnemy()
    item = self.findNearestItem()
    if flag:
        # What happens when I find a flag?
        fx = flag.pos.x
        fy = flag.pos.y
        self.pickUpFlag(flag)
    elif enemy:
        # What happens when I find an enemy?
        self.attack(enemy)
        self.attack(enemy)
    elif item:
        # <item %>
        pos = item.pos
        a = pos.x
        b = pos.y
        self.moveXY(a, b)

please i need help i dont know what i mix

please i need your help i dont know what am doing wrong

loop:
    flag = self.findFlag()
    enemy = self.findNearestEnemy()
    item = self.findNearestItem()
    if flag:
        # What happens when I find a flag?
        self.pickUpFlag(flag)
        
    elif enemy:
        # What happens when I find an enemy? 
        self.attack(enemy)
        
    elif item:
        # <item %>
        pos = item.pos
        a = pos.x
        b = pos.y
        self.moveXY(a, b)

@Txoni_de_Olatxu What is going wrong with the first version you posted in Rich Forager? It looks like if you hit submit to place flags, your guy will move to them, so you can use that to go through and clear out the various areas in the level.