Forest Fire Dancing Problem


#1

My codes don’t seem to work.

Can you have a look at them and see whats wrong?

while True:
evilstone = hero.findNearestItem()
if evilstone:
pos = evilstone.pos
if pos.x == 34:
hero.moveXY(46, 22)

    if pos.x == 45:
        hero.moveXY(35, 22)
        
        
else:
    hero.moveXY(40, 22)

Isn’t this supposed to work?


#2

@iwchoikr Your code has the potential to be right. However are you sure its doing what you expect?

Add the below code and ask what does this statement show as you run through the loop?
hero.say(evilstone.pos.x)

Also I had to format your code with tabs. I assume this is what you are looking at in the editor?


while True:
	evilstone = hero.findNearestItem()

	if evilstone:
		pos = evilstone.pos
		if pos.x == 34:
			hero.moveXY(46, 22)
		if pos.x == 45:
			hero.moveXY(35, 22)
	else:
		hero.moveXY(40, 22)