olistic / warriorjs

🏰 An exciting game of programming and Artificial Intelligence
https://warriorjs.com
MIT License
9.41k stars 489 forks source link

`.isCaptive()` returns undefined instead of false if the unit is not a captive #196

Closed ivarni closed 6 years ago

ivarni commented 6 years ago

Environment

I'm not sure why but this is what that command returns on my system

➜  mywarrior git:(master) ✗ npx envinfo --system --binaries --npmPackages @warriorjs/* --npmGlobalPackages @warriorjs/* --markdown
zsh: no matches found: @warriorjs/*

I've not installed it globally so that could be why, but either way I'm on ^3.0.0 at the time of writing this.

Steps to reproduce

  1. Run level 5 of the beginner tower
  2. Execute this code on the first turn:
    console.log(warrior.look().map(
    space => ([space.isEnemy(), space.isCaptive(), space.isEmpty()])
    ))

Expected Behavior

I expected it to log

[ [ false, false, true ],
  [ false, true, false ],
  [ true, false, false ] ]

Actual Behavior

It logs

[ [ false, false, true ],
  [ false, true, false ],
  [ true, undefined, false ] ]

I'm thinking it should return false for .isCaptive() in the 2nd slot. For reference this is what the board looks like at the start of turn 1 on level 5

╔═══════╗
║@ CaaSC║
╚═══════╝
ivarni commented 6 years ago

I'm closing this untill I can figure out if I'm on the right version or not, I've installed warriorjs@^3.0.0 locally instead of installing the cli as recommended and I might have gotten the wrong version somehow, ref #195

olistic commented 6 years ago

If you don’t want a local install, you can omit the -g but you should still install @warriorjs/cli and not warriorjs. The latter is a different branch of the game I no longer maintain.