Why does my hero seem to stutter-step?

I’m sure it’s just me, but my hero does not seem to move smoothly.
Also any tips to clean up my code would be great. Thanks

Vital Powers
# This level shows how to define your own functions.
# The code inside a function is not executed immediately. It’s saved for later.
# This function has your hero collect the nearest coin.
def pickUpNearestCoin():
items = self.findItems()
over2=[]
for item in items:
if item.value>2:
over2.append(item)

    nearestCoin = self.findNearest(over2)
    if nearestCoin:
        self.move(nearestCoin.pos)

# This function has your hero summon a soldier.
def summonSoldier():
    if self.costOf("soldier")<self.gold:
        self.summon("soldier")

# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)
        
# This function is to bash and cleave
def bashCleave():
    e1=self.findNearest(self.findEnemies())
    if e1:
        if self.isReady("cleave"):
            self.cleave(e1)
        else:
            if self.isReady("bash"):
                self.bash(e1)
            else pass
loop:
    # In your loop, you can "call" the functions defined above.
    # The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    pickUpNearestCoin()
    summonSoldier()
    commandSoldiers()
    bashCleave()

Because he isn’t repeating the pickUpNearestCoin() until he gets there; rather he is moving toward it, stopping, running the rest of the functions, then taking another step toward the coin.

Try a loop to keep going until he gets there unless there is a good reason to break out of the loop.

So I tried to change a few things. This seems like the best so far I’m sure it could be way better
Thanks for the help :slight_smile:

# This function has your hero summon a soldier.

def summonSoldier():
if self.costOf(“soldier”)<self.gold:
self.summon(“soldier”)

This function commands your soldiers to attack their nearest enemy.

def commandSoldiers():
for soldier in self.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
self.command(soldier, “attack”, enemy)

This function is to bash and cleave

def cleaveNE():
if self.isReady(“cleave”):
e1=self.findNearest(self.findEnemies())
if e1:
self.cleave(e1)

def bashNE():
if self.isReady(“bash”):
e1=self.findNearest(self.findEnemies())
if e1:
self.bash(e1)

loop:
loop:
if self.costOf(“soldier”)<self.gold:
break
if self.now()>5:
if self.isReady(“cleave”):
break
if self.isReady(“bash”):
break

    items = self.findItems()
    over2=[]
    for item in items:
        if item.value>1:
            over2.append(item)
    nearestCoin = self.findNearest(over2)
    if nearestCoin:
        self.move(nearestCoin.pos)

summonSoldier()
commandSoldiers()
cleaveNE()
bashNE()