Spaces:
Runtime error
Runtime error
kwabs22
commited on
Commit
·
482bc30
1
Parent(s):
b19b854
Initial State Machine and Config assist ideas
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
# Default configuration template
|
| 4 |
default_config = {
|
|
@@ -32,9 +33,265 @@ def add_target(targets_items, name, x, y, collisionType, collisiontext):
|
|
| 32 |
targets_items.append(new_target)
|
| 33 |
return targets_items
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
with gr.Blocks() as demo:
|
| 36 |
gr.HTML("Companion Space for zerogpu / client api workflow planning for a way to send a zip to the Basic Game Engine at the bottom of https://huggingface.co/spaces/KwabsHug/TestSvelteStatic (Also to test how much can be done majority on cpu)")
|
| 37 |
-
gr.HTML("Main ideas for this space is: <br>A program exist around data <br>We can generate almost any media data and more <br>llms good at short questions <br>Time moves in a straight so all considerations are flattend by the nature of time <br>HF + Gradio allows for api use so this my prototype tool for tool use test")
|
| 38 |
with gr.Tab("Config Creator"):
|
| 39 |
with gr.Tab("Simple Config Creator"):
|
| 40 |
inventory_items = gr.State([])
|
|
@@ -106,25 +363,59 @@ with gr.Blocks() as demo:
|
|
| 106 |
add_target_button.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output)
|
| 107 |
|
| 108 |
with gr.Tab("Advanced Config Creator"):
|
| 109 |
-
gr.HTML("")
|
| 110 |
-
|
| 111 |
-
with gr.Tab("Skeleton and Asset Generation"):
|
| 112 |
-
gr.HTML("With some ideas from gemini-1.5-flash-api-0514 and reka-flash-preview-20240611")
|
| 113 |
-
with gr.Tab("Skeleton Generator"):
|
| 114 |
gr.HTML("Some Kinds of game skeletons ideas - Timelines, Graph as State machine paths, Economy ecosystem")
|
| 115 |
gr.HTML("One prompt to be used to test models - <br>Please make 10 python lists for the types of media files and their purposes in a game and then use those lists to random generate a timeline of 20 items when the function is called <br>Great next suggest ways to improve this function to create better timelines")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
with gr.Tab("Save files"):
|
| 118 |
gr.HTML("For Dynamic events overnight or when player is not active what can LLMS edit? <br><br>eg. Waiting for a letter from a random npc can be decided by the llm <br>eg. Improved Stats on certain days (eg. bitrthday) <br>Privacy <br>User Directed DLC eg. Rockstar Editor with local llm guide")
|
| 119 |
gr.HTML("Placeholder for huggingface spaces that can assist ")
|
| 120 |
-
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist (9b and under) <br>initial floor for testing can be https://huggingface.co/spaces/Qwen/Qwen2-0.5B-Instruct, https://huggingface.co/spaces/Qwen/Qwen2-1.5b-instruct-demo, https://huggingface.co/spaces/stabilityai/stablelm-2-1_6b-zephyr, https://huggingface.co/spaces/IndexTeam/Index-1.9B, ")
|
| 121 |
|
| 122 |
with gr.Tab("Images"):
|
| 123 |
gr.HTML("Concept Art, UI elements, Static/3D Characters, Environments and Objects")
|
| 124 |
gr.HTML("Image Caption = https://huggingface.co/spaces/microsoft/Promptist, https://huggingface.co/spaces/gokaygokay/SD3-Long-Captioner, https://huggingface.co/spaces/gokaygokay/Florence-2, ")
|
| 125 |
gr.HTML("Images Generation Portraits = https://huggingface.co/spaces/okaris/omni-zero")
|
| 126 |
-
gr.HTML("Images Generation General =
|
| 127 |
gr.HTML("Images Generation Posters with text - https://huggingface.co/spaces/GlyphByT5/Glyph-SDXL-v2")
|
|
|
|
| 128 |
gr.HTML("Placeholder for huggingface spaces that can assist <br> https://huggingface.co/spaces/gokaygokay/Florence-2 <br>")
|
| 129 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 130 |
|
|
@@ -136,22 +427,22 @@ with gr.Blocks() as demo:
|
|
| 136 |
|
| 137 |
with gr.Tab("Video"):
|
| 138 |
gr.HTML("Cutscenes, Tutorials, Trailers")
|
| 139 |
-
gr.HTML("Placeholder for huggingface spaces that can assist")
|
| 140 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 141 |
|
| 142 |
with gr.Tab("3D"):
|
| 143 |
gr.HTML("Characters, Environments, Objects")
|
| 144 |
-
gr.HTML("Placeholder for huggingface spaces that can assist")
|
| 145 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 146 |
|
| 147 |
with gr.Tab("Animations (for lower resource use)"):
|
| 148 |
gr.HTML("Characters, Environments, Objects")
|
| 149 |
-
gr.HTML("Placeholder for huggingface spaces that can assist")
|
| 150 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 151 |
|
| 152 |
with gr.Tab("Fonts"):
|
| 153 |
gr.HTML("Style of whole game, or locations, or characters")
|
| 154 |
-
gr.HTML("Placeholder for huggingface spaces that can assist")
|
| 155 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 156 |
|
| 157 |
with gr.Tab("Shaders and related"):
|
|
@@ -175,6 +466,6 @@ with gr.Blocks() as demo:
|
|
| 175 |
gr.HTML("Prototyping and freemium <br>free api <br>HF Pro subscription")
|
| 176 |
gr.HTML("GPU (Data privacy) = No Rate limits? - https://lambdalabs.com/service/gpu-cloud https://huggingface.co/pricing#endpoints")
|
| 177 |
gr.HTML("Speed - Groq, SambaNova, ")
|
| 178 |
-
gr.HTML("Price - Coding - https://www.deepseek.com/ 0.3 per million")
|
| 179 |
|
| 180 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
|
| 4 |
# Default configuration template
|
| 5 |
default_config = {
|
|
|
|
| 33 |
targets_items.append(new_target)
|
| 34 |
return targets_items
|
| 35 |
|
| 36 |
+
#-----------------------------------------------------------------------------------------------------------------------------------
|
| 37 |
+
|
| 38 |
+
# List of player engagement UI elements
|
| 39 |
+
player_engagement_items = [
|
| 40 |
+
"Health Bar", "Mana/Energy Bar", "Experience Bar", "Mini-Map", "Quest Tracker",
|
| 41 |
+
"Inventory Quick Access Slots", "Skill Cooldown Indicators", "Currency Display",
|
| 42 |
+
"Compass", "Timer/Clock", "Action Prompts", "Reticle/Crosshair", "Enemy Health Bars",
|
| 43 |
+
"Score Display", "Inventory Grid", "Item Tooltip", "Item Categories/Tabs",
|
| 44 |
+
"Equip/Unequip Buttons", "Item Sorting Options", "Character Stats Panel",
|
| 45 |
+
"Character Model Viewer", "Quick Equip Slots", "Dialogue Box", "Dialogue Choices",
|
| 46 |
+
"Character Portraits", "Character Name Display", "Subtitle Text", "World Map",
|
| 47 |
+
"Local Map", "Fast Travel Points", "Map Markers", "Map Legend", "Crafting Recipe List",
|
| 48 |
+
"Ingredient Slots", "Craft Button", "Crafting Progress Bar", "Skill Nodes",
|
| 49 |
+
"Skill Descriptions", "Skill Point Counter", "Unlock Button", "Skill Path Highlight",
|
| 50 |
+
"Quest List", "Quest Details Panel", "Quest Objectives", "Quest Rewards",
|
| 51 |
+
"Quest Status Indicators", "Chat Box", "Player List", "Voice Chat Indicators",
|
| 52 |
+
"Ping/Latency Indicator", "Party/Team UI", "Scoreboard", "Matchmaking Screen",
|
| 53 |
+
"Pop-up Notifications", "Achievement Unlocks", "System Messages",
|
| 54 |
+
"On-screen Key Prompts", "Environmental Interaction Icons", "Save/Auto-Save Indicators",
|
| 55 |
+
"Credits Screen"
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
# List of character-based story events
|
| 59 |
+
story_events = [
|
| 60 |
+
'exploreLocation', 'discoverClue', 'meetCharacter', 'solveRiddle', 'findItem',
|
| 61 |
+
'faceChallenge', 'makeDecision', 'engageBattle', 'unlockAbility', 'learnSecret',
|
| 62 |
+
'completeMission', 'experienceSetback', 'earnReward', 'uncoverMystery', 'formAlliance',
|
| 63 |
+
'faceBetrayal', 'confrontNemesis', 'makeDiscovery', 'overcomeLoss', 'achieveVictory'
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
def pick_random_items(items, n):
|
| 67 |
+
return random.sample(items, n)
|
| 68 |
+
|
| 69 |
+
def generate_timeline(events, label):
|
| 70 |
+
timeline = []
|
| 71 |
+
for event in events:
|
| 72 |
+
timeline.append((random.randint(1, 100), label, event))
|
| 73 |
+
return timeline
|
| 74 |
+
|
| 75 |
+
def create_story(timeline):
|
| 76 |
+
story = []
|
| 77 |
+
for entry in timeline:
|
| 78 |
+
if entry[1] == "Story":
|
| 79 |
+
story.append(f"The hero {entry[2].replace('engageBattle', 'engaged in a fierce battle').replace('solveRiddle', 'solved a complex riddle').replace('exploreLocation', 'explored a mysterious location')}.")
|
| 80 |
+
else:
|
| 81 |
+
story.append(f"The player interacted with {entry[2]}.")
|
| 82 |
+
return " ".join(story)
|
| 83 |
+
|
| 84 |
+
def generate_story_and_timeline():
|
| 85 |
+
# Pick 10 random UI items
|
| 86 |
+
random_ui_items = pick_random_items(player_engagement_items, 10)
|
| 87 |
+
|
| 88 |
+
# Generate UI and story timelines
|
| 89 |
+
ui_timeline = generate_timeline(random_ui_items, "UI")
|
| 90 |
+
story_timeline = generate_timeline(story_events, "Story")
|
| 91 |
+
|
| 92 |
+
# Merge the timelines
|
| 93 |
+
merged_timeline = ui_timeline + story_timeline
|
| 94 |
+
|
| 95 |
+
# Sort the merged timeline based on the random numbers
|
| 96 |
+
merged_timeline.sort(key=lambda x: x[0])
|
| 97 |
+
|
| 98 |
+
# Create the story
|
| 99 |
+
story = create_story(merged_timeline)
|
| 100 |
+
|
| 101 |
+
# Format the timeline for display
|
| 102 |
+
formatted_timeline = "\n".join([f"{entry[0]}: {entry[1]} - {entry[2]}" for entry in merged_timeline])
|
| 103 |
+
|
| 104 |
+
return formatted_timeline, story
|
| 105 |
+
|
| 106 |
+
#-----------------------------------------------------------------------------------------------------------------------------------
|
| 107 |
+
|
| 108 |
+
class GameState:
|
| 109 |
+
def __init__(self, description, choices, transitions, conditions=None, npcs=None, consequences=None):
|
| 110 |
+
self.description = description
|
| 111 |
+
self.choices = choices
|
| 112 |
+
self.transitions = transitions
|
| 113 |
+
self.conditions = conditions if conditions else {}
|
| 114 |
+
self.npcs = npcs if npcs else []
|
| 115 |
+
self.consequences = consequences if consequences else {}
|
| 116 |
+
|
| 117 |
+
def apply_consequence(self, choice, player):
|
| 118 |
+
if choice in self.consequences:
|
| 119 |
+
self.consequences[choice](player)
|
| 120 |
+
|
| 121 |
+
class Player:
|
| 122 |
+
def __init__(self):
|
| 123 |
+
self.inventory = []
|
| 124 |
+
self.money = 20
|
| 125 |
+
self.knowledge = {}
|
| 126 |
+
|
| 127 |
+
def add_item(self, item):
|
| 128 |
+
self.inventory.append(item)
|
| 129 |
+
|
| 130 |
+
def has_item(self, item):
|
| 131 |
+
return item in self.inventory
|
| 132 |
+
|
| 133 |
+
def update_knowledge(self, topic):
|
| 134 |
+
self.knowledge[topic] = True
|
| 135 |
+
|
| 136 |
+
# Define the states
|
| 137 |
+
all_states = {
|
| 138 |
+
'village': {
|
| 139 |
+
'start': GameState(
|
| 140 |
+
"You wake up in a small village. You hear a rumor about a lost treasure.",
|
| 141 |
+
['explore village', 'gather supplies', 'rest'],
|
| 142 |
+
{'explore village': 'village_rumor', 'gather supplies': 'village_supplies', 'rest': 'village_start'},
|
| 143 |
+
consequences={
|
| 144 |
+
'gather supplies': lambda player: player.add_item('basic supplies')
|
| 145 |
+
}
|
| 146 |
+
),
|
| 147 |
+
'rumor': GameState(
|
| 148 |
+
"You hear more details about the treasure hidden in the ancient ruins nearby.",
|
| 149 |
+
['decide to go', 'ignore'],
|
| 150 |
+
{'decide to go': 'village_supplies', 'ignore': 'village_start'},
|
| 151 |
+
consequences={
|
| 152 |
+
'decide to go': lambda player: player.update_knowledge('treasure location')
|
| 153 |
+
}
|
| 154 |
+
),
|
| 155 |
+
'supplies': GameState(
|
| 156 |
+
"You gather supplies for your journey.",
|
| 157 |
+
['head to forest', 'stay in village'],
|
| 158 |
+
{'head to forest': 'forest_forest', 'stay in village': 'village_start'}
|
| 159 |
+
),
|
| 160 |
+
},
|
| 161 |
+
'forest': {
|
| 162 |
+
'forest': GameState(
|
| 163 |
+
"You enter the dense forest, heading towards the ruins.",
|
| 164 |
+
['travel further', 'return to village'],
|
| 165 |
+
{'travel further': 'ruins_ruins', 'return to village': 'village_start'}
|
| 166 |
+
),
|
| 167 |
+
},
|
| 168 |
+
'ruins': {
|
| 169 |
+
'ruins': GameState(
|
| 170 |
+
"You reach the ancient ruins. The entrance is dark and eerie.",
|
| 171 |
+
['enter ruins', 'return to forest'],
|
| 172 |
+
{'enter ruins': 'ruins_explore', 'return to forest': 'forest_forest'}
|
| 173 |
+
),
|
| 174 |
+
'explore': GameState(
|
| 175 |
+
"You explore the ruins, encountering traps and puzzles.",
|
| 176 |
+
['solve puzzle', 'avoid traps'],
|
| 177 |
+
{'solve puzzle': 'ruins_hiddenPassage', 'avoid traps': 'ruins_ruins'}
|
| 178 |
+
),
|
| 179 |
+
'hiddenPassage': GameState(
|
| 180 |
+
"You solve a challenging puzzle and unlock a hidden passage.",
|
| 181 |
+
['enter passage', 'go back'],
|
| 182 |
+
{'enter passage': 'ruins_treasureRoom', 'go back': 'ruins_explore'}
|
| 183 |
+
),
|
| 184 |
+
'treasureRoom': GameState(
|
| 185 |
+
"You enter the treasure room and find the treasure chest.",
|
| 186 |
+
['take treasure', 'leave'],
|
| 187 |
+
{'take treasure': 'ruins_celebrate', 'leave': 'ruins_ruins'},
|
| 188 |
+
consequences={
|
| 189 |
+
'take treasure': lambda player: player.add_item('treasure')
|
| 190 |
+
}
|
| 191 |
+
),
|
| 192 |
+
'celebrate': GameState(
|
| 193 |
+
"You celebrate your discovery and decide to bring the treasure back to the village.",
|
| 194 |
+
['return to village'],
|
| 195 |
+
{'return to village': 'village_return'}
|
| 196 |
+
),
|
| 197 |
+
},
|
| 198 |
+
'village_return': {
|
| 199 |
+
'village_return': GameState(
|
| 200 |
+
"You return to the village with the treasure and share it with the villagers.",
|
| 201 |
+
['end adventure'],
|
| 202 |
+
{'end adventure': 'end_end'}
|
| 203 |
+
),
|
| 204 |
+
},
|
| 205 |
+
'end': {
|
| 206 |
+
'end': GameState(
|
| 207 |
+
"Your adventure ends here. The villagers are grateful and everyone's lives improve.",
|
| 208 |
+
[],
|
| 209 |
+
{}
|
| 210 |
+
),
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
def validate_transitions(all_states):
|
| 215 |
+
errors = []
|
| 216 |
+
for location, states in all_states.items():
|
| 217 |
+
for state_key, state in states.items():
|
| 218 |
+
for transition_key, transition_state in state.transitions.items():
|
| 219 |
+
# Check if the transition is to another location
|
| 220 |
+
if transition_state in all_states:
|
| 221 |
+
trans_location, trans_state = transition_state, 'start' # Assuming 'start' state for new locations
|
| 222 |
+
elif '_' in transition_state:
|
| 223 |
+
trans_location, trans_state = transition_state.split('_')
|
| 224 |
+
else:
|
| 225 |
+
trans_location, trans_state = location, transition_state
|
| 226 |
+
|
| 227 |
+
# Validate the transition state
|
| 228 |
+
if trans_location not in all_states or trans_state not in all_states[trans_location]:
|
| 229 |
+
errors.append(f"Invalid transition from {location}.{state_key} to {trans_location}.{trans_state}")
|
| 230 |
+
|
| 231 |
+
return errors
|
| 232 |
+
|
| 233 |
+
path_errors = validate_transitions(all_states)
|
| 234 |
+
# if path_errors:
|
| 235 |
+
# for error in path_errors:
|
| 236 |
+
# print(error)
|
| 237 |
+
# else:
|
| 238 |
+
# print("All transitions are valid.")
|
| 239 |
+
|
| 240 |
+
class GameSession:
|
| 241 |
+
def __init__(self):
|
| 242 |
+
self.player = Player()
|
| 243 |
+
self.current_location = 'village'
|
| 244 |
+
self.current_state = 'start'
|
| 245 |
+
self.game_log = []
|
| 246 |
+
|
| 247 |
+
def make_choice(self, choice_index):
|
| 248 |
+
state = all_states[self.current_location][self.current_state]
|
| 249 |
+
if 0 <= choice_index < len(state.choices):
|
| 250 |
+
choice = state.choices[choice_index]
|
| 251 |
+
next_state = state.transitions[choice]
|
| 252 |
+
|
| 253 |
+
self.game_log.append(f"You chose: {choice}")
|
| 254 |
+
self.game_log.append(state.description)
|
| 255 |
+
|
| 256 |
+
state.apply_consequence(choice, self.player)
|
| 257 |
+
|
| 258 |
+
if '_' in next_state:
|
| 259 |
+
self.current_location, self.current_state = next_state.split('_')
|
| 260 |
+
else:
|
| 261 |
+
self.current_state = next_state
|
| 262 |
+
|
| 263 |
+
return self.get_current_state_info()
|
| 264 |
+
else:
|
| 265 |
+
return "Invalid choice. Please try again."
|
| 266 |
+
|
| 267 |
+
def get_current_state_info(self):
|
| 268 |
+
state = all_states[self.current_location][self.current_state]
|
| 269 |
+
choices = [f"{idx + 1}. {choice}" for idx, choice in enumerate(state.choices)]
|
| 270 |
+
return state.description, choices, "\n".join(self.game_log)
|
| 271 |
+
|
| 272 |
+
def start_game():
|
| 273 |
+
game_session = GameSession()
|
| 274 |
+
description, choices, game_log = game_session.get_current_state_info()
|
| 275 |
+
return description, choices, game_log, game_session
|
| 276 |
+
|
| 277 |
+
def make_choice(choice, game_session):
|
| 278 |
+
if not choice:
|
| 279 |
+
description, choices, game_log = game_session.get_current_state_info()
|
| 280 |
+
return description, choices, "Please select a choice before proceeding.", game_session
|
| 281 |
+
|
| 282 |
+
choice_index = game_session.get_current_state_info()[1].index(choice)
|
| 283 |
+
result = game_session.make_choice(choice_index)
|
| 284 |
+
|
| 285 |
+
return result[0], gr.update(choices=result[1]), result[2], game_session
|
| 286 |
+
|
| 287 |
+
initgameinfo = start_game()
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
#-----------------------------------------------------------------------------------------------------------------------------------
|
| 291 |
+
|
| 292 |
with gr.Blocks() as demo:
|
| 293 |
gr.HTML("Companion Space for zerogpu / client api workflow planning for a way to send a zip to the Basic Game Engine at the bottom of https://huggingface.co/spaces/KwabsHug/TestSvelteStatic (Also to test how much can be done majority on cpu)")
|
| 294 |
+
gr.HTML("Main ideas for this space is (June 2024): <br>A program exist around data <br>We can generate almost any media data and more <br>llms good at short questions <br>Time moves in a straight so all considerations are flattend by the nature of time <br>HF + Gradio allows for api use so this my prototype tool for tool use test")
|
| 295 |
with gr.Tab("Config Creator"):
|
| 296 |
with gr.Tab("Simple Config Creator"):
|
| 297 |
inventory_items = gr.State([])
|
|
|
|
| 363 |
add_target_button.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output)
|
| 364 |
|
| 365 |
with gr.Tab("Advanced Config Creator"):
|
| 366 |
+
gr.HTML("Config with More than text and images")
|
| 367 |
+
with gr.Tab("Skeleton Generator"):
|
|
|
|
|
|
|
|
|
|
| 368 |
gr.HTML("Some Kinds of game skeletons ideas - Timelines, Graph as State machine paths, Economy ecosystem")
|
| 369 |
gr.HTML("One prompt to be used to test models - <br>Please make 10 python lists for the types of media files and their purposes in a game and then use those lists to random generate a timeline of 20 items when the function is called <br>Great next suggest ways to improve this function to create better timelines")
|
| 370 |
+
with gr.Tab("Generate Timeline"):
|
| 371 |
+
gr.HTML("Placeholder")
|
| 372 |
+
gr.Markdown("# Story and Timeline Generator")
|
| 373 |
+
gr.Markdown("Click the button to generate a random timeline and story based on UI elements and story events.")
|
| 374 |
+
|
| 375 |
+
with gr.Row():
|
| 376 |
+
timeline_output = gr.Textbox(label="Timeline", lines=20)
|
| 377 |
+
story_output = gr.Textbox(label="Generated Story", lines=20)
|
| 378 |
+
|
| 379 |
+
generate_button = gr.Button("Generate Story and Timeline")
|
| 380 |
+
generate_button.click(generate_story_and_timeline, inputs=[], outputs=[timeline_output, story_output])
|
| 381 |
+
with gr.Tab("Test Example State Machine"):
|
| 382 |
+
gr.HTML("Placeholder")
|
| 383 |
+
with gr.Row():
|
| 384 |
+
with gr.Column(scale=2):
|
| 385 |
+
gr.Markdown("# Text-based Adventure Game")
|
| 386 |
+
description = gr.Textbox(label="Current Situation", lines=4, value=initgameinfo[0])
|
| 387 |
+
choices = gr.Radio(label="Your Choices", choices=initgameinfo[1])
|
| 388 |
+
submit_btn = gr.Button("Make Choice")
|
| 389 |
+
game_log = gr.Textbox(label="Game Log", lines=20, value=initgameinfo[2])
|
| 390 |
+
game_session = gr.State(value=initgameinfo[3])
|
| 391 |
+
submit_btn.click(
|
| 392 |
+
make_choice,
|
| 393 |
+
inputs=[choices, game_session],
|
| 394 |
+
outputs=[description, choices, game_log, game_session]
|
| 395 |
+
)
|
| 396 |
+
with gr.Column(scale=1):
|
| 397 |
+
gr.Markdown("# Debugging")
|
| 398 |
+
gr.Textbox(label="Path Errors", lines=4, value=path_errors)
|
| 399 |
+
with gr.Accordion("Config (Game Spoiler)", open=False):
|
| 400 |
+
custom_config = gr.Textbox(label="", value=all_states, lines=8)
|
| 401 |
+
custom_configbtn = gr.Button("Load a new config")
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
with gr.Tab("Asset Generation"):
|
| 405 |
+
gr.HTML("With some ideas from gemini-1.5-flash-api-0514 and reka-flash-preview-20240611")
|
| 406 |
|
| 407 |
with gr.Tab("Save files"):
|
| 408 |
gr.HTML("For Dynamic events overnight or when player is not active what can LLMS edit? <br><br>eg. Waiting for a letter from a random npc can be decided by the llm <br>eg. Improved Stats on certain days (eg. bitrthday) <br>Privacy <br>User Directed DLC eg. Rockstar Editor with local llm guide")
|
| 409 |
gr.HTML("Placeholder for huggingface spaces that can assist ")
|
| 410 |
+
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist (9b and under) <br>initial floor for testing can be https://huggingface.co/spaces/Qwen/Qwen2-0.5B-Instruct, https://huggingface.co/spaces/Qwen/Qwen2-1.5b-instruct-demo, https://huggingface.co/spaces/stabilityai/stablelm-2-1_6b-zephyr, https://huggingface.co/spaces/IndexTeam/Index-1.9B, https://huggingface.co/microsoft/Phi-3-mini-4k-instruct")
|
| 411 |
|
| 412 |
with gr.Tab("Images"):
|
| 413 |
gr.HTML("Concept Art, UI elements, Static/3D Characters, Environments and Objects")
|
| 414 |
gr.HTML("Image Caption = https://huggingface.co/spaces/microsoft/Promptist, https://huggingface.co/spaces/gokaygokay/SD3-Long-Captioner, https://huggingface.co/spaces/gokaygokay/Florence-2, ")
|
| 415 |
gr.HTML("Images Generation Portraits = https://huggingface.co/spaces/okaris/omni-zero")
|
| 416 |
+
gr.HTML("Images Generation General = https://huggingface.co/spaces/stabilityai/stable-diffusion-3-medium, https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma, https://huggingface.co/spaces/stabilityai/stable-diffusion, https://www.craiyon.com/, https://huggingface.co/spaces/prodia/sdxl-stable-diffusion-xl")
|
| 417 |
gr.HTML("Images Generation Posters with text - https://huggingface.co/spaces/GlyphByT5/Glyph-SDXL-v2")
|
| 418 |
+
gr.HTML("SVG Generation = Coding models - ")
|
| 419 |
gr.HTML("Placeholder for huggingface spaces that can assist <br> https://huggingface.co/spaces/gokaygokay/Florence-2 <br>")
|
| 420 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 421 |
|
|
|
|
| 427 |
|
| 428 |
with gr.Tab("Video"):
|
| 429 |
gr.HTML("Cutscenes, Tutorials, Trailers")
|
| 430 |
+
gr.HTML("Placeholder for huggingface spaces that can assist - https://huggingface.co/spaces/KingNish/Instant-Video, https://huggingface.co/spaces/multimodalart/stable-video-diffusion, https://huggingface.co/spaces/multimodalart/stable-video-diffusion")
|
| 431 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 432 |
|
| 433 |
with gr.Tab("3D"):
|
| 434 |
gr.HTML("Characters, Environments, Objects")
|
| 435 |
+
gr.HTML("Placeholder for huggingface spaces that can assist - https://huggingface.co/spaces/dylanebert/3d-arena, https://huggingface.co/spaces/stabilityai/TripoSR, https://huggingface.co/spaces/hysts/Shap-E")
|
| 436 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 437 |
|
| 438 |
with gr.Tab("Animations (for lower resource use)"):
|
| 439 |
gr.HTML("Characters, Environments, Objects")
|
| 440 |
+
gr.HTML("Placeholder for huggingface spaces that can assist - image as 3d object in video https://huggingface.co/spaces/ashawkey/LGM")
|
| 441 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 442 |
|
| 443 |
with gr.Tab("Fonts"):
|
| 444 |
gr.HTML("Style of whole game, or locations, or characters")
|
| 445 |
+
gr.HTML("Placeholder for huggingface spaces that can assist - there was a space that could make letter into pictures based on the prompt but I cant find it now")
|
| 446 |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist")
|
| 447 |
|
| 448 |
with gr.Tab("Shaders and related"):
|
|
|
|
| 466 |
gr.HTML("Prototyping and freemium <br>free api <br>HF Pro subscription")
|
| 467 |
gr.HTML("GPU (Data privacy) = No Rate limits? - https://lambdalabs.com/service/gpu-cloud https://huggingface.co/pricing#endpoints")
|
| 468 |
gr.HTML("Speed - Groq, SambaNova, ")
|
| 469 |
+
gr.HTML("Price - Coding - https://aider.chat/docs/leaderboards/ - https://www.deepseek.com/ 0.3 per million - is this per token or chinese character as that means converting code to chinese if possible can save api cost?")
|
| 470 |
|
| 471 |
demo.launch()
|