Hunters and Prey serious bug

Are you copying the code from above in this thread, or are you copying from the editor inside the game? It should show up if you copy from inside the game.

Oh?

give me a sec
OK

# Ogres are trying to kill your reindeer!
# Keep your archers back while summoning soldiers to attack.
def pickUpCoin():
    # Collect coins.
    items = self.findItems()
    nearestCoin = self.findNearest(items)
    if nearestCoin:
        self.move(nearestCoin.pos)
    pass
def summonTroops():
    # Summon soldiers if you have the gold.
    if self.costOf("soldier")<self.gold:
        self.summon("soldier")
        pass
# This function has an argument named soldier.
# Arguments are like variables.
# The value of an argument is determined when the function is called.
def commandSoldier(soldier):
    # Soldiers should attack enemies.
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)
    pass
# Write a commandArcher function to tell your archers what to do!
# It should take one argument that will represent the archer passed to the function when it's called.
# Archers should only attack enemies who are closer than 25 meters, otherwise, stay still.
def commandarcher(archer):
    enemy = archer.findNearest(archer.findenemies)
    if enemy and archer.distanceto(enemy) < 25:
        self.command(archer, "attack", enemy)
    else:
        self.command(archer, "move", archer.pos)
loop:
    pickUpCoin()
    summonTroops()
    friends = self.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            # This friend will be assigned to the variable soldier in commandSoldier
            commandSoldier(friend)
        elif friend.type == "archer":
            #commandArcher(friend)
            commandArcher(friend)
            pass

Yeah, thereā€™s usually not much hurry when we are communicating via a forum platform. :wink:

By the way, I was looking around and I noticed the very first time you posted your code here, you did paste it with indentation, so I edited and formatted it correctly for you above. You can click in the ā€œpencilā€ icon below your posts to edit them, in case you have to fix a typo or formatting.

Here are some issues Iā€™ve found in your code:

def commandarcher should be def commandArcher
(uppercase A in Archer)

archer.findNearest(archer.findenemies) should be archer.findNearest(archer.findEnemies())
(uppercase E in Enemies and you have to call the findEnemies method by adding () after it)

It says line 30 isnā€™t identified

I meant It Isnā€™t a function

distanceto should be distanceTo.
This is called CamelCase, and is a naming convention used in several programming languages.
You can see the correct spelling of your functions listed below the code editor in the game.

Where code editor?
It still wont work but no code probs

It didnt
My reindeer are killed because my archers arenā€™t going back to pos

Well, this is odd. Your code looks correct.

In fact, even the code that I have used to beat the level myself is no longer working.

It looks like there is a bug in this level.

@Serg @nick Can you take a look, please?

@Doom By the way, it is possible that you may have got a bad random seed. Can you try submitting (Clicking ā€œSubmitā€) a few times?

I did
same thing happens

Yeah, it really looks like a bug.

In any case, I think you can change this line:

    if enemy and archer.distanceTo(enemy) < 25:

To:

    if enemy and enemy.pos.x < 65:

It is kind of an ugly/unintended solution, but should be able to let you win.

@Doom Oh never mind, I found another problem in your code:

In your commandSoldier function:

def commandSoldier(soldier):
    # Soldiers should attack enemies.
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)

You are iterating over all friends, including archers, and telling them to attack. You should remove the for soldier in self.findFriends(): line and de-indent the lines that were inside of that block. This way, you will only order the soldier that was passed as parameter to the function.

Thank you so much!Now about the bugā€¦

I canā€™t really do much more than helping you figure out whether your computerā€™s system clock is correct. Do you know what operating system you have (Windows, OS X / Mac, Linux)? You may be able to look up on Google how to check your system clock.

If your system clock has the correct date and time, then it may be a problem with your account data. In that case, someone that has access to the CodeCombat database should be able to check. Please check your system clock beforehand. :smiley_cat:

Where is the system clock

It is usually in a corner of your computer screen, but it really depends on the operating system and visual theme. Most systems allow you to change the position of the clock or even hide it completely, so I canā€™t really help you very much this way. Perhaps, if canā€™t find it, you can send a screenshot and I should be able to at least infer what operating system you have.

how d i send a screenshot

Again, it depends on your operating system.

If you are on Linux or Windows, you most likely have a ā€œPrint Screenā€ or ā€œPrt Scrā€ key on your keyboard (near the F12 key). If you do, then press it once and release, and then you can paste it inside this message box.