-
Notifications
You must be signed in to change notification settings - Fork 3
CharacterManagers
In Pantella, character managers are used to manage characters in the game. The character manager is responsible for managing a character after they're added to a conversation, saving characters, managing the character in the game, and managing the character's memory manager.
The character manager class is a class that manages characters in the game. The character manager class has the following methods and properties:
-
__init__(self,conversation_manager): Initializes the character manager. Theconversation_managerparameter is the conversation manager that the character manager is associated with. -
age: Returns the age of the character. -
race: Returns the race of the character. -
in_game_race: Returns the in game race of the character. -
gender: Returns the gender of the character. -
age_title: Returns the age title of the character. -
gendered_age: Returns the gendered age of the character. -
_prompt_style: Returns the prompt style of the character or the default prompt style if the character does not have a prompt style override. -
prompt_style: Returns the prompt style of the character. -
language: Returns the language of the character. -
language_code: Returns the language code of the character. -
tts_language_code: Returns the TTS language code of the character. -
save_knows(self): Saves the characters that the character knows to a file. -
load_knows(self): Loads the characters that the character knows from a file. -
meet(self, other_character_name, add_game_events=True): Adds a character to the character's known characters. -
conversation_manager: Returns the conversation manager that the character manager is associated with. -
config: Returns the config of the conversation manager. -
get_perspective_identity(self, name, race, gender, relationship_level=0): Returns the perspective identity of the character. -
get_perspective_player_identity(self): Returns the perspective identity of the player. -
update_game_state(self): Updates the game state of the character. -
replacement_dict: Returns a dictionary of replacement strings for the character to use in the prompts. -
memories: Returns the memories of the character's memory manager. -
say(self,string, remember=True): Says a string in the game and adds it to the conversation history. -
leave_conversation(self): Leaves the conversation. -
after_step(self): Performs a step in the memory manager after the conversation step. -
before_step(self): Performs a step in the memory manager before the conversation step. -
reached_conversation_limit(self): Ran when the conversation limit is reached. Some memory managers may need to perform some action when the conversation limit is reached. -
add_message(self, msg): Adds a message to the character's memory manager. -
check_for_new_knows(self, msg, add_game_events=True): Checks if the character has met a new character. -
__str__(self): Returns a string representation of the character.
Initializes the character manager. The conversation_manager parameter is the conversation manager that the character manager is associated with. When creating a new character manager, you should call the parent class's __init__ method to ensure that the default character manager is loaded.
Returns the age of the character.
Returns the race of the character.
Returns the in-game race of the character.
Returns the gender of the character.
Returns the age title of the character.
Returns the gendered age of the character.
Returns the prompt style of the character or the default prompt style if the character does not have a prompt style override.
Returns the prompt style of the character.
Returns the language of the character.
Returns the language code of the character.
Returns the TTS language code of the character.
Saves the characters that the character knows to a file.
Loads the characters that the character knows from a file.
Adds a character to the character's known characters. The other_character_name parameter is the name of the character that the character is meeting. The add_game_events parameter is a boolean that determines if game events should be added when the character meets the other character.
Returns the conversation manager that the character manager is associated with.
Returns the config of the conversation manager.
Returns the perspective identity of the character. The name parameter is the name of the character. The race parameter is the race of the character. The gender parameter is the gender of the character. The relationship_level parameter is the relationship level of the character.
Returns the perspective identity of the player.
Updates the game state of the character.
Returns a dictionary of replacement strings for the character to use in the prompts. This is the dictionary used when formatting prompts with the character's information.
Returns the memories in the character's memory manager.
Says a string in the game and adds it to the conversation history. The string parameter is the string that the character is saying. The remember parameter is a boolean that determines if the string should be remembered in the character's memory manager.
Leaves the conversation.
Performs a step in the memory manager after the conversation step.
Performs a step in the memory manager before the conversation step.
Ran when the conversation limit is reached. Some memory managers may need to perform some action when the conversation limit is reached.
Adds a message to the character's memory manager. The msg parameter is the message that is being added.
Checks if the character has met a new character. The msg parameter is the message that is being checked. The add_game_events parameter is a boolean that determines if game events should be added when the character meets the other character.
Returns a string representation of the character. This is the string that is displayed when the character is printed.
When creating a new character manager, you should inherit from the base character class. This ensures that the character manager has access to the base character class's methods and properties. To inherit from the base character class, you should create a new Python file in the ./src/character_managers/ directory and import the base character class. You should then create a new class that inherits from the base character class and implement any additional methods or properties that are required for your character manager.
print("Loading custom_character_manager.py")
from src.logging import logging
import src.character_managers.base_character as base_character
logging.info("Imported required libraries in custom_character_manager.py")
manager_slug = "custom"
valid_games = ["custom"]
class Character(base_character.Character):
def __init__(self, characters_manager, info):
super().__init__(characters_manager, info)
# Add custom methods and properties here as needed