CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
9.92k stars 4.08k forks source link

Auto path #74644

Open Brambor opened 1 week ago

Brambor commented 1 week ago

Summary

Features "Player can record paths and automatically walk them again"

Purpose of change

Resolve #74433

Describe the solution

Listen with u.get_path_manager()->record_step to when the avatar moves in

void avatar_moves( const tripoint &old_abs_pos, avatar &u, const map &m )

Add the new_pos to std::vector<tripoint_abs_ms> recorded_path. If a cycle is detected, remove it.

Add an interface, where the player can manage their paths: image

Known issues to fix / features to implement:

Will not fix:

Further not-implemented improvements

dist optimization results --- For the optimization, I ended up doing `max( tripoint_diff.abs().xyz() )` . The results are pretty amazing: 4 checks instead of 800 on this test path: https://github.com/CleverRaven/Cataclysm-DDA/assets/13402666/c6d2dc67-b2fd-40eb-9090-b5ccd76e660e Works reasonably in a spiral. I especially like how the number of checks decreases despite the number of tiles increasing when the character walks away from the spiral at the end: https://github.com/CleverRaven/Cataclysm-DDA/assets/13402666/7f44f12e-a91b-44aa-853c-497edd3e01f8 ---

Describe alternatives you've considered

Record keystrokes https://github.com/CleverRaven/Cataclysm-DDA/issues/74433#issuecomment-2171117437

Testing

I tried whatever I could think of. Should work on flat ground, with stairs, and ladders. Doesn't work with ramps, I will look into Travel To code when I have the time.

Additional context

Brambor commented 1 week ago

It is not ready for merge, but it is ready for review.

anothersimulacrum commented 1 week ago

I'm not sure this is a benefit. Like macros, this risks making it a player responsibility to make up for deficiencies in game systems and UX.

Brambor commented 1 week ago

@anothersimulacrum You are not the only one. @ GuardianDll pushed back too and warned me. I am totally fine with this not being merged. As stated on Discord, I made it for myself. Merging is just more convenient to me.

Brambor commented 1 week ago

TL;DR: I see the alternatives as either suboptimal or more work (for the player).

I disagree though, that Travel to, and such, could be improved to the level this would be completely obsolete. For me, Travel to would have to find the optimal* path between A and B and that is next to impossible in all cases. Small improvements just don't do it for me. I need to believe the path is optimal.

Just not being able to mark tiles as dangerous per-tile makes Travel to sub optimal. If that was implemented, then marking all dangerous tiles would be too much work. So let's consider only tiles I walked on already, I could have walked into a puddle I don't want to walk into again. Then I need to mark it off again. I could mark furniture_type = puddle to be blacklisted. That wouldn't work, since it sometimes is better or possible to only walk through puddle. So we would define cost for each tile ... ... ...

Brambor commented 2 days ago

Recording path across ramp doesn't work (stairs do work).

I just found out that Travel to doesn't work with ramps either: image Commanding the character to Travel to to the tile below the cursor.

The moment you step down it cancels: image

image

Edit: I think I fixed that, PR coming soon.

github-actions[bot] commented 1 day ago

Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details.

Click to expand * Recorded path has no **lenght**. Path erased.

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

Hints for adding a new word to the dictionary * If the word is normally in all lowercase, such as the noun `word` or the verb `does`, add it in its lower-case form; if the word is a proper noun, such as the surname `George`, add it in its initial-caps form; if the word is an acronym or has special letter case, such as the acronym `CDDA` or the unit `mW`, add it by preserving the case of all the letters. A word in the dictionary will also match its initial-caps form (if the word is in all lowercase) and all-uppercase form, so a word should be added to the dictionary in its normal letter case even if used in a different letter case in a sentence. * For a word to be added to the dictionary, it should either be a real, properly-spelled modern American English word, a foreign loan word (including romanized foreign names), or a foreign or made-up word that is used consistently and commonly enough in the game. Intentional misspelling (including eye dialect) of a word should not be added unless it has become a common terminology in the game, because while someone may have a legitimate use for it, another person may spell it that way accidentally.