this is my code, please help I really appreciate it
Ogres are attacking a nearby settlement!
Be careful, though, for the ogres have sown the ground with poison.
Gather coins and defeat the ogres, but avoid the burls and poison!
while True:
enemy = hero.findNearestEnemy()
if enemy.type == “munchkin” or enemy.type == “thrower”:
hero.attack(enemy)
item = hero.findNearestItem()
if item.type ==“coin” or item.type == “gem”:
# Then move and pick it up:
hero.move(item)
while True:
enemy = hero.findNearestEnemy()
if enemy.type == "munchkin" or enemy.type == "thrower":
hero.attack(enemy)
item = hero.findNearestItem()
# Check the item type to make sure the hero doesn't pick up poison!
# If the item's type is "gem" or "coin":
if item.type == "gem" or "coin":
# Then move and pick it up:
hero.move(item)
@Saanvi_K I see your problem, hero.move(item) should be hero.move(item.pos) I recommend using hero.moveXY(x, y) because you will only learn about hero.move() in the mountain levels
Hi I just wanted to ask for help on the code that involves the character to move to the item. Here is my code.
`# Ogres are attacking a nearby settlement!
# Be careful, though, for the ogres have sown the ground with poison.
# Gather coins and defeat the ogres, but avoid the burls and poison!
while True:
enemy = hero.findNearestEnemy()
if enemy.type == "munchkin" or enemy.type == "thrower":
hero.attack(enemy)
item = hero.findNearestItem()
# Check the item type to make sure the hero doesn't pick up poison!
# If the item's type is "gem" or "coin":
if item.type == "coin" or item.type == "gem" :
# Then move and pick it up:
hero.move(48, 42)
`
Is the move code correct?
Hello, @Sans, and welcome to CodeCombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thank you!
Hope you have a good time here