File size: 2,738 Bytes
18b61a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe01c8c
18b61a0
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import gradio as gr
from game_world import GameWorld, GameSession

# Initialize game
world = GameWorld()
game_session = GameSession(world)

def main_game_loop(message, history):
    """Main game loop function for Gradio interface"""
    return game_session.run_action(message, history)

# Create Gradio interface
def create_interface():
    with gr.Blocks(theme=gr.themes.Soft(), title="Mythic Realms") as demo:
        gr.HTML("""
        <div style="text-align: center; padding: 20px;">
            <h1>๐Ÿฐ Mythic Realms: AI Fantasy RPG</h1>
            <p>Embark on an epic adventure in Aethermoor, a world of floating cities and sky whales!</p>
            <p><em>Type 'start game' to begin your journey</em></p>
        </div>
        """)
        
        chatbot = gr.Chatbot(
            height=500,
            placeholder="๐ŸŽฎ Ready to start your adventure? Type 'start game' to begin!",
            show_label=False,
            container=True,
            bubble_full_width=False
        )
        
        with gr.Row():
            msg = gr.Textbox(
                placeholder="What do you do next? (e.g., 'Look around', 'Talk to Captain Zara', 'Explore the docks')",
                container=False,
                scale=4
            )
            submit_btn = gr.Button("๐Ÿš€ Act", scale=1, variant="primary")
        
        with gr.Row():
            gr.Examples(
                examples=[
                    "Start game",
                    "Look around the docks",
                    "Talk to Captain Zara Windwhisper",
                    "Explore the market",
                    "Ask about sky ships",
                    "Check my inventory",
                    "Look for adventure"
                ],
                inputs=msg
            )
        
        # Set up the chat interface
        def respond(message, history):
            response = main_game_loop(message, history)
            history.append((message, response))
            return history, ""
        
        msg.submit(respond, [msg, chatbot], [chatbot, msg])
        submit_btn.click(respond, [msg, chatbot], [chatbot, msg])
        
        gr.HTML("""
        <div style="text-align: center; margin-top: 20px; padding: 10px; background-color: #aba0ab; border-radius: 10px;">
            <p><strong>๐ŸŽฏ Game Tips:</strong></p>
            <p>โ€ข Use natural language to describe your actions</p>
            <p>โ€ข Interact with NPCs to learn about the world</p>
            <p>โ€ข Manage your inventory wisely</p>
            <p>โ€ข Explore different locations for unique adventures</p>
        </div>
        """)
    
    return demo

# Launch the app
if __name__ == "__main__":
    demo = create_interface()
    demo.launch()