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

Automatic leaning #805

Merged
merged 7 commits into from
Jan 19, 2025
Merged

Conversation

AdamTadeusz
Copy link
Contributor

Description

Automatic leaning. Currently using automatic leaning prevents the use of manual leaning completely.

@AdamTadeusz AdamTadeusz requested a review from a team December 10, 2024 19:08
Copy link
Contributor

@brysondev brysondev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but how do we incorporate this for the sourcebots branch? I'd love to have this functionality added for them.

@AdamTadeusz
Copy link
Contributor Author

We can add a server only section which checks if a player is a bot, and does the same thing as whats done client side for the local player except with far fewer tracelines. We could add a time variable so that bots stop leaning only after a set number of seconds pass without the conditions for maintaining their current leaning state, to make their behavior look more natural while saving resources.

@AdamTadeusz
Copy link
Contributor Author

We can add a server only section which checks if a player is a bot, and does the same thing as whats done client side for the local player except with far fewer tracelines. We could add a time variable so that bots stop leaning only after a set number of seconds pass without the conditions for maintaining their current leaning state, to make their behavior look more natural while saving resources.

Actually a smarter way to go about this with a very similar end result would be to only perform the calculation for leaning for bots every x seconds

@Rainyan
Copy link
Collaborator

Rainyan commented Dec 12, 2024

We can add a server only section which checks if a player is a bot, and does the same thing as whats done client side for the local player except with far fewer tracelines. We could add a time variable so that bots stop leaning only after a set number of seconds pass without the conditions for maintaining their current leaning state, to make their behavior look more natural while saving resources.

Actually a smarter way to go about this with a very similar end result would be to only perform the calculation for leaning for bots every x seconds

If there's an issue of this causing a perf spike with high bot counts, you could also consider staggering this for example with modulo of the bot index, so that you're guaranteeing at most X expensive operations per think cycle regardless of the bot count. Something like (pseudocode): if (botindex % test != 0) return; test = (test+1)%MAX_PLAYERS.

Or some other measurement of how much time you're willing to spend in that routine per one bot think. This can work well for spreading work that doesn't necessarily need to be applied for every bot at the same exact tick.

And actually this might even be acceptable for things like general decision making and sensing for the bots, as real humans also have differences in their reaction times; so it should feel natural, even if bots sometimes react a few milliseconds slower. Although if you wanted to make this kind of optimization more fair, you could loop a random permutation so the bots that happened to be blessed with lower entity indices aren't always faster to react. Or use some other kind of balancing metric. But this starts to get increasingly off-topic 😅

@AdamTadeusz AdamTadeusz requested a review from a team January 16, 2025 15:51
@AdamTadeusz AdamTadeusz merged commit 47e310d into NeotokyoRebuild:master Jan 19, 2025
7 checks passed
@AdamTadeusz AdamTadeusz deleted the 086_autoLean branch January 24, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants