Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Hordes 2.0 #14240

Closed
wants to merge 2 commits into from

Conversation

4 participants
@kevingranade
Copy link
Member

commented Nov 30, 2015

I've been poking at this for a while, and I finally sorted some things out to my satisfaction and am implementing it.

There are two key points to the design:

  1. Monsters are stored on a per-overmap-tile priority queue (monster_group) which is itself stored on a per-overmap priority queue. This effectively creates a scheduler for periodically allowing monsters to move, while managing how many updates happen per game tick. The plan is to let individual monster_groups get a little behind, and then catch them up all at once so that each batch of monster updates pulls from a small number of groups and write to a small number of groups, improving locality of reference.
  2. The senses object isolates monster AI from the overmap code, it knows the kind of things the AI needs to know, and knows how to get that information from the overmap. I intend to extend this for use with map-scale monster AI later for similar reasons.
hordes move with calls to overmap::move_hordes()
These should both be removed, specific monster instances should be created instead of hordes, probably.

monsters outside the reality bubble live in overmap::monster_map

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

Are these supposed to be TODO items?

This comment has been minimized.

Copy link
@kevingranade

kevingranade Dec 2, 2015

Author Member

Yes, this whole file is simply my brain dump about the design of the feature, it will be cleaned up and corrected as I go, and tidied up into javadoc by the end of the process.


Use cases:
Steady-state processing:
The overmap is triggered to do a turn, it grabs the monster group at the head of monster_turn_sequence and checks if they are due for processing, if they are, it processes them, moving to new locations in monster_map if necessary, and re-inserts them in the appropriate monster_turn_sequence (might be on a new overmap).

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

So if the first monster isn't ready to be processed, you stop scanning due to the sorted nature of the queue?

This comment has been minimized.

Copy link
@kevingranade

kevingranade Dec 2, 2015

Author Member

Yes, we can guarantee that we process the "most out of date" monsters in each group.

For map data (navigability, vision, and scent), monster AI can have a persistent "oracle" injected into it, which it can query for map data such as nearest visible enemy, nearest strong scent, and pathing information. This means the monster AI doesn't have a dependency on the overmap, and creates an injection point for testing monster AI.

Save/load:
When an overmap is savesd, the monster groups can be written out in no particular order.

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

Typo on this line.

OMTs should have a move cost derived in a similar way to the load factor.
Monster pays move cost to exit an OMT
Eventually monster groups should fight each other if they encounter opposition.
Dense hordes should mark map tiles for destruction as they cross over them, at some point becoming completely wrecked.

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

That is questionable since most zombies don't actually destroy terrain when loaded into the reality bubble unless agitated.

This comment has been minimized.

Copy link
@Coolthulhu

Coolthulhu Nov 30, 2015

Contributor

They agitate very easily, though.
And in a dense horde, one zombie is enough to start a mosh pit and get the rest to bash down an entire house.

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

Many players have found that it's currently a viable strategy to stay very quiet in your house and wait for the horde to pass. They will rarely mess anything up. So having them behave differently on overmap scale would be strange.

This comment has been minimized.

Copy link
@kevingranade

kevingranade Dec 2, 2015

Author Member

When I say dense hordes here I mean having the map tile at near capacity, literally wall-to-wall zombies.

This comment has been minimized.

Copy link
@CIB

CIB Dec 2, 2015

Contributor

Ah, that clears things up, thanks.

**/
void apply_stimulus( const tripoint &location, const monster_group_stimulus &stimulus );
int next_overmap_move() const;
// Decide on and advance time to next overmap move.

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

Could make this a doxygen comment.

}

void monster_group::add_monster( monster &new_monster ) {
// Reset the strongest stimulus since this new monster might not have received it.

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

On the other hand, the newest monster might simply follow its group. Heuristically, it might be a better solution for now to keep the stimulus, but decrease the interest in the stimulus.

Another note, for the common case of the player just barely escaping a monster and putting it on the reality bubble, it might be good to still have the monster pointing in the direction they were going on the overmap.

This comment has been minimized.

Copy link
@kevingranade

kevingranade Dec 2, 2015

Author Member

The rationale is expanded a bit on line 28, but I need to bulk up the explanation some. This isn't denying input to the monster, but rather a work-avoidance mechanism. As stimuli come in, they will be applied to each monster on the list, who will each make their own decision about the stimuli, but if a stronger stimuli is followed by a weaker stimuli, we can avoid applying it. This is upset by new monsters being inserted into the group though, because we don't have any information about the strongest recent stimuli those monsters experienced, so to be safe I'm just resetting it.
I completely agree that when monsters leave the map, or when they shift from one overmap square to another they should remember their previous goals.

I just realized though, we need to track stimuli of each type separately, if a clearly visible stimuli is followed by a relatively quiet sound, the sound still needs to be applied in case there are blind monsters in the group.


static int effective_strength( const monster_group_stimulus &stimulus, const tripoint &location ) {
// TODO: different scaling for effective strength based on stimulus type?
return stimulus.strength - ( stimulus.occurence - calendar::turn ) -

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

( stimulus.occurence - calendar::turn ) will always be negative, so personally I'd find it more intuitive to do + ( caldar::turn - stimulus.occurence).. In fact, putting it like that, I'm pretty sure that's not what you had in mind. ;)

This comment has been minimized.

Copy link
@kevingranade

kevingranade Dec 2, 2015

Author Member

Yep, this is backwards.

/**
* Object to inject into monster AI to isolate AI code from map or overmap accesses.
*/
class senses {

This comment has been minimized.

Copy link
@CIB

CIB Nov 30, 2015

Contributor

👍

@CIB

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2015

Very good code, I have few complaints.

When you write a description of a function or field, it would be nice to make it a doxygen comment, even if it's just a one-liner (I think /// works as one-line doxygen comment Doxygen is dum, you pretty much have to use /** */).

When this goes in, there should be a clear distinction between status quo and TODO in the documentation.

@kevingranade

This comment has been minimized.

Copy link
Member Author

commented Dec 2, 2015

Both points taken, will do.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2016

Appears stalled

@mugling mugling closed this Sep 14, 2016

@kevingranade kevingranade added this to Input Queue in Hordes Mar 4, 2017

@kevingranade kevingranade added this to To Do in Increase engagement ranges via automation Jan 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.