This repository contains code for an interactive text-based adventure game called "Temporal Traverse." Players will navigate a character named Alex through various time periods, making choices that determine the narrative's path and, ultimately, Alex's fate. The game is powered by Cassandra for chat history and AI-based language model from OpenAI to generate responses.
- Python 3.x
- A Cassandra cluster (or use AstraDB) to store chat history
- OpenAI API key for language generation
-
Cassandra Configuration
- Ensure you have a Cassandra cluster or AstraDB set up. Update the
cloud_config
variable with the appropriate credentials in the code. - Replace
secure-connect-choose-your-adventure.zip
with the bundle corresponding to your Cassandra or AstraDB setup.
- Ensure you have a Cassandra cluster or AstraDB set up. Update the
-
Environment Variables
- Store your Cassandra and OpenAI credentials in a file named
token.json
. - Set up a
.env
file and add theOPENAI_API_KEY
variable.
- Store your Cassandra and OpenAI credentials in a file named
-
OpenAI API Key
- To provision an OpenAI API key, visit OpenAI's website and create an API key. Insert this key as the value for
OPENAI_API_KEY
in your.env
file.
- To provision an OpenAI API key, visit OpenAI's website and create an API key. Insert this key as the value for
-
Vector Database Provisioning
- This game uses Cassandra for chat history storage, but you can also integrate a Vector Database for advanced functionalities. Provision a Vector Database for an additional data layer to support complex data queries and analysis.
-
Game Rules and Narrative
- The game's narrative and rules are defined within the Python script. Players will guide Alex through the Temporal Traverse, making decisions that impact the storyline. The game ends when a path leads to "The End."
-
Execution
- Run the Python script to start the game.
bashCopy code
python connect-database.py
-
Gameplay
- The game initiates by choosing a time-travel device for transportation.
- Players will encounter decision points where they must make choices, each affecting the story's direction.
- After three decision points, paths leading to potential character death are presented, and the game ends upon encountering "The End."
The game utilizes a chat history stored in Cassandra through CassandraChatMessageHistory
. This context aids the AI model (LLMChain) from OpenAI to generate responses based on the player's input and the established narrative template.
Contributions are welcome! If you wish to enhance the game, feel free to fork the repository and submit a pull request with your changes.
This project is licensed under MIT License. Feel free to modify and distribute it as per the license terms.
This game is a demonstration and should be used responsibly. The AI-generated content might not always follow a predictable or desired path due to its learning nature.
Thank you for checking out the Temporal Traverse Adventure Game repository. Enjoy your journey through time and storytelling! If you have any queries or suggestions, feel free to reach out or create an issue in the repository.