Skip to content

Commit

Permalink
Merge pull request #13 from Bradymck/master
Browse files Browse the repository at this point in the history
Aqua Prime game bots
  • Loading branch information
Bradymck committed Sep 3, 2023
2 parents 9e5a1f3 + 1da3896 commit f398835
Show file tree
Hide file tree
Showing 13 changed files with 1,153 additions and 142 deletions.
136 changes: 0 additions & 136 deletions .gitignore

This file was deleted.

66 changes: 66 additions & 0 deletions AquaPrime/APICounter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import datetime


class APICounter:
"""
APICounter is a Python class that implements a simple counter system to track and limit the number of requests
allowed per day for each user.
Attributes:
max_requests_per_day (int): The maximum number of requests allowed per day.
requests (dict): A dictionary that stores the request count for each user, keyed by user ID.
Methods:
__init__(self, max_requests_per_day):
Initializes a new instance of the APICounter class with the specified maximum limit of requests per day.
check_limit(self, user_id):
Checks if the user has exceeded the maximum number of requests allowed per day based on the current date.
If the user has not exceeded the limit, updates the request count for the user and returns True. If the user
has exceeded the limit, returns False.
Usage:
# Create an instance of APICounter with a maximum limit of 5 requests per day
counter = APICounter(5)
# Example usage in your API endpoint
user_id = "user123"
if counter.check_limit(user_id):
# Process the API request for the user
print("API request processed.")
else:
print("API request limit exceeded.")
"""
def __init__(self, max_requests_per_day):
"""
Initializes a new instance of the APICounter class with the specified maximum limit of requests per day.
Args:
max_requests_per_day (int): The maximum number of requests allowed per day.
"""
self.max_requests_per_day = int(max_requests_per_day)
self.requests = {}

def check_limit(self, user_id):
"""
Checks if the user has exceeded the maximum number of requests allowed per day based on the current date.
If the user has not exceeded the limit, updates the request count for the user and returns True. If the user
has exceeded the limit, returns False.
Args:
user_id (str): The ID of the user making the API request.
Returns:
bool: True if the user has not exceeded the request limit, False otherwise.
"""
today = datetime.date.today()
if user_id not in self.requests:
self.requests[user_id] = {"date": today, "count": 0}
elif self.requests[user_id]["date"] != today:
self.requests[user_id]["date"] = today
self.requests[user_id]["count"] = 0

if self.requests[user_id]["count"] < self.max_requests_per_day:
self.requests[user_id]["count"] += 1
return True
else:
return False
94 changes: 94 additions & 0 deletions AquaPrime/_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Aqua Prime Grumpy Cat AI Documentation

## Overview

The Aqua Prime Grumpy Cat AI is a component of the Aqua Prime game—a Discord-based Tabletop Role-Playing Game (TTRPG) that combines economic strategy, education about cryptocurrency, and interactive storytelling. The Grumpy Cat AI serves as the game's Dungeon Master, providing witty and humorous responses in the character of Grumpy Cat to players' interactions and inquiries. The AI utilizes OpenAI's GPT-3.5 engine to generate contextually relevant and engaging responses.

# Purpose

The Grumpy Cat AI enhances players' immersion within the Aqua Prime universe by delivering responses that align with the in-game narrative and player interactions. The AI takes on the persona of Grumpy Cat, a popular internet meme, and maintains character throughout interactions, contributing to the satirical and entertaining nature of the game.

# Key Features

Contextual Responses: The AI leverages past player messages and interactions to build context. It includes both recent in-game conversations (RAM) and long-term history (HDD) of player interactions to provide more personalized and relevant responses.

Dynamic Prompts: The AI constructs prompts for the OpenAI GPT-3.5 engine that include:

## Operating System (OS) Section: A static game world setting description

### Hard Disk Drive (HDD) Section: Historical information about the player and related users

### Random Access Memory (RAM) Section: Recent in-game conversation messages

### System Section: Grumpy Cat's character and role description

### User Input Section: The current user's input message

### Mentioned Users Section: Any mentioned users in the input message

### Collaborative Storytelling: The AI facilitates collaborative storytelling within the Aqua Prime universe, driving engaging role-playing interactions between players and NPCs

## Usage

Players interact with the Grumpy Cat AI through Discord messages. When the AI is mentioned in a message, it processes the message's context, retrieves historical data from a MongoDB database, searches for additional context in Weaviate, and constructs a prompt for the OpenAI engine. The AI generates a response based on the prompt and delivers it back to the Discord channel.

## Components

### WeaviateClient: A class that interfaces with Weaviate, an external data source, to retrieve context relevant to player interactions

### OpenAI: A class that interacts with the OpenAI GPT-3.5 engine to generate responses based on prompts

### Bot Framework: The Discord bot framework handles interactions with the Grumpy Cat AI, retrieves historical messages, constructs prompts, and delivers AI-generated responses to the Discord channel

# Implementation

The Grumpy Cat AI is integrated with the Aqua Prime Discord bot using Python. The codebase consists of classes for interfacing with external data sources, creating prompts, and generating AI responses. The AI maintains Grumpy Cat's character by using the same tone, language, and humor expected from the meme.

# Conclusion

The Aqua Prime Grumpy Cat AI enhances the immersive experience of the Aqua Prime game by providing contextually relevant and entertaining responses. By taking on the role of the iconic Grumpy Cat, the AI adds a layer of humor and engagement to player interactions, contributing to the unique and engaging gameplay of Aqua Prime.

# Commands

### Dice Rolling feature (Roll Table)

Discord Dice rolling bot that scales the dice to the size of the library items in 'effects', will also allow /shoot commands, /res commands to ressurect a player that was shot
If you roll a one with !roll it will change the user name to 'Frog', Give them the role ''@🐸'', and time them out for 8 hours. (Other functions to come)

Discord Commands Module Documentation
Overview
The Discord Commands Module provides various commands for players within the Aqua Prime game—a Discord-based Tabletop Role-Playing Game (TTRPG). These commands enable players to engage in various in-game actions, from attacking to casting spells, adding depth and interactivity to the gameplay experience.

Purpose
The purpose of this module is to enhance player engagement by offering a range of interactive commands that align with the Aqua Prime game's narrative and mechanics. Players can execute commands to perform in-game actions, such as attacking, shooting, rolling dice, and casting spells, contributing to collaborative storytelling and entertainment.

Key Features
Attack Command (!attack): Allows players to roll a twenty-sided die (d20) and calculate the attack total by adding a specified modifier. Players are then presented with the roll result, modifier, and total value.

Shoot Command (!shoot): Enables players to "shoot" a targeted user with a fictional gun. If specific conditions are met, the target user's role is modified, resulting in a humorous response.

Resurrection Command (!res): Grants players with a special role the ability to "resurrect" another user by modifying their roles. This command introduces a strategic aspect to the game.

Dice Roll Command (!dice): Allows players to roll two six-sided dice (2d6) and calculates the total of the rolls. The command then displays the individual rolls and the total value.

Spell Cast Command (!spell): Enables players to cast a random spell from a spell book, which has various effects on the player or the environment. Each spell is associated with a unique outcome.

Usage
Players within the Aqua Prime Discord server can utilize the provided commands by entering them in the chat. Each command is prefixed with ! to distinguish it as a command. Players can engage in diverse interactions and actions using these commands, contributing to the overall gameplay experience.

Components
Attack Command (!attack): Rolls a d20, calculates the total with a specified modifier, and provides the player with a roll result, modifier, and total value.

Shoot Command (!shoot): Simulates a user shooting another user, applying role modifications if specific conditions are met.

Resurrection Command (!res): Allows players with a special role to resurrect another user by modifying roles.

Dice Roll Command (!dice): Rolls 2d6 and calculates the total, displaying both individual roll results and the total.

Spell Cast Command (!spell): Enables players to cast a random spell with various effects, adding an element of unpredictability to the game.

Implementation
The Discord Commands Module is implemented using the Discord.py library in Python. Each command is defined as a function within the module and is prefixed with the command prefix !. The module handles interactions, calculations, role modifications, and responses, enhancing the interactive gameplay experience within the Aqua Prime game.

Conclusion
The Discord Commands Module enriches the Aqua Prime gameplay by providing players with an array of interactive commands that align with the game's narrative and mechanics. By offering a variety of actions, from attacking to casting spells, the module contributes to collaborative storytelling, engagement, and entertainment within the Aqua Prime TTRPG universe.
55 changes: 55 additions & 0 deletions AquaPrime/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from context import process_os_context, process_hdd_context, process_ram_context, process_user_context

def process_os_context():
# Replace with your logic to process OS context from your game world data
os_context = '''"Role: OS
Setting: Aqua Prime, a virtual world where players engage in a multifaceted TTRPG experience.
Factions:
- Economic Factions: Focus on trading, crafting, mining, and resource management.
- Exploration Factions: Emphasize discovery, adventure, and mapping uncharted territories.
- Cultural Factions: Engage with narrative, memes, pop culture, and satire.
- Technological Factions: Concentrate on AI development and technological advancement.
Roles:
- Players join or create factions with unique goals and culture.
- Leadership structures vary across factions.
Bots:
- AI-driven bots guide players, enforce rules, and enhance role-playing.
- Custom bots reflect faction identity and goals.
Economics:
- Factions manage shared resources like Moonstones, crafting materials, and currency.
- Economy Bot oversees in-game currency, shop, and rewards.
Resources:
- Collect Moonstones from factions and players; burn for ship power during streams.
Rewards:
- Successful players receive prizes decided by factions, including NFTs and crypto.
Diverse Gameplay:
- Factions like Doge Cult, Thieves Guild, Bankers, Law, Bufficorn Cavalry, Meme Factory, Telephone Company, and Dark Cloud Militia offer diverse playstyles and interactions.
These factions and mechanics enrich Aqua Prime's gameplay, fostering strategic choices, creativity, and collaborative experiences.
"'''
return os_context


def process_hdd_context():
# Replace with your logic to process HDD context from MongoDB and Weaviate
hdd_context = "This is the long term summary of the final prompt and must not be sent to chat and is simply logged in mongo after the user recives a response creating a TLDR of the game state and scenario for the assiciated user IDS, roles, and bots involved in the summary"
return hdd_context


def process_ram_context():
# Replace with your logic to process RAM context from recent messages
ram_context = "Summarize everything the user and others have said in the last 5 messages along with any mentioned user and bots or roles, etc. This ensures short term memory is accounted for in the response"
return ram_context


def process_user_context():
# Replace with your logic to process User context from MongoDB
user_context = "This is the core message the bot must respond to after collecting full context of the game world, roles, user, past messages, etc. This ensures the message send from the user is core to the response and exibits personality and game master responses appropriate for the message the user is sending"
return user_context
41 changes: 41 additions & 0 deletions AquaPrime/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: '3.4'
services:
weaviate:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:1.20.3
ports:
- 8080:8080
restart: on-failure:0
environment:
QNA_INFERENCE_API: 'http://qna-transformers:8080'
NER_INFERENCE_API: 'http://ner-transformers:8080'
SUM_INFERENCE_API: 'http://sum-transformers:8080'
SPELLCHECK_INFERENCE_API: 'http://text-spellcheck:8080'
OPENAI_APIKEY: $OPENAI_APIKEY
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'text2vec-openai'
ENABLE_MODULES: 'text2vec-openai,qna-transformers,ner-transformers,sum-transformers,text-spellcheck,ref2vec-centroid,generative-openai'
CLUSTER_HOSTNAME: 'node1'
qna-transformers:
image: semitechnologies/qna-transformers:distilbert-base-cased-distilled-squad
environment:
ENABLE_CUDA: '0'
ner-transformers:
image: semitechnologies/ner-transformers:dbmdz-bert-large-cased-finetuned-conll03-english
environment:
ENABLE_CUDA: '0'
sum-transformers:
image: semitechnologies/sum-transformers:facebook-bart-large-cnn-1.0.0
environment:
ENABLE_CUDA: '0'
text-spellcheck:
image: semitechnologies/text-spellcheck-model:pyspellchecker-en

0 comments on commit f398835

Please sign in to comment.