This crashes my hero and then I usually lose the match.
I would expect this to mean that I am attempting to call this.command() on a unit I do not control, however I do not believe this to be the case — I only use units retrieved via this.findFriends(). Something unexpected must be happening.
In the game I am currently viewing it seems to happen immediately upon the death of some resurrected zombies. Perhaps this is related, since it seems that enemy units will fight for you if resurrected. Perhaps, upon death, there is an instant where they are included in the return value of this.findFriends(), but it is not valid to command them.
The above is largely speculation. I haven’t been able to debug this at all because there does not seem to be any practical logging functionality (this.say() is not very useful) or inspection tools. I have a high confidence that this is not a problem in my code, but I’m not willing to share it at this time.
Anyway, if a dev sees this (@nick) perhaps you can have a look?
I had the same problem. I think the issue is that you have something like:
friends = this.findFriends()
this.summon('soldier')
for friend in friends:
this.command(friend, 'attack', enemy)
Basically you have some action between when you created the findFriends array and when you actually commanded, and in that time a dude that you were controlling died and switched teams (I also have had the error appear because the dude was dead)
If you make sure you are only getting the array directly before using it with no game actions in between, it should remove the error.
Damn, I think you’re right @dwhittaker, your explanation fits my problem very well. Well done for figuring that out and thanks for telling me!
It had not occurred to me that the summoning action takes time (I guess just one “frame”) and therefore the state of the world would change before I got to issuing orders. I was doing exactly as you described: fetching the data, then summoning, then giving orders.
So, not a CodeCombat bug after all, just a clueless player bug. Though it would be nice if the hero AI didn’t die completely when this happens.
I just realized who I was helping… I shoulda kept my mouth shut til after the tournament! Actually at least this way I can take a smidgeon of glory by saying I helped Wizard Dude!
My guy finds something interesting in the wall and spends about 20 seconds studying it before getting back to the task at hand.
Your generosity did seem rather unfounded! Looks like I’m finally down from first though so I have some more work to do.
I also had this problem with the wall… sometimes a coin appears in the rocks at the top-right which is not reachable in a straight line and my hero would spend a good while furiously charging the wall to get to it. Now I check the coin with this.isPathClear() before chasing it and the problem is largely gone. Either that or you can specifically ignore coins in this section of the map.
Hmm, I can’t tell where the coins was, though–I need to be able to see how far into the obstacle the coin spawned in order to figure out whether there’s a bug in the don’t-spawn-coins-in-obstacles logic or whether the tolerances are just slightly off.
Yeah, I realized later that I had 2 self.move(item.pos) lines separated by spell casting and friend summoning. Apparently somewhere between the two lines I reached the coin, then didn’t have anything to move toward for the second one so Pender got confused.