Spaces:
Running
on
Zero
Running
on
Zero
import gradio as gr | |
import random | |
import json | |
import re | |
# Default configuration template | |
default_config = { | |
'background': '/AutoGameBackgrounds/1stGameLoc123.png', | |
'inventory': [], | |
'skills': [], | |
'objectives': [], | |
'targets': [], | |
'story': [], | |
'actions': {} | |
} | |
# Helper functions to dynamically add items | |
def add_inventory_item(inventory_items, type, name, description): | |
new_item = {"type": type, "name": name, "description": description} | |
inventory_items.append(new_item) | |
return inventory_items | |
def add_skill(skills_items, branch, name, learned): | |
new_skill = {"branch": branch, "name": name, "learned": learned == 'True'} | |
skills_items.append(new_skill) | |
return skills_items | |
def add_objective(objectives_items, id, name, complete): | |
new_objective = {"id": id, "name": name, "complete": complete == 'True'} | |
objectives_items.append(new_objective) | |
return objectives_items | |
def add_target(targets_items, name, x, y, collisionType, collisiontext): | |
new_target = {"name": name, "x": int(x), "y": int(y), "collisionType": collisionType, "collisiontext": collisiontext} | |
targets_items.append(new_target) | |
return targets_items | |
#----------------------------------------------------------------------------------------------------------------------------------- | |
# List of player engagement UI elements | |
player_engagement_items = [ | |
"Health Bar", "Mana/Energy Bar", "Experience Bar", "Mini-Map", "Quest Tracker", | |
"Inventory Quick Access Slots", "Skill Cooldown Indicators", "Currency Display", | |
"Compass", "Timer/Clock", "Action Prompts", "Reticle/Crosshair", "Enemy Health Bars", | |
"Score Display", "Inventory Grid", "Item Tooltip", "Item Categories/Tabs", | |
"Equip/Unequip Buttons", "Item Sorting Options", "Character Stats Panel", | |
"Character Model Viewer", "Quick Equip Slots", "Dialogue Box", "Dialogue Choices", | |
"Character Portraits", "Character Name Display", "Subtitle Text", "World Map", | |
"Local Map", "Fast Travel Points", "Map Markers", "Map Legend", "Crafting Recipe List", | |
"Ingredient Slots", "Craft Button", "Crafting Progress Bar", "Skill Nodes", | |
"Skill Descriptions", "Skill Point Counter", "Unlock Button", "Skill Path Highlight", | |
"Quest List", "Quest Details Panel", "Quest Objectives", "Quest Rewards", | |
"Quest Status Indicators", "Chat Box", "Player List", "Voice Chat Indicators", | |
"Ping/Latency Indicator", "Party/Team UI", "Scoreboard", "Matchmaking Screen", | |
"Pop-up Notifications", "Achievement Unlocks", "System Messages", | |
"On-screen Key Prompts", "Environmental Interaction Icons", "Save/Auto-Save Indicators", | |
"Credits Screen" | |
] | |
# List of character-based story events | |
story_events = [ | |
'exploreLocation', 'discoverClue', 'meetCharacter', 'solveRiddle', 'findItem', | |
'faceChallenge', 'makeDecision', 'engageBattle', 'unlockAbility', 'learnSecret', | |
'completeMission', 'experienceSetback', 'earnReward', 'uncoverMystery', 'formAlliance', | |
'faceBetrayal', 'confrontNemesis', 'makeDiscovery', 'overcomeLoss', 'achieveVictory' | |
] | |
def pick_random_items(items, n): | |
return random.sample(items, n) | |
def generate_timeline(events, label): | |
timeline = [] | |
for event in events: | |
timeline.append((random.randint(1, 100), label, event)) | |
return timeline | |
def create_story(timeline): | |
story = [] | |
for entry in timeline: | |
if entry[1] == "Story": | |
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')}.") | |
else: | |
story.append(f"The player interacted with {entry[2]}.") | |
return " ".join(story) | |
def generate_story_and_timeline(include_media=False): | |
# Pick 10 random UI items | |
random_ui_items = pick_random_items(player_engagement_items, 10) | |
# Generate UI and story timelines | |
ui_timeline = generate_timeline(random_ui_items, "UI") | |
story_timeline = generate_timeline(story_events, "Story") | |
# Initialize merged timeline with UI and story timelines | |
merged_timeline = ui_timeline + story_timeline | |
# Include media-related items if specified | |
if include_media: | |
media_files = generate_media_file_list(5) | |
rendered_media = render_media_with_dropdowns(media_files) | |
media_timeline = generate_timeline(rendered_media, "Media") | |
merged_timeline += media_timeline | |
# Sort the merged timeline based on the random numbers | |
merged_timeline.sort(key=lambda x: x[0]) | |
# Create the story | |
story = create_story(merged_timeline) | |
# Format the timeline for display | |
formatted_timeline = "\n".join([f"{entry[0]}: {entry[1]} - {entry[2]}" for entry in merged_timeline]) | |
return formatted_timeline, story | |
media_file_types = ["image", "video", "audio"] | |
def generate_media_file_list(n): | |
return [random.choice(media_file_types) for _ in range(n)] | |
def render_media_with_dropdowns(media_files): | |
rendered_output = [] | |
for index, media in enumerate(media_files): | |
iframe = f'<iframe src="{media}_source_{index}.html"></iframe>' | |
dropdown = f''' | |
<select> | |
<option value="{media}_source_1">Source 1</option> | |
<option value="{media}_source_2">Source 2</option> | |
<option value="{media}_source_3">Source 3</option> | |
</select> | |
''' | |
rendered_output.append(f"{iframe}{dropdown}") | |
return rendered_output | |
def save_to_placeholder(rendered_media): | |
placeholder = [] | |
for item in rendered_media: | |
placeholder.append(item) | |
return placeholder | |
# Example usage with and without media-related items | |
timeline_with_media, story_with_media = generate_story_and_timeline(include_media=True) | |
timeline_without_media, story_without_media = generate_story_and_timeline(include_media=False) | |
def split_content_into_blocks(timeline): | |
blocks = [] | |
current_text_block = [] | |
for entry in timeline.split('\n'): | |
if 'Media -' in entry: | |
# If we have accumulated text, add it as a block | |
if current_text_block: | |
blocks.append((' '.join(current_text_block), 'text')) | |
current_text_block = [] | |
# Extract the iframe and dropdown | |
match = re.search(r'<iframe.*?</select>', entry, re.DOTALL) | |
if match: | |
blocks.append((match.group(), 'iframe')) | |
else: | |
current_text_block.append(entry) | |
# Add any remaining text as a final block | |
if current_text_block: | |
blocks.append((' '.join(current_text_block), 'text')) | |
return blocks | |
def show_elements(text): | |
blocks = split_content_into_blocks(text) | |
outputs = [] | |
for content, block_type in blocks: | |
if block_type == 'text': | |
outputs.append(gr.Markdown(content)) | |
elif block_type == 'iframe': | |
outputs.append(gr.HTML(content)) | |
return outputs | |
def convert_timeline_to_game_structure(timeline): | |
lines = timeline.split('\n') | |
game_structure = {} | |
current_location = 0 | |
sub_location = 0 | |
for i, line in enumerate(lines): | |
if line.strip() == "": | |
continue | |
if line[0].isdigit(): # New location starts | |
current_location += 1 | |
sub_location = 0 | |
location_key = f"location{current_location}" | |
game_structure[location_key] = { | |
"description": "", | |
"events": [], | |
"choices": ["continue"], | |
"transitions": {} | |
} | |
else: # Continue with sub-locations or media entries | |
sub_location += 1 | |
location_key = f"location{current_location}_{sub_location}" | |
# Extract the event description | |
parts = line.split(': ', 1) | |
if len(parts) == 2: | |
prefix, rest = parts | |
event_parts = rest.split(' - ', 1) | |
if len(event_parts) == 2: | |
event_type, event_description = event_parts | |
else: | |
event_type, event_description = "Unknown", rest | |
else: | |
event_type, event_description = "Unknown", line | |
description = rest.strip() if event_type in ["Media", "UI"] else f"{event_type}: {event_description}" | |
if sub_location == 0: | |
game_structure[f"location{current_location}"]["description"] = description | |
else: | |
game_structure[f"location{current_location}"]["events"].append({ | |
"description": description, | |
"type": event_type | |
}) | |
# Set the transition to the next location or to the end | |
if i < len(lines) - 1: | |
next_line = lines[i + 1].strip() | |
if next_line and next_line[0].isdigit(): # New location starts | |
game_structure[f"location{current_location}"]["transitions"]["continue"] = f"masterlocation1_location{current_location + 1}" | |
else: | |
#game_structure[f"location{current_location}"]["transitions"]["continue"] = f"location_{current_location}_{sub_location + 1}" | |
game_structure[f"location{current_location}"]["transitions"]["continue"] = "end" | |
else: | |
game_structure[f"location{current_location}"]["transitions"]["continue"] = "end" | |
# Add an end location | |
game_structure["end"] = { | |
"description": "The adventure ends here.", | |
# "choices": [], | |
# "transitions": {} | |
"choices": ["restart"], | |
"transitions": {"restart": "location1"} # Assuming location_1 is the start | |
} | |
# Wrap the game structure in master_location1 | |
wrapped_structure = {"masterlocation1": game_structure} | |
return wrapped_structure | |
def generate_game_structures(): | |
timeline_with_media, _ = generate_story_and_timeline(include_media=True) | |
timeline_without_media, _ = generate_story_and_timeline(include_media=False) | |
game_structure_with_media = convert_timeline_to_game_structure(timeline_with_media) | |
game_structure_without_media = convert_timeline_to_game_structure(timeline_without_media) | |
return game_structure_with_media, game_structure_without_media | |
# Generate and print the game structures | |
game_structure_with_media, game_structure_without_media = generate_game_structures() | |
#print("Game Structure with Media:") | |
#print(json.dumps(game_structure_with_media, indent=2)) | |
#print("\nGame Structure without Media:") | |
#print(json.dumps(game_structure_without_media, indent=2)) | |
def show_game_structure(include_media): | |
if include_media: | |
return json.dumps(game_structure_with_media, indent=2) | |
else: | |
return json.dumps(game_structure_without_media, indent=2) | |
#----------------------------------------------------------------------------------------------------------------------------------- | |
class Player: | |
def __init__(self): | |
self.inventory = [] | |
self.money = 20 | |
self.knowledge = {} | |
def add_item(self, item): | |
self.inventory.append(item) | |
def has_item(self, item): | |
return item in self.inventory | |
def update_knowledge(self, topic): | |
self.knowledge[topic] = True | |
# Define the states | |
all_states = { | |
'village': { | |
'start': { | |
"description": "You wake up in a small village. You hear a rumor about a lost treasure.", | |
"choices": ['explore village', 'gather supplies', 'rest'], | |
"transitions": {'explore village': 'village_rumor', 'gather supplies': 'village_supplies', 'rest': 'village_start'}, | |
"consequences": { | |
'gather supplies': lambda player: player.add_item('basic supplies') | |
} | |
}, | |
'rumor': { | |
"description": "You hear more details about the treasure hidden in the ancient ruins nearby.", | |
"choices": ['decide to go', 'ignore'], | |
"transitions": {'decide to go': 'village_supplies', 'ignore': 'village_start'}, | |
"consequences": { | |
'decide to go': lambda player: player.update_knowledge('treasure location') | |
} | |
}, | |
'supplies': { | |
"description": "You gather supplies for your journey.", | |
"choices": ['head to forest', 'stay in village'], | |
"transitions": {'head to forest': 'forest_forest', 'stay in village': 'village_start'} | |
}, | |
}, | |
'forest': { | |
'forest': { | |
"description": "You enter the dense forest, heading towards the ruins.", | |
"choices": ['travel further', 'return to village'], | |
"transitions": {'travel further': 'ruins_ruins', 'return to village': 'village_start'} | |
}, | |
}, | |
'ruins': { | |
'ruins': { | |
"description": "You reach the ancient ruins. The entrance is dark and eerie.", | |
"choices": ['enter ruins', 'return to forest'], | |
"transitions": {'enter ruins': 'ruins_explore', 'return to forest': 'forest_forest'} | |
}, | |
'explore': { | |
"description": "You explore the ruins, encountering traps and puzzles.", | |
"choices": ['solve puzzle', 'avoid traps'], | |
"transitions": {'solve puzzle': 'ruins_hiddenPassage', 'avoid traps': 'ruins_ruins'} | |
}, | |
'hiddenPassage': { | |
"description": "You solve a challenging puzzle and unlock a hidden passage.", | |
"choices": ['enter passage', 'go back'], | |
"transitions": {'enter passage': 'ruins_treasureRoom', 'go back': 'ruins_explore'} | |
}, | |
'treasureRoom': { | |
"description": "You enter the treasure room and find the treasure chest.", | |
"choices": ['take treasure', 'leave'], | |
"transitions": {'take treasure': 'ruins_celebrate', 'leave': 'ruins_ruins'}, | |
"consequences": { | |
'take treasure': lambda player: player.add_item('treasure') | |
} | |
}, | |
'celebrate': { | |
"description": "You celebrate your discovery and decide to bring the treasure back to the village.", | |
"choices": ['return to village'], | |
"transitions": {'return to village': 'village_return'} | |
}, | |
}, | |
'village_return': { | |
'village_return': { | |
"description": "You return to the village with the treasure and share it with the villagers.", | |
"choices": ['end adventure'], | |
"transitions": {'end adventure': 'end_end'} | |
}, | |
}, | |
'end': { | |
'end': { | |
"description": "Your adventure ends here. The villagers are grateful and everyone's lives improve.", | |
"choices": [], | |
"transitions": {} | |
}, | |
} | |
} | |
def validate_transitions(all_states): | |
errors = [] | |
for location, states in all_states.items(): | |
for state_key, state in states.items(): | |
for transition_key, transition_state in state['transitions'].items(): | |
# Check if the transition is to another location | |
if transition_state in all_states: | |
trans_location, trans_state = transition_state, 'start' # Assuming 'start' state for new locations | |
elif '_' in transition_state: | |
trans_location, trans_state = transition_state.split('_') | |
else: | |
trans_location, trans_state = location, transition_state | |
# Validate the transition state | |
if trans_location not in all_states or trans_state not in all_states[trans_location]: | |
errors.append(f"Invalid transition from {location}.{state_key} to {trans_location}.{trans_state}") | |
return errors | |
path_errors = validate_transitions(all_states) | |
if path_errors: | |
for error in path_errors: | |
print(error) | |
else: | |
print("All transitions are valid.") | |
class GameSession: | |
def __init__(self, starting_location='village', starting_state='start'): | |
self.player = Player() | |
self.current_location = starting_location | |
self.current_state = starting_state | |
self.game_log = [] | |
def make_choice(self, choice_index): | |
state = all_states[self.current_location][self.current_state] | |
if 0 <= choice_index < len(state['choices']): | |
choice = state['choices'][choice_index] | |
next_state = state['transitions'][choice] | |
self.game_log.append(f"You chose: {choice}") | |
self.game_log.append(state['description']) | |
if 'consequences' in state and choice in state['consequences']: | |
if state['consequences'][choice]: | |
state['consequences'][choice](self.player) | |
else: | |
# Handle empty consequence, e.g., log a message or provide a default action | |
print(f"No consequence for choice: {choice}") | |
# You can add any default action here if needed | |
if '_' in next_state: | |
self.current_location, self.current_state = next_state.split('_') | |
else: | |
self.current_state = next_state | |
return self.get_current_state_info() | |
else: | |
return "Invalid choice. Please try again." | |
def get_current_state_info(self): | |
state = all_states[self.current_location][self.current_state] | |
choices = [f"{idx + 1}. {choice}" for idx, choice in enumerate(state['choices'])] | |
return state['description'], choices, "\n".join(self.game_log) | |
def start_game(starting_location='village', starting_state='start'): | |
game_session = GameSession(starting_location, starting_state) | |
description, choices, game_log = game_session.get_current_state_info() | |
return description, choices, game_log, game_session | |
def make_choice(choice, game_session): | |
if not choice: | |
description, choices, game_log = game_session.get_current_state_info() | |
return description, choices, "Please select a choice before proceeding.", game_session | |
choice_index = int(choice.split('.')[0]) - 1 | |
result = game_session.make_choice(choice_index) | |
return result[0], gr.update(choices=result[1]), result[2], game_session | |
def load_game(custom_config=None): | |
global all_states | |
if custom_config: | |
try: | |
new_config = json.loads(custom_config) | |
all_states = new_config | |
# Determine the starting location and state | |
starting_location = next(iter(all_states.keys())) | |
starting_state = next(iter(all_states[starting_location].keys())) | |
game_session = GameSession(starting_location, starting_state) | |
description, choices, game_log = game_session.get_current_state_info() | |
new_path_errors = validate_transitions(all_states) | |
return gr.update(value=f"Custom configuration loaded successfully! \n{new_path_errors}"), game_log, description, gr.update(choices=choices), game_session, gr.update(value=custom_config) | |
except json.JSONDecodeError as e: | |
# Get the line number and column of the error | |
lineno, colno = e.lineno, e.colno | |
# Get the problematic line | |
lines = custom_config.split('\n') | |
error_line = lines[lineno - 1] if lineno <= len(lines) else "" | |
# Create a pointer to the error location | |
pointer = ' ' * (colno - 1) + '^' | |
error_message = f"Invalid JSON format in custom configuration:\n" | |
error_message += f"Error at line {lineno}, column {colno}:\n" | |
error_message += f"{error_line}\n" | |
error_message += f"{pointer}\n" | |
error_message += f"Error details: {str(e)}" | |
return gr.update(value=error_message), gr.update(), gr.update(), None, gr.update(value=custom_config) | |
except Exception as e: | |
return gr.update(value=f"Error loading custom configuration: {str(e)}"), gr.update(), gr.update(), None, gr.update(value=custom_config) | |
# If no custom config, start with the default configuration | |
starting_location = next(iter(all_states.keys())) | |
starting_state = next(iter(all_states[starting_location].keys())) | |
game_session = GameSession(starting_location, starting_state) | |
description, choices, game_log = game_session.get_current_state_info() | |
return description, gr.update(choices=choices), game_log, game_session, gr.update() | |
initgameinfo = start_game() | |
#----------------------------------------------------------------------------------------------------------------------------------- | |
with gr.Blocks() as demo: | |
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") | |
with gr.Tab("Skeleton Generator"): | |
gr.HTML("Some Kinds of game skeletons ideas - Timelines, Graph as State machine paths, Economy ecosystem") | |
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") | |
with gr.Tab("Generate Timeline"): | |
with gr.Tab("Asset generation considered"): | |
gr.HTML("Iframes are a placeholder for sample assets") | |
with gr.Tab("Prototype for finegrained editing of time line before conversion to game format"): | |
with gr.Row(): | |
gr.Textbox(value=timeline_with_media, lines=4) | |
gr.Textbox(value=timeline_without_media, lines=4) | |
gr.HTML("Splits by new line") | |
input_text = gr.Textbox(label="Input Text", lines=10) | |
output_group = gr.Group() | |
def update(text): | |
return show_elements(text) | |
with gr.Tab("Conversion of game version"): | |
gr.HTML("Can copy in the next tab - only linear path for now") | |
media_checkbox = gr.Checkbox(label="Include Media") | |
output_text = gr.Code(language="json") | |
media_checkbox.change( | |
fn=show_game_structure, | |
inputs=[media_checkbox], | |
outputs=[output_text] | |
) | |
with gr.Tab("Without Asset generation consideration"): | |
gr.Markdown("# Story and Timeline Generator") | |
gr.Markdown("Click the button to generate a random timeline and story based on UI elements and story events. <br>Ask an LLM to use this to write a story around") | |
with gr.Row(): | |
timeline_output = gr.Textbox(label="Timeline", lines=20) | |
story_output = gr.Textbox(label="Generated Story", lines=20) | |
generate_button = gr.Button("Generate Story and Timeline") | |
generate_button.click(generate_story_and_timeline, inputs=[], outputs=[timeline_output, story_output]) | |
with gr.Tab("Test Example State Machine"): | |
with gr.Row(): | |
with gr.Column(scale=2): | |
gr.Markdown("# Text-based Adventure Game") | |
description = gr.Textbox(label="Current Situation", lines=4, value=initgameinfo[0]) | |
media = gr.HTML("Placeholder to load all media tests") | |
choices = gr.Radio(label="Your Choices", choices=initgameinfo[1]) | |
submit_btn = gr.Button("Make Choice") | |
game_log = gr.Textbox(label="Game Log", lines=20, value=initgameinfo[2]) | |
game_session = gr.State(value=initgameinfo[3]) | |
submit_btn.click( | |
make_choice, | |
inputs=[choices, game_session], | |
outputs=[description, choices, game_log, game_session] | |
) | |
with gr.Column(scale=1): | |
gr.Markdown("# Debugging") | |
error_box = gr.Textbox(label="Path Errors", lines=4, value=path_errors) | |
with gr.Accordion("Config (Game Spoiler)", open=False): | |
custom_config = gr.Textbox(label="Custom Configuration (JSON)", value=json.dumps(all_states, default=lambda o: o.__dict__, indent=2), lines=8) | |
custom_configbtn = gr.Button("Load Custom Config") | |
custom_configbtn.click( | |
load_game, | |
inputs=[custom_config], | |
outputs=[error_box, game_log, description, choices, game_session, custom_config] | |
) | |
with gr.Tab("Custom JS Config Creator"): | |
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)") | |
with gr.Tab("Simple Config Creator"): | |
inventory_items = gr.State([]) | |
skills_items = gr.State([]) | |
objectives_items = gr.State([]) | |
targets_items = gr.State([]) | |
with gr.Tabs(): | |
with gr.TabItem("Inventory"): | |
inventory_type = gr.Textbox(label="Type") | |
inventory_name = gr.Textbox(label="Name") | |
inventory_description = gr.Textbox(label="Description") | |
add_inventory = gr.Button("Add Inventory Item") | |
inventory_textbox = gr.JSON(label="Inventory Items", value=[]) | |
with gr.TabItem("Skills"): | |
skills_branch = gr.Textbox(label="Branch") | |
skills_name = gr.Textbox(label="Name") | |
skills_learned = gr.Dropdown(choices=["True", "False"], label="Learned") | |
add_skill_button = gr.Button("Add Skill") | |
skills_textbox = gr.JSON(label="Skills", value=[]) | |
with gr.TabItem("Objectives"): | |
objectives_id = gr.Textbox(label="ID") | |
objectives_name = gr.Textbox(label="Name") | |
objectives_complete = gr.Dropdown(choices=["True", "False"], label="Complete") | |
add_objective_button = gr.Button("Add Objective") | |
objectives_textbox = gr.JSON(label="Objectives", value=[]) | |
with gr.TabItem("Targets"): | |
targets_name = gr.Textbox(label="Name") | |
targets_x = gr.Textbox(label="X Coordinate") | |
targets_y = gr.Textbox(label="Y Coordinate") | |
targets_collisionType = gr.Textbox(label="Collision Type") | |
targets_collisiontext = gr.Textbox(label="Collision Text") | |
add_target_button = gr.Button("Add Target") | |
targets_textbox = gr.JSON(label="Targets", value=[]) | |
with gr.TabItem("Placeholders for Modal Target"): | |
gr.HTML("Placeholder") | |
with gr.TabItem("Placeholders for State Machine Modal Target"): | |
gr.HTML("Placeholder") | |
with gr.TabItem("Placeholders for Background"): | |
gr.HTML("Placeholder") | |
config_output = gr.JSON(label="Updated Configuration") | |
#, outputs=config_output) | |
def aggregate_config(inventory, skills, objectives, targets): | |
config = default_config.copy() | |
config['inventory'] = inventory | |
config['skills'] = skills | |
config['objectives'] = objectives | |
config['targets'] = targets | |
return config | |
add_inventory.click(add_inventory_item, inputs=[inventory_items, inventory_type, inventory_name, inventory_description], outputs=inventory_textbox) | |
add_inventory.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output) | |
add_skill_button.click(add_skill, inputs=[skills_items, skills_branch, skills_name, skills_learned], outputs=skills_textbox) | |
add_skill_button.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output) | |
add_objective_button.click(add_objective, inputs=[objectives_items, objectives_id, objectives_name, objectives_complete], outputs=objectives_textbox) | |
add_objective_button.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output) | |
add_target_button.click(add_target, inputs=[targets_items, targets_name, targets_x, targets_y, targets_collisionType, targets_collisiontext], outputs=targets_textbox) | |
add_target_button.click(aggregate_config, inputs=[inventory_items, skills_items, objectives_items, targets_items], outputs=config_output) | |
with gr.Tab("Advanced Config Creator"): | |
gr.HTML("Config with More than text and images") | |
with gr.Tab("Asset Generation"): | |
gr.HTML("With some ideas from gemini-1.5-flash-api-0514 and reka-flash-preview-20240611 <br><br>Licenses for the spaces still to be evaluated") | |
with gr.Tab("Save files"): | |
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") | |
gr.HTML("Placeholder for huggingface spaces that can assist ") | |
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") | |
with gr.Tab("Images"): | |
gr.HTML("Concept Art, UI elements, Static/3D Characters, Environments and Objects") | |
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, ") | |
gr.HTML("Images Generation Portraits = https://huggingface.co/spaces/okaris/omni-zero") | |
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") | |
gr.HTML("Images Generation Posters with text - https://huggingface.co/spaces/GlyphByT5/Glyph-SDXL-v2") | |
gr.HTML("Images Generation Very Specific position and shape - https://huggingface.co/spaces/linoyts/scribble-sdxl-flash") | |
gr.HTML("SVG Generation = Coding models - ") | |
gr.HTML("Placeholder for huggingface spaces that can assist <br> https://huggingface.co/spaces/gokaygokay/Florence-2 <br>") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Audio"): | |
gr.HTML("Music - Background, Interactive, Cutscene, Menu <br>Sound Effects - Environment, character, action (environmental triggered by user eg. gun), UI <br>Speech - Dialouge, narration, voiceover <br>The new render function means the Config can be made and iframe/api functions can be ordered as neccessary based on the part of the config that needs it to streamline workflows based on current state of config ") | |
gr.HTML("Placeholder for huggingface spaces that can assist") | |
gr.HTML("Audio Sound Effects - https://huggingface.co/spaces/artificialguybr/Stable-Audio-Open-Zero") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Video"): | |
gr.HTML("Cutscenes, Tutorials, Trailers") | |
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") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("3D"): | |
gr.HTML("Characters, Environments, Objects") | |
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") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Animations (for lower resource use)"): | |
gr.HTML("Characters, Environments, Objects") | |
gr.HTML("Placeholder for huggingface spaces that can assist - image as 3d object in video https://huggingface.co/spaces/ashawkey/LGM") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Fonts"): | |
gr.HTML("Style of whole game, or locations, or characters") | |
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") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Shaders and related"): | |
gr.HTML("Post-processing Effects, material effects, Particle systems, visual feedback") | |
gr.HTML("Visual Effects - eg. explosion can turn all items white for a moment, losing conciousness blurs whole screen") | |
gr.HTML("Placeholder for huggingface spaces that can assist") | |
gr.HTML("Placeholder for models small enough to run on cpu here in this space that can assist") | |
with gr.Tab("Other Considerations"): | |
with gr.Tab("General"): | |
gr.HTML("Experiment for https://huggingface.co/spaces/ysharma/open-interpreter/blob/main/app.py inplementation with gradio client api") | |
gr.HTML("Some conderations for future integration: https://huggingface.co/spaces/dylanebert/3d-arena, https://github.com/fudan-generative-vision/hallo") | |
gr.HTML("Useful Spaces and links: https://huggingface.co/spaces/artificialguybr/Stable-Audio-Open-Zero https://huggingface.co/spaces/stabilityai/TripoSR https://huggingface.co/spaces/wangfuyun/AnimateLCM-SVD https://huggingface.co/spaces/multimodalart/face-to-all https://huggingface.co/spaces/facebook/MusicGen https://huggingface.co/spaces/Doubiiu/tooncrafter") | |
gr.HTML("https://huggingface.co/spaces/linoyts/scribble-sdxl-flash as map planner") | |
gr.HTML("---------------------------------------Gameplay Ideas-------------------------------") | |
gr.HTML("https://huggingface.co/spaces/Lin-Chen/ShareCaptioner-Video - game use example police questions a event with multiple eye witnesses needs to give as close to the caption description to win") | |
with gr.Tab("Backend and/or Hosting?"): | |
gr.HTML("Prototyping and freemium <br>free api <br>HF Pro subscription") | |
gr.HTML("GPU (Data privacy) = No Rate limits? - https://lambdalabs.com/service/gpu-cloud https://huggingface.co/pricing#endpoints") | |
gr.HTML("Speed - Groq, SambaNova, ") | |
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?") | |
with gr.Tab("Asset loading test"): | |
with gr.Row(): | |
gr.Image(value="testmedia/Flash scribble SDXL - random squiggles as roads.webp") | |
gr.Video(value="testmedia/SVD - random squiggles as roads video 004484.mp4") | |
gr.Audio(value="testmedia/Stable Audio - Raindrops, output.wav") | |
gr.HTML("Placeholder to test use as all media loader for ease of prototyping") | |
demo.launch() | |