# Zero-Sum "can't command x" bug

**URL:** <https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264>\
**Category:** Bugs\
**Created:** [March 28, 2015, 2:28pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264 "2015-03-28T14:28:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![WizardDude](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wizarddude/32/1516_2.png) [@WizardDude](https://discourse.codecombat.com/u/WizardDude)\
**Post date:** [March 28, 2015, 2:28pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/1 "2015-03-28T14:28:24Z")

</div>

Hi all,

In zero-sum, I am seeing a message like the following in some games:

```
Hero Placeholder 1 (team ogres) can't command Bonnie (team humans).

```

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?

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [March 28, 2015, 4:47pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/2 "2015-03-28T16:47:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WizardDude](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wizarddude/32/1516_2.png) [@WizardDude](https://discourse.codecombat.com/u/WizardDude)\
**Post date:** [March 28, 2015, 6:30pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/3 "2015-03-28T18:30:47Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [March 28, 2015, 11:39pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/4 "2015-03-28T23:39:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WizardDude](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wizarddude/32/1516_2.png) [@WizardDude](https://discourse.codecombat.com/u/WizardDude)\
**Post date:** [March 29, 2015, 10:49am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/5 "2015-03-29T10:49:29Z")

</div>

😃 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.

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [March 29, 2015, 11:00am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/6 "2015-03-29T11:00:09Z")

</div>

I believe Nick has gotten it fixed so that coins don’t spawn out of bounds anymore.

Good luck getting back on top! I’m just hoping to be in the top ten, too busy teaching and getting ready to move to spend much time playing.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [March 29, 2015, 3:03pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/7 "2015-03-29T15:03:40Z")

</div>

Maybe we need a warning for commanding enemies that isn’t an error?

I did try to add `this.debug` to the method list for this one, but it appears not to have worked. Let me try again.

If you still see a coin stuck in the wall, press Ctrl+\ and send me a screenshot so I can debug it further.

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [March 31, 2015, 10:37am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/8 "2015-03-31T10:37:26Z")

</div>

@nick

Here is one. I’m not sure if there is a coin hidden there or not, but I stand there running into the wall for a while before moving on.

![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2246/7b4356f82d49eadc.png)

---

<div class="post-metadata">

**Author:** ![VincentMaths](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vincentmaths/32/2418_2.png) [@VincentMaths](https://discourse.codecombat.com/u/VincentMaths)\
**Post date:** [April 1, 2015, 8:46am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/9 "2015-04-01T08:46:06Z")

</div>

Hello, the question has arealdy been answered, but maybe my solution could help others.

```
    Hero Placeholder 1 (team ogres) can't command Bonnie (team humans).

```

I added a condition checking the team of the unit before commanding it.

Somewhere in the initialization, I have

```
myTeam=this.team;

```

And instead of

```
this.command(friend, 'attack', enemy);

```

I use

```
if(friend.team==myTeam){
  this.command(friend, 'attack', enemy);
}

```

I think this is a more robust solution than “do it quickly so your units can’t die or change team before you command them”.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [April 4, 2015, 1:57am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/10 "2015-04-04T01:57:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [April 4, 2015, 3:29am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/11 "2015-04-04T03:29:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![EnchantedAndroid](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@EnchantedAndroid](https://discourse.codecombat.com/u/EnchantedAndroid)\
**Post date:** [April 25, 2015, 1:08am UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/12 "2015-04-25T01:08:54Z")

</div>

I finished the level, but it never showed the red flag on the map. Any ideas why?  
😕

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [April 28, 2015, 11:35pm UTC](https://discourse.codecombat.com/t/zero-sum-cant-command-x-bug/3264/13 "2015-04-28T23:35:39Z")

</div>

Did you “finish” it for both ogres and humans? It’s possible it’s loading one or the other session and seeing it as incomplete.
