Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
import random
|
3 |
|
4 |
class HangmanGame:
|
5 |
def __init__(self):
|
6 |
self.reset_game()
|
7 |
-
|
8 |
-
# Optional: Add a small dictionary of words if you want predefined options
|
9 |
-
self.word_list = [
|
10 |
-
"PYTHON", "PROGRAMMAZIONE", "COMPUTER", "INTELLIGENZA",
|
11 |
-
"SVILUPPATORE", "TECNOLOGIA", "ALGORITMO"
|
12 |
-
]
|
13 |
|
14 |
def reset_game(self):
|
15 |
self.word_to_guess = ""
|
@@ -33,7 +26,7 @@ class HangmanGame:
|
|
33 |
self.word_to_guess = word
|
34 |
self.display_word = ['_'] * len(word)
|
35 |
|
36 |
-
return "Gioco iniziato!
|
37 |
|
38 |
def make_guess(self, guess):
|
39 |
# If game is already over, prevent further guessing
|
@@ -103,7 +96,9 @@ def guess_interface(guess):
|
|
103 |
|
104 |
# Create Gradio interface
|
105 |
with gr.Blocks() as demo:
|
106 |
-
gr.Markdown("# 🎲 Gioco dell'Impiccato")
|
|
|
|
|
107 |
|
108 |
# Status displays
|
109 |
status_output = gr.Textbox(label="Stato del Gioco", interactive=False)
|
@@ -112,12 +107,12 @@ with gr.Blocks() as demo:
|
|
112 |
|
113 |
# Word input section
|
114 |
with gr.Row():
|
115 |
-
word_input = gr.Textbox(label="Inserisci una parola
|
116 |
start_btn = gr.Button("Inizia Gioco")
|
117 |
|
118 |
# Guess input section
|
119 |
with gr.Row():
|
120 |
-
guess_input = gr.Textbox(label="Inserisci una lettera o la parola completa")
|
121 |
guess_btn = gr.Button("Indovina")
|
122 |
|
123 |
# Button actions
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
class HangmanGame:
|
4 |
def __init__(self):
|
5 |
self.reset_game()
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
def reset_game(self):
|
8 |
self.word_to_guess = ""
|
|
|
26 |
self.word_to_guess = word
|
27 |
self.display_word = ['_'] * len(word)
|
28 |
|
29 |
+
return "Gioco iniziato! Secondo giocatore: indovina la parola.", ' '.join(self.display_word), 6
|
30 |
|
31 |
def make_guess(self, guess):
|
32 |
# If game is already over, prevent further guessing
|
|
|
96 |
|
97 |
# Create Gradio interface
|
98 |
with gr.Blocks() as demo:
|
99 |
+
gr.Markdown("# 🎲 Gioco dell'Impiccato per Due Giocatori")
|
100 |
+
gr.Markdown("## Primo giocatore: inserisci la parola da indovinare")
|
101 |
+
gr.Markdown("## Secondo giocatore: cerca di indovinare la parola")
|
102 |
|
103 |
# Status displays
|
104 |
status_output = gr.Textbox(label="Stato del Gioco", interactive=False)
|
|
|
107 |
|
108 |
# Word input section
|
109 |
with gr.Row():
|
110 |
+
word_input = gr.Textbox(label="Primo giocatore: Inserisci una parola segreta")
|
111 |
start_btn = gr.Button("Inizia Gioco")
|
112 |
|
113 |
# Guess input section
|
114 |
with gr.Row():
|
115 |
+
guess_input = gr.Textbox(label="Secondo giocatore: Inserisci una lettera o la parola completa")
|
116 |
guess_btn = gr.Button("Indovina")
|
117 |
|
118 |
# Button actions
|