Hacker News new | ask | show | jobs
by passivepinetree 2959 days ago
It would be awesome if there was a way to gain information about your enemies. For example, sometimes (when facing a sludge), it's better to run away, heal, and come back to finish it off at full health. When facing an archer, it's often better to power through and kill it before healing. There's no programmatic way to know which enemy is attacking your warrior, so I'm often finding myself writing custom, non-reusable code for a specific level, which isn't great.
4 comments

I stopped playing at the level where this became critical for exactly this reason. My warrior presumably has eyes, so why can she not tell the difference between a sludge and an archer? If the goal was ultimately to write a player that could succeed in any arbitrary level ("Epic Mode"), I did not feel like I could accomplish that without being able to know what I was up against. If I have to hardcode decisions based on known levels anyway... might as well just hardcode exact instructions on which actions to take based on a counter. But at that point, it doesn't really feel like programming an artifical intelligence anymore.
Hello, I'm sorry you feel that way. I think that being able to determine what enemies your warrior is facing is something valuable. However, it's possible to succeed in epic mode (and get a perfect score) without hard-coding any instruction.
Can't you infer what enemy you're facing based on the damage they do to you?

In the original, [ruby-warrior](https://github.com/ryanb/ruby-warrior), you can `listen` (at some point) to get an array of occupied spaces and then you can check if a space contains an enemy. If you're not immediately adjacent to an enemy but your warrior is taking damage you can infer you're being attacked by an archer (or another enemy with a ranged attack).

This is a really good idea that somehow I totally missed. I stopped playing at a level where this became important (as @elefantastisch noted above), but now I kind of want to pick it back up again. It's not guaranteed to work (different enemies might deal the same amounts of damage), but maybe location could help in those cases (i.e., if my warrior is being dealt a certain amount of damage and the space in front and behind the warrior is empty, one could infer the enemy is an archer).
Something for basic enemy assessment would allow for more tactical action, though. For example, checking armor and weapon types to switch between your own equipment (hammers vs heavy armor, swords vs cloth armor, spears vs spearmen or beasts with tough hides) - or putting together different signs to decide if an unarmored enemy is a wizard or a thief.
Screeps does that, and it doesn't have "classes" per se, but modular bodies... so you can look at an enemy and see that they have some HEAL body parts, so you know they are a healer. You can even calculate how much healing per turn they can do to influence your fight or flight, or target priority decisions (you have multiple units, after all).
Looking at the code you could do getCharacter() for a Space returned by look()/listen()/feel() to figure out what type of enemy it is: https://github.com/olistic/warriorjs/blob/master/packages/wa...