Hello,
I have a problem with Greed Traps level. I think that the code is OK (correct me if I’m wrong). The point being I collect the coin because it is direcly placed on the way to the designated coordinates. Is it a bug?
#Patrol and place traps ONLY if you see a coin.
# Write this function.
def maybeBuildTrap(x, y):
# Move to the given x,y postion
hero.moveXY(x, y)
# Search a coin and if you see it, build a "fire-trap"
item = hero.findNearestItem()
if item:
hero.buildXY("fire-trap", x, y)
pass
while True:
# Call maybeBuildTrap for the top left passage.
maybeBuildTrap(12, 56)
# Now for the top right passage.
maybeBuildTrap(67, 56)
# Now for the bottom right passage.
maybeBuildTrap(67, 12)
# Now for the bottom left passage.
maybeBuildTrap(12, 12)
The error is the character collects the coin by accident so no fire-trap is built. Adjusting the x coordinat on the bottom right passage should solve this issue:
maybeBuildTrap(12, 56)
# Now for the top right passage.
maybeBuildTrap(67, 56)
# Now for the bottom right passage.
maybeBuildTrap(70, 12)
# Now for the bottom left passage.
maybeBuildTrap(12, 12)
2 Likes
Gee!, indeed mate, it worked. Thanks a lot!
I already answered it I believe. Could you withdraw your post
and how do you withdraw the post? Can’t see any option for this.
You can click on the three dots on the bottom of your post. A series of icons will then appear. Click on the trash can and your post will be withdrawn. (Note: This only works if you posted the same post that you’re trying to delete.)
I don’t have the trash icon on my posts.
After you have posted a message you can find the three dots and once you click on them the trash can will be there.