Don’t know if this counts as a bug or not, but when I started to fool around with the code to speed up processing the list, I discovered that the following code wins the level outright:
Not sure if there is any easy way to fix this.
As an aside, I attempted to speed things up by removing the weakest friend from the list after my hero has called their name. Any suggestions as to why this code isn’t working?
friends = self.findFriends() loop: weakestFriend = None leastHealth = 9999 friendIndex = 0 # Tell the weakest friends to go home first. while friendIndex < len(friends): friend = friends[friendIndex] if friend.health < leastHealth: leastHealth = friend.health weakestFriend = friend friendIndex += 1 if weakestFriend: self.say('Hey ' + weakestFriend.id + ', go home!') friends.remove(weakestFriend) weakestFriend = None
After the first pass, it keeps throwing an error that there is no value to “friend.health”… but that only makes sense if the friends list gets emptied after being read. Why would that happen?
Also, it looks like the “.remove” method isn’t enabled (perhaps due to API protections). I tried the following code:
After friends.remove(weakestFriend), weakestFriend was still appearing in the list.