[Adventurer] Aggressive Mimicry

Mountain level Aggressive Mimicry is ready for testing.

It’s a demo level about the special case of the string search problem – startsWith function.


I didn’t encounter any problems running this level.

I am having problems, can’t get my guy to attack anyone, unless I remove the part of the code that deals with startsWith. I’m using python.

Not sure that I got you. Could you explain your problem more careful?

When I write the code as designed, my hero just stands there. When I just
have a basic attack enemy code, he attacks the ogres, but obviously doesn’t
attack the others.

Could you post your code or send me sessionID?

@Bryukh default gear worked with aggressively modified code. Didn’t work consistently which is ok. And with my config, a sword upgrade would take care of this and allow for simpler code without modification, and guaranteed level completion each seed.

@dwhittaker the Python code worked on my end. Did you add a : to the end of the if statement?

added LUA patch
added grammar patch

returns after playing to the campaign screen like the other levels to http://codecombat.com/play/undefined

Hm. Could you give more examples or code? Which problems you had with the default equipment? BTW, what do you mean by “default equipment” for that level?

can someone please explain how do I call the function and compare it with the id?

ok nevermind, I figured it out

@Bryukh When I say default gear, this is the equipment I chose for my character at that point in the game. Instead of upgrading my equipment I kept the minimum in most cases. I used the long sword up until I believe the final battle on the Mountain level. My gear would most likely not be standard.

What I mean to say is that if I can still modify the code and pass the level that it is fine. If a gear upgrade was required then I would list this, meaning that if someone choose poorly with gear they might need to subscribe to get more gems to buy better equipment to fix their bad choices, or that the level might be more difficult for some.

Perhaps this brings up another thought. Should we include a level or a dialogue that encourages the player to upgrade their equipment in a certain manner? In other words what is the minimum gear required for this level?

Here is the gear that I used:

I then used the stars to summon archers and different fighting strategies to defeat all of the ogres.

Let me know if I can further clarify. Looking at my post I can see how it was vague. Does this help more?


Oh. Then it’s ok (“with aggressively modified code”). I tested it with the “course” mountain equipment.

1 Like

Soon there will be “Recomended Health” and “recommended dps”.


what am I missing here…

# Protect the village from the ogres. 
# Watch for ogres, peasants and ogres disguised as ”peasants".

# This function checks if the text starts with the word.
def startsWith(text, word):
    # If the word is longer then the text:
    if len(word) > len(text):
        return False
    # Loop through the indexes of word and text.
    for index in range(len(word)):
        # If characters with the same index are different:
        if word[index] != text[index]:
            # Then the word doesn't coincide with the text.
            return False
    # We checked all letters and they are the same.
    return True

ogreNameStart = "Zog"

while True:
    enemy = hero.findNearestEnemy()
    suspect = hero.findNearest(hero.findFriends())
    # Use the function "startsWith" to check
    # if suspect's name (id) starts with "Zog", attack:
    if startsWith(suspect, ogreNameStart) is True:
    # Else if there is an enemy, then attack it:
    elif enemy:
    # Else return to the red X mark:
        hero.moveXY(27, 27)

1 Like

I suppose you need to remove say (everywhere) because you spend hero time for that


I was using that to de-bug or test my code. It didn’t work before when I didn’t have it. I tried taking it out and he still lets the first on walk right by every time.

1 Like

Look for those lines:

# if suspect's name (id) starts with "Zog", attack:
if startsWith(suspect, ogreNameStart) is True:

suspect is not a name. It’s an unit.


I wondered about that, but when I had him saying it, he was saying the name so I thought maybe it will check. Thanks

1 Like

When you use say(unit) it try to converts it to string. It’s like say(42).

But it doesn’t wok when you need specific methods.


ya it works when you do it

   if startsWith(suspect.id, ogreNameStart) is True:

he goes and kills the first ogre

1 Like