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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ai controllers use cell trackers to know when to idle #82691

Merged
merged 5 commits into from Apr 17, 2024

Conversation

Ben10Omintrix
Copy link
Contributor

@Ben10Omintrix Ben10Omintrix commented Apr 15, 2024

About The Pull Request

this makes ai controllers use cell trackers and signals to determine when to idle

Why It's Good For The Game

might be better than looping over all clients for every controller

Changelog

馃啈
code: The way mobs idle has been refactored, please report any issues with non-reactive mobs
/:cl:

@Ben10Omintrix
Copy link
Contributor Author

might be a good idea to tm this first

@optimumtact
Copy link
Member

This is peak

@san7890
Copy link
Member

san7890 commented Apr 16, 2024

i would recommend adding a code: The way mobs idle has been refactored, please report any issues with non-reactive mobs to the github. to your changelog since this has the potential to be quite user facing

@san7890 san7890 added the Code Improvement Code is now easier to copy paste. label Apr 16, 2024
@san7890
Copy link
Member

san7890 commented Apr 16, 2024

hm is the test merge bot not working? it should have been on sybil for the last two hours and at least one round should have completed in that span

@MrMelbert MrMelbert added the Performance Uses the 32-bit address space and slow interpreter more effectively label Apr 16, 2024
Copy link
Member

@LemonInTheDark LemonInTheDark left a comment

Choose a reason for hiding this comment

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

can be even more speedy

code/datums/ai/_ai_controller.dm Outdated Show resolved Hide resolved
code/datums/ai/_ai_controller.dm Outdated Show resolved Hide resolved
code/datums/ai/_ai_controller.dm Outdated Show resolved Hide resolved
code/datums/ai/_ai_controller.dm Outdated Show resolved Hide resolved
@Ben10Omintrix Ben10Omintrix marked this pull request as draft April 16, 2024 15:57
Copy link
Contributor

github-actions bot commented Apr 18, 2024

This pull request was test merged in 56 round(s).

Round list

sybil

manuel

dwasint pushed a commit to dwasint/Monkestation2.0 that referenced this pull request May 6, 2024
## About The Pull Request
this makes ai controllers use cell trackers and signals to determine
when to idle

## Why It's Good For The Game
might be better than looping over all clients for every controller

