My code doesn’t work for the Useful Competitors Level and there is always one coin in the top left still there.
while(true) {
var enemy = hero.findNearestEnemy();
if(enemy) {
if(enemy.type != "peon") {
hero.attack(enemy);
}
}
var item = hero.findNearestItem();
if(item) {
// Gather the item only if the type is NOT equal to "poison".
var itemX = item.pos.x;
var itemY = item.pos.y
if (item.type != "poison") {
hero.moveXY(itemX, itemY);
}
}
}