-
Notifications
You must be signed in to change notification settings - Fork 20
Bots slow down if far ahead of teammates #1538
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
Closed
sunzenshen
wants to merge
2
commits into
NeotokyoRebuild:master
from
sunzenshen:bots-walk-to-let-friends-catch-up
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,82 @@ QueryResultType CNEOBotSeekAndDestroy::ShouldHurry( const INextBot *me ) const | |
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| // Should I slow down to let my teammates catch up? | ||
| QueryResultType CNEOBotSeekAndDestroy::ShouldWalk( const CNEOBot *me, const QueryResultType qShouldAimQuery ) const | ||
| { | ||
| // ShouldAim query shorts cuts ShouldWalk to ANSWER_YES as aiming and running blocks each other | ||
| if (qShouldAimQuery == ANSWER_YES) | ||
| { | ||
| return ANSWER_YES; | ||
| } | ||
|
|
||
| const CKnownEntity* threat = me->GetVisionInterface()->GetPrimaryKnownThreat(); | ||
| if (threat != NULL) | ||
| { | ||
| // I need to decide how to deal with a threat | ||
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
| if (NEORules()->GetGameType() == NEO_GAME_TYPE_CTG) | ||
| { | ||
| if (NEORules()->GhostExists()) | ||
| { | ||
| // For comparing my distance to the ghost compared to my teammates | ||
| const Vector &vGhostPos = NEORules()->GetGhostPos(); | ||
| float flMySqDistToGhost = (me->GetAbsOrigin() - vGhostPos).LengthSqr(); | ||
| int iAliveTeammates = 0; | ||
|
|
||
| for ( int i = 1; i <= gpGlobals->maxClients; i++ ) | ||
| { | ||
| CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); | ||
|
|
||
| if (!pPlayer || !pPlayer->IsAlive() || pPlayer->GetTeamNumber() != me->GetTeamNumber() || pPlayer == me->GetEntity()) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| iAliveTeammates++; | ||
|
|
||
| const CNEO_Player *pNeoPlayer = ToNEOPlayer(pPlayer); | ||
| if (pNeoPlayer && pNeoPlayer->IsCarryingGhost()) | ||
| { | ||
| // Maybe I can catch up to my team's ghost carrier | ||
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
| // Check if this teammate is closer to the ghost | ||
| float flTeammateSqDistToGhost = (pPlayer->GetAbsOrigin() - vGhostPos).LengthSqr(); | ||
| if (flTeammateSqDistToGhost < flMySqDistToGhost) | ||
| { | ||
| // Maybe I can catch up to my teammate up ahead | ||
| return ANSWER_UNDEFINED; | ||
| } | ||
| } | ||
|
|
||
| if (iAliveTeammates == 0) | ||
| { | ||
| // I'm the sole survivor, don't need to wait for anyone | ||
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
| // I should slow down to let my teammates catch up | ||
| return ANSWER_YES; | ||
| } | ||
| } | ||
|
|
||
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| QueryResultType CNEOBotSeekAndDestroy::ShouldAim(const CNEOBot* me, const bool bWepHasClip) const | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to allow CNEOBotSeekAndDestroy::ShouldWalk to instantiate the abstract class. I decided to revert my original experiment with aiming to slow down since walking already was enough to let teammates catch up with the recent related bot updates. |
||
| { | ||
| return ANSWER_UNDEFINED; | ||
| } | ||
|
|
||
|
|
||
| class CNextSpawnFilter : public IEntityFindFilter | ||
| { | ||
| public: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I'm reading this correctly then only one bot per team can ever be walking at a time because they are close to the objective. Perhaps an early return here only if any team mate is closer to the objective than "me" by some tweakable value, that way some number of bots closest to the ghost can all walk at once.
If you wanted to add something like that you would probably also need to count how many alive bots are within that tolerance where a bot is considered to be the same distance from the ghost as "me", so in the case where all the bots on a team are close together they don't all walk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many bots should be slowing down is also a good design question. In experimenting with CTG tactics in another branch, I'm wondering if slowing down any of the bots is a generally optimal strategy. For example, if the ghost was spawned closer to one team, it could make sense to just try to rush, but on the other team the same approach would lead to getting picked off one by one. I think it might be a good idea to let this PR wait until we decide on a default bot strategy for CTG, so that we have some behavior to compare with before and after this tweak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess one potential heuristic we could try when the other PRs slot into place is whether we should have teams that are closer to the objective should rush, but the other team that is calculated to be farther should engage in this logic of slowing down, so they can attack together in force.
Also, while this patch currently only has 1 bot slow down for the second up front bot on the team, perhaps we could calculate a ratio of how lopsided team counts are, so teams that are evenly stacked will have fewer bots slowing down than teams that are greatly outnumbered by the other team.