thejoshwolfe / legend-of-swarkland

Turn-based action fantasy puzzle game inspired by NetHack and Crypt of the Necrodancer
http://wolfesoftware.com/legend-of-swarkland/
Other
94 stars 5 forks source link

Brainstorming: Make diagonal pathing AI easier to understand #85

Open thejoshwolfe opened 2 years ago

thejoshwolfe commented 2 years ago

I'm the creator of this game, and i still don't have an intuitive muscle memory for where orcs and centaurs are going to go when i'm diagonally 1 space away from them. this is a problem.

image

Ideas:

  1. Remember the last movement and keep going in that direction. This is how Necrodancer does it. This can apply to either:
    • a) only exact diagonals |dx| = |dy|, or
    • b) any diagonal whenever there isn't a straight shot. (This is how Necrodancer does it.)
  2. Prefer some cardinal direction, such as east/west before north/south. This has the advantage of being stateless, but would be the first time that the universe is not rotationally symmetrical. I'm also skeptical that this would work very well; it may result in lots of "sumo conflicts" > < where individuals bounce off each other and both fail to move.
  3. :-1: Literally random. I don't like this idea, because anticipating enemy behavior is supposed to be part of the skill expression of this game. Important randomness like this also has an unfortunate interaction with undo/redo where the player can grind an exploration of the rng seed to find a favorable outcome. grinding is bad.
  4. Alternate between x and y. This has all the problems of (1), and is probably hard to understand, which defeats the purpose of this brainstorming.

The biggest drawback to what is probably the best option (1) is that it requires storing state for each individual. From a technical perspective, this isn't too concerning, and some technical solution will be needed once friendliness/hostility is determined statefully #32 . The problem I see with this kind of state is the interface.

Should the player be expected to remember the state? That works great for Crypt of the Necrodancer when your memory only needs to last for about 0.5 seconds, but in Swarkland you can rewind to a previous state you were looking at several minutes ago, and there's no reasonable expectation of remembering that.

Should the UI show little arrows where it expects enemies will move? This could work, but there's a slippery slope where the client could literally call the AI functions and give you a warning if you're going to make a move that will get you stabbed. An AI playing the game is a planned usecase, but not for the player GUI.

Perhaps the UI can show little arrows representing the individuals last movement. :thinking: A related planned feature is a button to replay the last turn's animations. Maybe that's all we need to make the stateful AI intuitive.

Regarding 1.a vs 1.b: this seems like a good candidate for depending on the individuals strategic intelligence. Centaurs should prefer to line up long range shots (as they do now), and rats should just barrel forward with whatever "momentum" they already have as long as that continues to reduce the orthogonal distance. And it's pretty obvious that rhinos or any other creature with a "facing direction" should prefer not to turn, and should prefer to turn 90 degrees over 180 degrees.

This all interacts with another planned feature (soon:tm:) which is actual pathfinding. We want the pathfinding to be able to walk around lava pools/trees/walls, and we also want individuals to remember where you were and pursue that spot when you go out of view. The question in this discussion is mainly for resolving "ties" in the pathfinding when the distance is the same and there's no clear reason to prefer one route over another (such as in the above screenshot).

Another issue with (1) is that it doesn't solve the case of making the first move. If there's no "momentum", then it can't be used to resolve ties. Given that the first move will usually happen far away from the player's character, it's less important for it to be intuitive. A reasonable solution is to initialize every individuals momentum to a random value at world creation.

thejoshwolfe commented 2 years ago

For reference, the current implementation is:

  1. Individuals with attack range=1 (orcs, turtles, etc.) prefer to avoid straight-shot alignment with the target, and resolve exact diagonal ties counterclockwise.
  2. Individuals with attack range!=1 (centaurs, rhinos, blobs, etc.) prefer to get in straight-shot alignment with the target, and resolve exact diagonal ties clockwise.

This clockwise-vs-counterclockwise thing is way too hard to develop muscle memory for. Furthermore, it's not clear why rhinos and blobs are trying to line up straight-shots.

The clockwise-vs-counterclockwise issue is also related to #86 .

thejoshwolfe commented 2 years ago

another idea: if you can't decide, don't move. shoutouts to https://en.wikipedia.org/wiki/Buridan%27s_ass

this idea is so easy to implement that it's worth experimenting with. i don't expect it to be very appealing.

thejoshwolfe commented 2 years ago

We could also go with the Zombicide tiebreaker, where if the monster can't decide which way to go, it duplicates and goes both directions! (ref: https://zombicide.com/dl/rulebook-zombicide-season-1.pdf search for "If necessary, add".) Shoutouts to Ameritrash.