## Changelog
:cl:
code: The way mobs idle has been refactored, please report any issues
with non-reactive mobs
/:cl:
dwasint added a commit to Monkestation/Monkestation2.0 that referenced this pull request May 12, 2024
* Basic bots (medibots) (tgstation#79955)

refactors bots into basic bots. i decided to do medibots first because
they were the most complex bots and wanted to get them out of the way
first. if this pr gets merged then i will be rolling out the rest of the
bot refactors over the next months

medibots can now wear any type of hats! some of these hats can trigger
unique new recorded voicelines and interactions!

![chickembot](https://github.com/tgstation/tgstation/assets/138636438/09d4519d-0a34-4b7f-898b-260f894bfdce)

![hatbot](https://github.com/tgstation/tgstation/assets/138636438/088e0618-108d-4fb4-a29b-771cfa027fb3)

converts medbots into basic medbots. they are now a bit more responsive
than before but overall they should act similarly to how they did. also
adds the basic bot ai framework which has all the generic bot behaviors
that the next bots may or may not need to have in their ai. i tried my
best to improve their code and turned some of their bitflags into define
bitfields. this pr may need a careful review because i did it from
scratch as the old bot project branch was too outdated for me to use
:cl:
refactor: medbots are now basic bots. please report any bugs
add: medbots can wear hats!
/:cl:

* Update stage2.dm

* compile fixes

* Fix medibots (tgstation#80136)

Should fix advanced medkit medibots healing and also give back the
healing bonus to brute medkit medibots. Medibots should no longer leave
their healing pose in the middle of healing either. Player medibots
can't overheal.

It also readds any removed lines. And they can use robot emotes again.
Fixes tgstation#80135

Fixes!
:cl:
fix: Medibots made from advanced medkits works again
fix: Medibots made from brute medkits have their bonus healing again
fix: Medibots can use robotic emotes again
/:cl:

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>

* basic cleanbots refactor and new janitor skillchip (tgstation#80128)

this pr refacotrs cleanbots into basic bots. also adds a new skillchip
for janitrs. this skillchip will allow janitors to communicate with
cleanbots and order them around, like pointing at something and telling
them to clean it. also now the cleanbot has an inbuilt mop which it will
use to smack mice and cockroaches

refactors cleanbots into basic bots and fixes them getting stuck
sometimes while patrolling. also janitors being able to order them
around can make them a bit more useful as tools for the janitor

:cl:
refactor: cleanbots are refactored into basic bots. please report all
bugs
fix: fixes cleanbots getting stuck sometimes while patrolling
add: janitors get a new skillchip which allow them to communicate with
cleanbots
/:cl:

* compiling

* basic bot path huds and medbot research (tgstation#80277)

this pr integrates the bot path huds to ai controllers and move loops to
allow basic bots to display their paths in the hud.
also closes tgstation#80280 and closes tgstation#80330

basic bots now can display their path on huds

:cl:
add: basic bots can now display their paths on huds
fix: medbots can research healing again
/:cl:

* [no gbp] some few bot fixes (tgstation#80208)

i forgto to set this in my last prs closes tgstation#80204
also closes tgstation#80252

ais can summon bots

:cl:
fix: AIs can summon bots again
fix: cleanbots can clean floors directly underneath them and prioritize
floors nearest to them
fix: medbots drop empty medkits now
/:cl:

* fixes

* Basic mobs now use z-level turnoff instead of simple (tgstation#82469)

On one compile of MetaStation, I saw that there's 45 basic mobs on the
station, 256 on lavaland (the number growing from tendrils), and 59 in
all other z levels combined.

While we do expect Lavaland to be visited every round, at least it won't
be running during the times when no one is there, but even more
importantly, space exploration is something not done every round, so we
don't have any reason to waste our resources on AIs that will never be
interacted with.

Simple animals had an easy solution to this:
If no one is on the Z level, their AI turns off
If someone is on the Z level, they are idle unless needed.

The last simple animals that exists right now are bots, megafauna,
geese, gondolas, and some minor ones like mimic, zombie, dark wizard,
soulscythe, etc.
Point is, we're very much nearly done going through all simple animals,
so this code is being wasted just to ensure things like cleanbots won't
work if no one is on the z level, something I doubt happens often, so I
took their code and made it work for basic mobs instead. I could've done
both but I thought it would look very bad, and maybe this is a good
incentivize to get more basic mob conversions.

There's one major change here and it's that we're missing the "Idle"
mode, some basic mobs like the Lavaland village seems to be made with
intent that they'll be running even if players aren't around, so this
sets up a future PR that makes idle AI easier to add, and I want to make
sure those cases are taken into account.

We don't need to always be processing these basic mobs, and sets us in
the future to hopefully also implement idle AIs.

:cl:
balance: Basic mob AIs with no mobs on the Z level now stop.
/:cl:

---------

Co-authored-by: san7890 <the@san7890.com>

* Fixes AI lag by re-adding idle mode to all AI that was lost with the simple mob to basic mob conversion. (tgstation#82539)

* hygeienbots basic bots (tgstation#80435)

turns hygenic bots into basic bots. also now PAIs and people can play as
hygeinebots. and they can wear hats

transforms hyginebots into basic bots. their old AI used to handle all
the logic. i moved some of the logic to the mob itself so players can
also clean (or burn) things. also this pr will add pathing limits to
bots, in the case the jps movement thinks it can reach something, but
actually cant, in which case the bot will give up the chase

:cl:
refactor: hygeinebots are now basic bots. please report all the bugs
fix: fixes hygenebots not being able to patrol
add: hygeinebots can now be controlled by Players
/:cl:

* don't want these to idle

* Update goldgrub_ai.dm

* Update _ai_movement.dm

* ai controllers use cell trackers to know when to idle (tgstation#82691)

## About The Pull Request
this makes ai controllers use cell trackers and signals to determine
when to idle

## Why It's Good For The Game
might be better than looping over all clients for every controller

## Changelog
:cl:
code: The way mobs idle has been refactored, please report any issues
with non-reactive mobs
/:cl:

* Reworks targeting behavior to fall back onto proximity monitors. Refactors ai cooldowns a bit (tgstation#82640)

Nother bit ripped out of tgstation#79498
[Implements a get_cooldown() proc to get around dumb manual overrides
and empower me to optimize the findtarget
logic](tgstation@7047d29)

[Adds modify_cooldown, uses it to optimize find_potential_targets
further](tgstation@4ebc8ce)

No sense running the behavior if we're just waiting on its output, so
let's run it once a minute just in case, then push an update instantly
if we find something

[Optimizes connect_range and
promxity_monitors](tgstation@bcf7d7c)

We know what turfs exist before and after a move
We can use this information to prevent trying to update turfs we don't
care about.

This is important because post these changes mobs with fields will be
moving a lot more, so it's gotta be cheap

[Implements a special kind of field to handle ai
targeting](tgstation@80b63b3)

If we run targeting and don't like, find anything, we should setup a
field that listens for things coming near us and then handle those
things as we find them.

This incurs a slight startup cost but saves so much time on the churn of
constant costs

Note:
We should also work to figure out a way to avoid waking ais if none is
near them/they aren't doing anything interesting

We don't need to do that immediately this acts as somewhat of a stopgap
(and would be good regardless) but it is worth keeping in mind)

I am unsure whether this is worth it anymore since tgstation#82539 was merged. As
I say it was done as a stopgap because ais didn't know how to idle.
If not I'll rip er out and we'll keep the other
refactoring/optimizations.

Cleaner basic ai code, maybe? faster basic ai code, for sure faster
proximity monitors (significantly)

* compiles

* more

* Update oldstation.dmm

* Update _ai_controller.dm

* Update _ai_controller.dm

* Update _ai_controller.dm

---------

Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Improvement Code is now easier to copy paste. Performance Uses the 32-bit address space and slow interpreter more effectively
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants