i keep getting an infinite loop (or my code is running really slow) error.
i think its where i’m calling my function but i cant figure out exactly what ive done wrong.
here it is:
# You need exactly 104 gold.
less = "Nimis"
more = "Non satis"
requiredGold = 104
# This function calculates the sum of all coin values.
def sumCoinValues(coins):
coinIndex = 0
totalValue = 0
# Iterate all coins.
while coinIndex < len(coins):
totalValue += coins[coinIndex].value
coinIndex += 1
return totalValue
def collectAllCoins():
item = hero.findNearest(hero.findItems())
while item:
hero.moveXY(item.pos.x, item.pos.y)
item = hero.findNearest(hero.findItems())
while True:
items = hero.findItems()
# Get the total value of coins.
goldAmount = sumCoinValues(items)
# If there are coins, then goldAmount isn't zero.
if goldAmount != 0:
# If goldAmount is less than requiredGold
if goldAmount < requiredGold:
# Then say "Non satis".
hero.say(less)
# If goldAmount is greater than requiredGold
if goldAmount > requiredGold:
# Then say "Nimis".
hero.say(more)
# If goldAmount is exactly equal to requiredGold
if goldAmount == requiredGold:
# Then collect all coins:
collectAllCoins()
sorry i took so long to reply. Its been hectic here.
That worked straight way! Thanks for response
one question though. why did that work?
if more = "Nimis" then surely by coding in hero.say(more) then that should’ve worked?
otherwise what is the point of creating that function (if thats what its called)?
I hadn’t realised it until @xython said, but the variables are the wrong way round, so the hero is saying the wrong word. If you put in
if goldAmount < requiredGold:
# Then say "Non satis".
hero.say(more)
# If goldAmount is greater than requiredGold
if goldAmount > requiredGold:
# Then say "Nimis".
hero.say(less)
then it works.
There is a way to suggest corrections to CoCo via Github, but I got a bit lost when I tried it before .
Hmm, I’m confused.
I reloaded this level to try it again and it worked perfectly.
At the top of the level it says:
less = “Nimis”
more = “Non satis”
That seems to fit up to me.
It tells you to say “Non satis”, and you can use hero.say(more). It says at the top that Non satis = more, so that would make sense.
You may already know this, but nimis means less in latin, and no satis is “not satisfied”. e.g. more.
Maybe I’m missing the point, but I used:
if goldAmount < requiredGold:
# Then say "Non satis".
hero.say(more)
# If goldAmount is greater than requiredGold
if goldAmount > requiredGold:
# Then say "Nimis".
hero.say(less)
“satis is “not satisfied”. e.g. more” - No - not satisfied means less
For all readers of the topic:
“The lyrics to this were truly threatening to an older audience. This song was perceived as an attack on the status quo.”
Don’t be afraid to question the correctness of the default code and all the authorities in general
I accept that a level could be wrong, but I’m sure about the meaning of the Latin. My Latin dictionary (like google) says that nimis means too much. If I was given a massive slice of cake and I wanted less, I would say “too much”. You say the amount is “too much”, meaning you want less. I could have just said “less” (if I was rude), and received the same result: less cake.
Same with non satis. Satis means “enough”, “sufficient”. So non satis is “not sufficient”, meaning more. There isn’t sufficient stone to build this castle, meaning I need some more. Result: I get more stone.
I have no problem accepting levels can be wrong (For example I think this level has a bug, and I submitted a patch: Cursed Valley- didn't lose health? - #13 by Deadpool198), but I’ve been doing Latin since I was 7 (my granny taught me (up until about 5 months ago…)), and I’m sure about the meaning of the words.
Danny
I don’t want to argue. We both take the same fact and we have different actions.
For me it’s a statement for of the fact that the amount is too much, not asking for less, and the initial phrases must be the correct translation to English.