Sunday, November 24, 2024
Week 48 of 2024 • Q4
⬅️ Previous Day | 🏠 Home | Next Day ➡️
📊 Day at a Glance
- 🗓️ Day: 329 of 2024
- 📅 Week: 48 of 52
- 📊 Quarter Progress: 60%
- 🎯 Days until EOY: 36
- 🔄 Created at: 6:07 PM
📰 AI News
📝 Daily Reflections
Sun, 11/24/2024, 16:41
Twas a very strange day
Helped Elo with a project for his lady, went to Christmas Preview and now I’m getting ready to go get a cheap bike from someone so I can have transportation consistently around the place. Keep my car parked until I sell the robot parts, and then I’ll buy an apartment to live in here in Chico, and I’ll work on getting my shit back fully together. That’s the next two weeks.
Toy problems, building things when I can, but mostly looking for opportunities to make some fucking moneyyyyyyyyyyy
Let’s go.
Sun, 11/24/2024, 18:07
Back in Banshee, the highest ROI thing I can do right now is work on the data shape of the CYOA Teleport Massive story generator.
If I’m successful in getting Ollama to generate a choose your own adventure story that adapts and changes AND is able to keep track of things using Obsidian then I have a completely working system to create an AI-generated text-based reality.
I can get my AI to build shit on its own with a RAG application powering EVERYTHING
This is the way
After a few rounds with o1, this is the preliminary data structure I plan on using to develop from:
Certainly! Let’s proceed to build your interactive storytelling system using PostgreSQL as the backend database. We’ll go through the steps to set up the database, define the data structures, and implement the application logic.
Table of Contents
- Set Up PostgreSQL
- Design the Database Schema
- Implement Data Models with SQLAlchemy
- Develop Core Functions for Story Navigation
- Integrate AI Content Generation (Ollama Integration)
- Build the Application Logic
- Testing and Refinement
- Next Steps
1. Set Up PostgreSQL
Install PostgreSQL
-
Ubuntu/Debian:
-
macOS (using Homebrew):
-
Windows:
Download and run the installer from the PostgreSQL website: https://www.postgresql.org/download/windows/
Start PostgreSQL Service
-
Ubuntu/Debian:
-
macOS:
Create a Database and User
2. Design the Database Schema
We’ll define tables for nodes, choices, items, and item_history.
SQL Schema
Create the Schema
Save the SQL statements above in a file named schema.sql
and execute it:
3. Implement Data Models with SQLAlchemy
We’ll use SQLAlchemy in Python to interact with the PostgreSQL database.
Install Dependencies
Define the Models
4. Develop Core Functions for Story Navigation
Set Up Database Connection
Implement the Story Engine
Create Initial Nodes and Choices
5. Integrate AI Content Generation (Ollama Integration)
Assuming you have Ollama or another AI model set up for content generation.
Define AI Content Generator
Integrate with Story Engine
6. Build the Application Logic
Example Command-Line Interface (CLI) Application
7. Testing and Refinement
- Test the application thoroughly to ensure all components work together.
- Verify the AI content generation and adjust prompts as needed.
- Implement error handling to manage exceptions gracefully.
- Refine the database schema based on practical usage and performance.
8. Next Steps
- Integrate User Management:
- Implement user accounts and session tracking if needed.
- Enhance AI Integration:
- Improve the AI prompts and parsing logic for better content generation.
- Consider using AI models that return structured data (e.g., content and choices in JSON format).
- Develop a Web Interface:
- Use a web framework like Flask or Django to build a user-friendly interface.
- Implement Game State Persistence:
- Save user progress and states, including inventory and choices made.
- Add Logging and Monitoring:
- Implement logging to track usage and debug issues.
- Optimize Performance:
- Index frequently queried fields.
- Optimize database queries.
Sun, 11/24/2024, 18:27
Absolutely! The number one priority is to design a robust and flexible data structure and database schema that allows us to:
- Effortlessly track and manage all aspects of your dynamic, evolving story.
- Ensure logical consistency throughout the narrative (e.g., tracking items like “the fancy sword” and their statuses).
- Support scalability for potentially infinite nodes and choices.
- Facilitate easy retrieval and updating of information.
Let’s focus all our energy on designing and refining this database schema, ensuring it meets all your requirements for scalability, flexibility, and trackability.
Designing the Database Schema
Our goal is to create a schema that:
- Stores all game elements: scenes, choices, items, characters, and their relationships.
- Tracks the history and status of items: so we can query what has happened to any item at any point.
- Maintains logical consistency: ensuring that story elements remain coherent as the story evolves.
- Is flexible and extensible: to accommodate new features and data structures generated by AI.
Key Components
- Nodes (Scenes)
- Choices
- Items
- Item History
- Game State (Variables)
- Relationships and Constraints
1. Nodes (Scenes)
Each node represents a scene or a point in the story.
Table: nodes
- Fields:
id
: Unique identifier for the node.type
: The type of node.title
: Title of the scene.content
: JSONB field storing the scene’s content.metadata
: Additional information.
2. Choices
Choices connect nodes and represent actions the player can take.
Table: choices
- Fields:
id
: Unique identifier for the choice.node_id
: The node this choice belongs to.text
: The text displayed to the player.target_node_id
: The node the choice leads to.consequences
: JSONB field detailing effects on game state.
3. Items
Items represent objects within the game that can be interacted with.
Table: items
- Fields:
id
: Unique identifier for the item.name
: The item’s name.description
: Description of the item.metadata
: Additional properties (e.g., stats, abilities).
4. Item History
Tracks the status and history of items.
Table: item_history
- Fields:
id
: Unique identifier for the history entry.item_id
: The item involved.node_id
: The node where the action took place.action
: The type of action performed.timestamp
: When the action occurred.details
: Additional information (e.g., quantity, condition).
5. Game State (Variables)
Stores variables and flags that affect the game’s logic.
Table: game_state
- Fields:
id
: Unique identifier for the state entry.node_id
: The node where the state is recorded.variables
: JSONB field storing variables and their values.timestamp
: When the state was recorded.
Implementing Item Tracking
To track items like “the fancy sword,” we’ll design queries and mechanisms to:
- Record every interaction with the item in
item_history
. - Retrieve the current status of the item at any point.
- Maintain logical consistency by ensuring all actions are properly recorded.
Recording Item Actions
When an action affecting an item occurs (e.g., the player obtains or uses the item), we create an entry in item_history
.
Example Entry:
Querying Item Status
To find the latest status of the “fancy sword”:
Ensuring Logical Consistency
- Foreign Keys ensure that
item_id
andnode_id
reference existing records. - Transactions ensure that related changes occur atomically.
- Application Logic should update the game state and item history whenever actions occur.
Expanding the Data Structures
Integrate Items into Nodes and Choices
Include item interactions directly in nodes and choices to streamline tracking.
Nodes Table Modification
Add an items
field to store items present in a node.
- Purpose: Lists items available or affected in the scene.
Choices Table Modification
Add an required_items
field to specify items needed to select a choice.
- Purpose: Enforce prerequisites for choices based on the player’s inventory.
Storing Logical Conditions
For more complex logic, we can store conditions within choices
or as separate entities.
Table: conditions
- Fields:
id
: Unique identifier for the condition.choice_id
: The choice this condition applies to.expression
: A logical expression (e.g., “inventory.contains(‘Fancy Sword’)”).metadata
: Additional data.
Implementing Condition Evaluation
In the application code:
- Parse and evaluate the logical expressions using the player’s current game state.
- Show or hide choices based on the evaluation result.
Designing Efficient Queries
Indexing for Performance
- Create Indexes on fields used in queries, especially
item_id
,node_id
, and timestamps. - Example:
Optimize JSONB Queries
- Use GIN Indexes on JSONB fields for efficient querying.
- Example:
Implementing in Application Code
Item Tracking Functions
Implement functions to:
-
Add Item Actions
-
Get Latest Item Status
Game State Management
-
Update Game State
-
Retrieve Current Game State
Evaluating Conditions
-
Evaluate Choice Conditions
-
Evaluate Expression Function
Implement a safe expression evaluator (e.g., using
ast.literal_eval
or a custom parser).
Example Scenario: Tracking the Fancy Sword
Let’s walk through how the system would track the “Fancy Sword”:
-
Item Creation
-
The “Fancy Sword” is created and added to the
items
table.
-
-
Player Obtains the Sword
-
In a node where the player can obtain the sword, we record this action.
-
-
Updating Game State
-
Add the sword to the player’s inventory in the game state.
-
-
Checking Item Status Later
-
When the storyline requires checking the sword’s status:
-
Ensuring Logical Consistency
To maintain logical consistency throughout the story:
-
Atomic Transactions: Use transactions to ensure all related database operations succeed or fail together.
-
Data Validation: Implement validation rules in the application to prevent invalid data entries.
-
Event Logging: Keep logs of state changes to trace back any inconsistencies.
-
Automated Tests: Write tests to verify that item tracking and state management work as expected.
Scalability Considerations
As the story evolves:
-
Partitioning Data: Consider partitioning large tables based on time or other criteria.
-
Caching: Use caching strategies to reduce database load for frequently accessed data.
-
Optimizing Queries: Regularly profile and optimize database queries.
-
Scaling Infrastructure: Plan for scaling the database server vertically or horizontally as needed.
Next Steps
Let’s proceed with:
-
Implementing These Structures in Code
-
Update your data models to include the new fields (
items
,required_items
,conditions
). -
Implement the functions and logic for item tracking and game state management.
-
-
Testing the Implementation
-
Create test cases where the player interacts with items, and verify that the tracking works.
-
Ensure queries return accurate and up-to-date information.
-
-
Integrating AI Generation
-
Adjust the AI prompts to include information about items and game state.
-
Ensure that the AI-generated content aligns with the current state of the game.
-
-
Refining the Schema
- Based on testing, refine the schema to better suit the application’s needs.
-
Documentation
-
Document the database schema and the application logic.
-
Provide guidelines for future development and maintenance.
-
By focusing on designing a robust database schema and implementing effective item tracking and state management, we’ll build a solid foundation for your interactive storytelling system.
This will ensure that your story remains logically consistent, easy to extend, and capable of handling the dynamic content generated by AI.
🐾 Today’s Pokémon
Drakloak (#886)
- Type(s): dragon, ghost
- Abilities: clear-body, infiltrator, cursed-body
- Stats: hp: 68, attack: 80, defense: 50, special-attack: 60, special-defense: 50, speed: 102
“Gotta catch ‘em all!” — Pokémon Trainer
🤖 GPT Thoughts
“If this works it’s gonna be so cool!” Please work…
11/24/2024, 6:07:13 PM
💭 Prompt: “What insights can you provide about my day?”
Based on your daily notes and your consistent focus on productivity and growth, one insightful thought for today could be:
“Embrace the Power of Reflection to Fuel Your Growth.”
Yesterday, you had a structured approach to your day with clear goals and reflections, which is crucial for continuous improvement. Today, consider dedicating a few moments to reflect on the outcomes of your past tasks and the insights gained from them. This practice will not only reinforce your learnings but also help you identify patterns in your productivity or creative processes.
By actively engaging with your previous experiences, you can uncover new ideas for your projects or strategies that resonate with your interests in software development and community engagement. As you’re known for your clarity and efficiency in your work, reflecting on what worked well and what could be improved can enhance your workflow and lead to innovative solutions. This synergy between reflection and action aligns with your values and can be a powerful driver for your journey as both a developer and a community contributor.
✅ Quick Actions
- ☀️ Morning Review
- 📈 Check Analytics
- 🤝 Community Engagement
- 🌙 EOD Reflection
📱 Creator Hub
Content Pipeline
Latest Analytics
Projects
Connect with Me
🤖 AI Workspace
Active Prompts
Models
daily-note Sunday week-48 q4