Hi all. I’m stuck on the level Grim Determination in the mountain levels. My most region is to ramp up a couple of peasants in the beginning, and then to give each one a ‘zone’ where they’re collecting coins, in order to maximize collection. I’ve tweaked my strategy with the rest of the level to the point that I think I’ve got it, if not for the problem that I can’t figure out why only the first peasant does anything. Here’s my code:
# Here's the first two CommandPeasant functions; there are 4 in total
def commandPeasant1(psnt):
hero.command(psnt, "move", {"x": 35, "y": 24})
coins = psnt.findItems()
for coin in coins:
if coin.value >= 3 and coin.pos.x > 23 and coin.pos.y < 39:
hero.command(psnt, "move", coin.pos)
break
def commandPeasant2(psnt):
hero.command(psnt, "move", {"x": 35, "y": 55})
coins = psnt.findItems()
for coin in coins:
if coin.value >= 3 and coin.pos.x > 23 and coin.pos.y > 38:
hero.command(psnt, "move", coin.pos)
break
# And now, in CommandFriends():
def commandFriends():
# Command your friends.
friends = hero.findFriends()
peasants = hero.findByType("peasants")
for friend in friends:
if friend == peasants[0]:
commandPeasant1(friend)
elif friend == peasants[1]:
commandPeasant2(friend)
elif friend == peasants[2]:
commandPeasant3(friend)
elif friend == peasants[3]:
commandPeasant4(friend)
elif friend.type == "griffin-rider":
commandGriffin(friend)
elif friend.type == "paladin":
commandPaladin(friend)
# And now, the relevant part of the loop:
while True:
commandFriends()
With this code, the lower of the two peasants (I believe she’s always ‘Rose’) goes about collecting (as does the Mimic, who’s running from a different function), but Hector and any summoned peasants never even so much as move.
Any help, or even general advice on strategy would be greatly appreciated.