def summonSoldiers(): if hero.gold >= hero.costOf("soldier"): hero.summon("soldier") def commandSoldiers(): for soldier in hero.findByType("soldier"): enemy = soldier.findNearestEnemy() if enemy: hero.command(soldier, "attack", enemy) def pickUpNearestCoin(): items = hero.findItems() nearestCoin = hero.findNearest(items) if nearestCoin: hero.move(nearestCoin.pos) peasant = hero.findByType("peasant") while True: summonSoldiers() commandSoldiers() pickUpNearestCoin()
Can’t you redo the code from scrach using Java Script?
But how did you arrive to this level? Using Java Script or Phyton? If you did not do it already, I recomand you to play some easier levels with Java Script.
learn java in web dev
What is web dev? ???
Jeremy, what part about starting from scratch is giving you problems? If you switch to JS and then Restart, you get:
The first function can be used as an example for the others. Is this where you get stuck?
i dont know how to define funtions
Ok, as AnseDra recommended, I’d suggest going back and doing some of the earlier levels in JS. I believe this is the first level to explore functions:
ok thanks @dedreous (20chars)