형들 독학으로 파이썬 배워보는 파린이인데 너무 어려워


왜 codecombat.com이라고 하는 사이트에서 코드 짜서 주인공 공격시키고 막 그러며 한판 한판 깨는 게임형식인데.


이번판은 우리팀과 똑같은 적팀(+간간히 충원되는 적들)이랑 싸우는거라서 그냥 싸우면 충원되는 적들 때문에 ㅈ되고


cleave라는 범위데미지 기술을 많이 써야 이기는거 같길래 글케 짰어.


혹시 파이썬 하는 형들 중에서 누가 이거 좀 읽어봐 줄 수 있을까??


일단 범위내 몇마리나 있는지 확인하는 함수

def withinRange(range):

    rangeIndex = 0

    count = 0

    while rangeIndex

        if hero.distanceTo(enemies[rangeIndex]) <= range :

            count += 1

        rangeIndex += 1

    return count


체력이 제일 적은 놈 찾는 함수

def smallestEnemy():

    smallestIndex = 0

    smallest = None

    smallestHealth = 0

    while smallestIndex

        if enemies[smallestIndex].health

            smallest = enemies[smallestIndex]

            smallestHealth = smallest.health

        smallestIndex += 1

    return smallest



while True:

    enemyIndex = 0

    while enemyIndex

        enemies = hero.findEnemies()

        enemy = smallestEnemy()

        while enemy.health > 0: #요기가 잘못됐다고 자꾸 뜨는데 왜 그럴까??

            if hero.isReady("cleave") and withinRange(10) > 3 or withinRange(10) >= len(enemies):

                hero.cleave(enemy)

            hero.attack(enemy)

        enemyIndex += 1