Skip to content

Conversation

@CroilBird
Copy link
Contributor

@CroilBird CroilBird commented Jul 19, 2025

About the PR

Added the ability for Polly the parrot to commit memories to the database

This is basically exactly the implementation I had in mind, but in terms of functionality I am looking for input regarding:

  • How much the parrot should learn
  • How long the messages should be retained.
  • Whether the admin tooling needs changes

I hope the UI code is sane and I am doing the async stuff correctly.

Why / Balance

SS13 did it. Fun. Gaslights players into thinking there's a tesloose/zombie/murderous ninja/nukies if they don't read who's saying it.

Technical details

General

Several-thousand LOC PR to make a parrot funny.

Overall, the following: Players who have at least 10 hours of playtime and who pass all the basic learning checks of the ParrotMemoryComponent/System, have their messages committed to the database.

Memories are kept for 7 days at the time of writing.

Before we start, how much data is being saved, here?

I made a python script to fill the parrot memory table full of messages by simulating:

  • Rounds of between 30 minutes and 2 hours
  • a parrot that is almost constantly being talked to, 24/7, learning a new message every 60-80 seconds
  • a cutoff of max 7 days (as is the current limit in this PR)
  • simulated lobby times, 2.5 minutes for end round and 5 minutes for lobby.

This would add something like 6,5k messages to the database, an average of 62 per round, and kept 103 rounds.

With multiple servers this would be more, but it should give you a decent indication of how much is stored in the database.

I don't want to think about how much actually ends up being used.

Database

This adds a table to the database that contains parrot memories. It stores:

  • Text of the message
  • Source player from whom the memory came
  • Round id the memory was created in
  • The creation time of the memory
  • whether or not the memory is blocked

Adds a bunch of functions to retrieve/update these memories for parrots and for admins.

Components

Adds a ParrotDbMemoryComponent. Only contains the next refresh time point

Systems

Adds a ParrotDbSystem, which:

  • Adds memories to the database when an entity with a ParrotMemoryComponent and a ParrotDbMemoryComponent learns a new chat message
  • Fills the ParrotMemoryComponent with new memories when the refresh time point is passed
  • Truncates old memories when the round starts
  • Blocks all memories belonging to a player if they are erased

Admin tooling

Adds a Parrot Memory browser window. This allows admins to:

  • View blocked and unblocked memories per round
  • Block and unblock messages manually
  • Filter messages in a round by text
  • Ahelp users who created a message

When a player is erased it sets all parrot memories sourced from that player to blocked.

CCVars

Adds four CCVars:

  • parrot.db_refresh_interval: How often a parrot's round memory is filled/refreshed with memories from the database
  • parrot.db_refresh_num_memories: How many memories to retrieve from the database
  • parrot.db_min_overall_playtime: The minimum overall playtime of a player before their messages are committed to the database
  • parrot.db_max_memory_age: The maximum age of memories before they are truncated.

Anything else?

Yes this fixes removing parrot memories from a player when they're erased. That was broken in certain cases, I didn't test it well enough.

Media

Basics - polly's inter-round memory

1.mp4

Admin tooling - Memory manager basics

2_s.mp4

Admin tooling - Blocking messages

3_s.mp4

Admin tooling - Erasing players and ahelping

4_s.mp4

Admin tooling - Filtering message text

5_s.mp4

Requirements

Breaking changes

Changelog

🆑 Crude Oil

  • add: Polly the Parrot now retains messages across rounds

ADMIN:

  • add: A panel to manage persistent parrot memory was added to the admin menu


// order isn't important in this list so we can use the faster means of removing
memoryComponent.SpeechMemories.RemoveSwap(i);
i--;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes a bug that I didn't catch in the last PR, this wasn't clearing messages correctly.

@CroilBird
Copy link
Contributor Author

I am guessing my substandard understanding of async and how we interact with the database is failing the tests. I'll have a look into it.

@notquitehadouken
Copy link
Contributor

me whispering "SHITSEC" 800 times every round to the bird

@PJBot PJBot added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. labels Jul 20, 2025
@beck-thompson beck-thompson removed the S: Awaiting Changes Status: Changes are required before another review can happen label Jul 20, 2025
@CroilBird
Copy link
Contributor Author

CroilBird commented Jul 25, 2025

I'm going to tweak this a bit more today and add one or two things.

I lied I'll do it tomorrow

@CroilBird
Copy link
Contributor Author

I thought about adding a pin functionality, allowing messages to stay forever if an admin deems them based, and adding pagination to the parrot messages UI so it'd show like 10 pages at a time.

But I'd rather not touch the UI at all anymore and defer to whatever input maints or admin have in the reviews instead.

@PJBot PJBot removed the size/XL Denotes a PR that changes 5000+ lines. label Jul 29, 2025
@ScarKy0
Copy link
Contributor

ScarKy0 commented Jul 29, 2025

Why block messages and not just remove them forever? Are blocked messages gonna be always acceasible via the menu?

@CroilBird
Copy link
Contributor Author

Why block messages and not just remove them forever? Are blocked messages gonna be always acceasible via the menu?

Yes, blocked words stay there forever. The blocked words are also supposed to never be re-learnt by parrots. I seem to have forgotten to actually implement this part, though. I'll do that still.

It'd be a very low effort way of filtering what the parrots can learn if people keep trying to teach the parrots the same bad things.

@ToastEnjoyer ToastEnjoyer added P3: Standard Priority: Default priority for repository items. T: New Feature Type: New feature or content, or extending existing content D3: Low Difficulty: Some codebase knowledge required. A: General Interactions Area: General in-game interactions that don't relate to another area. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Aug 5, 2025
@iaada iaada added S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. size/XL Denotes a PR that changes 5000+ lines. labels Aug 12, 2025
@CroilBird
Copy link
Contributor Author

Made it so blocked words are never learnt again, and also added a cvar for the number of memories a parrot retrieves from the database every time it refreshes.

I noticed that people really like it when they see a parrot has learnt something from them and see it parroted, and the old behavior would just replace everything in the parrot's memory. With the cvar set at the default 15 it should only replace some of the messages learned in the current round.

@superjj18

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: General Interactions Area: General in-game interactions that don't relate to another area. Changes: UI Changes: Might require knowledge of UI design or code. D3: Low Difficulty: Some codebase knowledge required. P3: Standard Priority: Default priority for repository items. S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. size/XL Denotes a PR that changes 5000+ lines. T: New Feature Type: New feature or content, or extending existing content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants