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

Serpent Savings

Please help me I am stuck with this level
this is (edit: not!) my code

x = 10
direct = []
direct[0] = Vector(10, 0)
while True:
    friend = hero.findNearest(hero.findFriends())
    friends = hero.findFriends()
    tails = hero.findEnemies()
    coins = hero.findItems()
    for friend in friends:
        if Math.floor(friend.pos.x > 10) and Math.floor(friend.pos.x) < 70:
            if Math.floor(friend.pos.y > 10) and Math.floor(friend.pos.y) < 55:
                if Math.floor(friend.pos.x) % 7 == 0:
                    if Math.floor(friend.pos.x) % 2 == 0:
                        direct[0] = Vector(0, 10)
                    else:
                        direct[0] = Vector(0, -10)
                else:
                    direct[0] = Vector(10, 0)
            else:
                if (friend.pos.y <= 10):
                    direct[0] = Vector(10, 2)
                else:
                    direct[0] = Vector(10, -2)
            direct[0] = Vector(0, 0)
            move = Vector.add(friend.pos, direct[0])
        else:
            if Math.floor(friend.pos.x < 60):
                move = {'x': 75, 'y': 60}
            elif(Math.floor(friend.pos.y > 10)):
                move = {'x': 75, 'y': 10}
            else:
                move = {'x': 10, 'y': 10}
        hero.command(friend, 'move', move)

Can you send me the link to the level?

Mumbo_6

1 Like

http://codecombat.com/play/level/serpent-savings?

Oh, sorry, im not a subscriber…

1 Like

oh… its ok(20char)

Ah, I see you are not using your own code… This level is super duper difficult, if you can’t do it now, then you may have to come back to it later when you’re more experienced with coding. Or try and write your own code in a new topic and I’ll help you. I’ll close this one.
Also please stick on one topic, I see you made another post somewhere else.
Danny

1 Like

someone pleaseee help me this is my code

def onSpawn(event):
    global coors
    while True:        
        if friend:            
            if friend.distanceTo(Vector(coors[0], coors[1]))<40:
                pet.moveXY(coorsn[0], coorsn[1])
            else:
                pet.moveXY(coors[0], coors[1])
            pet.moveXY(friend.pos.x, friend.pos.y)
        
coors =  [60, 60]
coorsn = [60, 60]
friends = hero.findFriends()
friend = friends[0]
pet.on("spawn", onSpawn)
path = [
    [70, 57],#right top
    #[72, 45],
    #[14, 45],
    #[14, 21],
    #[70, 21],
    [70, 11],#right bottom
    [7, 8],#left bottom
    [7, 57]#left Top
]
index = 0
while True:    
    friends = hero.findFriends()
    friend = friends[0]
    coors = path[index%len(path)]
    coorsn = path[(index+1)%len(path)]
    item = friend.findNearestItem()    
    if item and friend.distanceTo(item.pos)<10:
        moveto = item.pos
    else:
        moveto = Vector(coors[0], coors[1])
    enemies = friend.findEnemies()
    for enemy in enemies:
        if friend.distanceTo(enemy) < 5:
            vectorToH = Vector.subtract(friend.pos, enemy.pos)
            vectorToH = Vector.normalize(vectorToH)
            vectorToH = Vector.multiply(vectorToH, 5)
            moveto = Vector.add(vectorToH, moveto)
    hero.command(friend, "move", moveto)
    if friend.distanceTo(Vector(coors[0], coors[1]))<5:
        index+=1
    if hero.canCast('haste', friend):
        hero.cast('haste', friend)

someone please help me :sob:

We help everybody here :slight_smile:

5 Likes

I’m not saying we can’t help them, I’m saying that I won’t help someone make some code they’ve stolen work. What’s the point of that? I do have limits to my willingness to help, which I think I have proved so far by helping people on the forum for quite a while.

5 Likes

There is some Android bug. I do not share Chaboy opinion and did not give him a like

1 Like