Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,11 +22,11 @@ def simulate_agent(start_pos):
|
|
| 22 |
r, c = map(int, start_pos.split(','))
|
| 23 |
|
| 24 |
if not (0 <= r < 5 and 0 <= c < 5):
|
| 25 |
-
return None, "
|
| 26 |
|
| 27 |
current_state = (r, c)
|
| 28 |
except Exception:
|
| 29 |
-
return None, "
|
| 30 |
|
| 31 |
path = [current_state]
|
| 32 |
steps = 0
|
|
@@ -65,7 +65,7 @@ def simulate_agent(start_pos):
|
|
| 65 |
path_r, path_c = zip(*path)
|
| 66 |
ax.plot(path_c, path_r, marker='o', color='blue', linewidth=2, label='Agent Path')
|
| 67 |
|
| 68 |
-
status = "Success!
|
| 69 |
ax.set_title(f"Simulation: {status}")
|
| 70 |
plt.legend()
|
| 71 |
|
|
@@ -77,7 +77,7 @@ demo = gr.Interface(
|
|
| 77 |
fn=simulate_agent,
|
| 78 |
inputs=gr.Textbox(label="Starting Position (row,col)", value="0,0", placeholder="Enter 0-4 coordinates"),
|
| 79 |
outputs=[gr.Plot(label="Navigation Map"), gr.Text(label="Path Details")],
|
| 80 |
-
title="
|
| 81 |
description="The agent uses Reinforcement Learning (Q-Learning) to navigate to the green goal while avoiding pits.",
|
| 82 |
theme=gr.themes.Soft(),
|
| 83 |
css=".share-button { display: none !important; }"
|
|
|
|
| 22 |
r, c = map(int, start_pos.split(','))
|
| 23 |
|
| 24 |
if not (0 <= r < 5 and 0 <= c < 5):
|
| 25 |
+
return None, " Error: Coordinates must be between 0 and 4 (e.g., '0,2')."
|
| 26 |
|
| 27 |
current_state = (r, c)
|
| 28 |
except Exception:
|
| 29 |
+
return None, " Invalid format. Please use 'row,col' (e.g., 0,0)."
|
| 30 |
|
| 31 |
path = [current_state]
|
| 32 |
steps = 0
|
|
|
|
| 65 |
path_r, path_c = zip(*path)
|
| 66 |
ax.plot(path_c, path_r, marker='o', color='blue', linewidth=2, label='Agent Path')
|
| 67 |
|
| 68 |
+
status = "Success! " if path[-1] == goal else "Fell in a Pit "
|
| 69 |
ax.set_title(f"Simulation: {status}")
|
| 70 |
plt.legend()
|
| 71 |
|
|
|
|
| 77 |
fn=simulate_agent,
|
| 78 |
inputs=gr.Textbox(label="Starting Position (row,col)", value="0,0", placeholder="Enter 0-4 coordinates"),
|
| 79 |
outputs=[gr.Plot(label="Navigation Map"), gr.Text(label="Path Details")],
|
| 80 |
+
title=" Autonomous Grid Navigator",
|
| 81 |
description="The agent uses Reinforcement Learning (Q-Learning) to navigate to the green goal while avoiding pits.",
|
| 82 |
theme=gr.themes.Soft(),
|
| 83 |
css=".share-button { display: none !important; }"
|