public class AI {
public static void main(String[] args) {
while(true) {
// Collect gold.
var item = hero.findNearestItem();
hero.move(item.pos);
// If you have enough gold, summon a soldier.
if (hero.gold > 20){
hero.summon("soldier");
}
// Use a for-loop to command each soldier.
var friends = hero.findFriends();
for(int friendIndex = 0; friendIndex < friends.length; friendIndex++) {
var friend = friends[friendIndex];
if(friend.type == "soldier") {
var enemy = friend.findNearestEnemy();
hero.command(friend, "move", {"x":74, "y":47});
hero.command(friend, "attack", enemy);
// If there's an enemy, command her to attack.
// Careful! If your soldiers are defeated, a warlock will appear!
// Otherwise, move her to the right side of the map.
}
}
}
}
}
When I run this code I get an error and I don’t know why. Plz help.