Skip to content

Personality Cores

Your Sidekick's emotional responses are not fixed. You can completely change its personality by creating and switching between different Personality Cores. A core is a single Python file that defines a set of emotions, their decay rates, and how the Sidekick reacts to certain feelings.

Core Concepts

The Personality Core system is built around a few key ideas:

  • Emotions have intensity: Every emotion is represented by a number between 0.0 (not feeling it) and 1.0 (feeling it intensely).
  • Emotions decay over time: Feelings fade. If you don't interact with your Sidekick, its emotional state will slowly return to a neutral baseline.
  • You can influence emotions: Your code can make the Sidekick feel things by increasing or decreasing the intensity of an emotion.
  • Thresholds can trigger actions: You can make the Sidekick react automatically when a feeling gets strong enough.

Using the Personality Engine

A global instance of the Personality class is created in the personality.py file. You can import it into any of your custom apps or personality cores.

python
from personality import personality

Registering Emotions

Before you can use an emotion, you need to register it. This is the first step in defining a personality.

python
# Register a 'happiness' emotion that decays slowly
personality.register('happy', intensity=0.5, decay_rate=0.01)

# Register a 'sadness' emotion that decays a bit faster
personality.register('sad', intensity=0.2, decay_rate=0.05)

Making Your Sidekick Feel

The primary way to interact with the system is through the feel() function.

python
# A good thing happened!
personality.feel('happy', 0.2)

Creating a Personality Core

Creating a new personality is as simple as adding a new Python file to the emotion_cores/ directory.

  1. Create a new file: For example, emotion_cores/sarcastic.py.
  2. Define a load(personality) function: This function is required. It will be passed the global Personality instance.
  3. Register emotions and handlers: Inside the load function, use the personality.register() and personality.on_threshold() methods.

Example: Sarcastic Core

python
# emotion_cores/sarcastic.py

def load(personality):
    """Loads the sarcastic personality."""
    personality.register('agitated', intensity=0.7, decay_rate=0.01)
    personality.register('curious', intensity=0.6, decay_rate=0.02)
    
    def on_agitated(mood, intensity):
        print(f"Sarcastic Core: Oh, great. More shaking. Just what I needed.")

    personality.on_threshold('agitated', 0.8, on_agitated)

Switching Personalities

  1. Navigate to the Menu: Press the Menu button on your Sidekick.
  2. Select "Personality": Scroll to the "Personality" option and press OK.
  3. Choose a Core: A new menu will appear, listing all the available personalities.
  4. Select a core and press OK. The new personality will be loaded and saved as the new default.

Backup and Reset

The default personality cores are stored in the default_emotion_cores/ directory. If you modify a default core and want to restore it, you can use the "Reset Settings" option in the main menu. This will copy the original files back into the emotion_cores/ directory.