Spaces:
Sleeping
Sleeping
Commit ·
b152caa
1
Parent(s): e1936c8
fix: move graders.py and tasks.py into my_env folder
Browse files- graders.py → my_env/graders.py +0 -0
- my_env/tasks.py +67 -0
- tasks.py +0 -67
graders.py → my_env/graders.py
RENAMED
|
File without changes
|
my_env/tasks.py
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tasks.py — defines all 3 tasks and their action schema
|
| 2 |
+
|
| 3 |
+
TASKS = [
|
| 4 |
+
{
|
| 5 |
+
"task_id": 1,
|
| 6 |
+
"name": "Basic Moisture Control",
|
| 7 |
+
"difficulty": "easy",
|
| 8 |
+
"description": "Keep soil moisture between 40–70% for 7 days.",
|
| 9 |
+
"max_steps": 7,
|
| 10 |
+
"goal": "moisture_in_range"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"task_id": 2,
|
| 14 |
+
"name": "Weather Adaptive Irrigation",
|
| 15 |
+
"difficulty": "medium",
|
| 16 |
+
"description": "Manage irrigation across 14 days with changing weather.",
|
| 17 |
+
"max_steps": 14,
|
| 18 |
+
"goal": "handle_weather"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"task_id": 3,
|
| 22 |
+
"name": "Full Season Management",
|
| 23 |
+
"difficulty": "hard",
|
| 24 |
+
"description": "Manage a full 30-day crop season across Seedling, Growing, and Mature stages.",
|
| 25 |
+
"max_steps": 30,
|
| 26 |
+
"goal": "full_season"
|
| 27 |
+
}
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
ACTION_SCHEMA = {
|
| 31 |
+
"type": "discrete",
|
| 32 |
+
"n": 4,
|
| 33 |
+
"actions": {
|
| 34 |
+
0: "no_water",
|
| 35 |
+
1: "low_water",
|
| 36 |
+
2: "medium_water",
|
| 37 |
+
3: "high_water"
|
| 38 |
+
},
|
| 39 |
+
"description": "Choose how much water to give the crop each day."
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def get_all_tasks():
|
| 44 |
+
"""Returns the list of all tasks with action schema."""
|
| 45 |
+
return {
|
| 46 |
+
"tasks": TASKS,
|
| 47 |
+
"action_schema": ACTION_SCHEMA
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def get_task_by_id(task_id):
|
| 52 |
+
"""Returns a single task by its ID."""
|
| 53 |
+
for task in TASKS:
|
| 54 |
+
if task["task_id"] == task_id:
|
| 55 |
+
return task
|
| 56 |
+
return None
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# Quick test
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
+
print("All tasks:")
|
| 62 |
+
result = get_all_tasks()
|
| 63 |
+
for task in result["tasks"]:
|
| 64 |
+
print(f" Task {task['task_id']}: {task['name']} ({task['difficulty']})")
|
| 65 |
+
print("\nAction schema:")
|
| 66 |
+
for k, v in result["action_schema"]["actions"].items():
|
| 67 |
+
print(f" {k} = {v}")
|
tasks.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
# tasks.py — defines all 3 tasks and their action schema
|
| 2 |
-
|
| 3 |
-
TASKS = [
|
| 4 |
-
{
|
| 5 |
-
"task_id": 1,
|
| 6 |
-
"name": "Basic Moisture Control",
|
| 7 |
-
"difficulty": "easy",
|
| 8 |
-
"description": "Keep soil moisture between 40–70% for 7 days.",
|
| 9 |
-
"max_steps": 7,
|
| 10 |
-
"goal": "moisture_in_range"
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"task_id": 2,
|
| 14 |
-
"name": "Weather Adaptive Irrigation",
|
| 15 |
-
"difficulty": "medium",
|
| 16 |
-
"description": "Manage irrigation across 14 days with changing weather.",
|
| 17 |
-
"max_steps": 14,
|
| 18 |
-
"goal": "handle_weather"
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"task_id": 3,
|
| 22 |
-
"name": "Full Season Management",
|
| 23 |
-
"difficulty": "hard",
|
| 24 |
-
"description": "Manage a full 30-day crop season across Seedling, Growing, and Mature stages.",
|
| 25 |
-
"max_steps": 30,
|
| 26 |
-
"goal": "full_season"
|
| 27 |
-
}
|
| 28 |
-
]
|
| 29 |
-
|
| 30 |
-
ACTION_SCHEMA = {
|
| 31 |
-
"type": "discrete",
|
| 32 |
-
"n": 4,
|
| 33 |
-
"actions": {
|
| 34 |
-
0: "no_water",
|
| 35 |
-
1: "low_water",
|
| 36 |
-
2: "medium_water",
|
| 37 |
-
3: "high_water"
|
| 38 |
-
},
|
| 39 |
-
"description": "Choose how much water to give the crop each day."
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def get_all_tasks():
|
| 44 |
-
"""Returns the list of all tasks with action schema."""
|
| 45 |
-
return {
|
| 46 |
-
"tasks": TASKS,
|
| 47 |
-
"action_schema": ACTION_SCHEMA
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
def get_task_by_id(task_id):
|
| 52 |
-
"""Returns a single task by its ID."""
|
| 53 |
-
for task in TASKS:
|
| 54 |
-
if task["task_id"] == task_id:
|
| 55 |
-
return task
|
| 56 |
-
return None
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
# Quick test
|
| 60 |
-
if __name__ == "__main__":
|
| 61 |
-
print("All tasks:")
|
| 62 |
-
result = get_all_tasks()
|
| 63 |
-
for task in result["tasks"]:
|
| 64 |
-
print(f" Task {task['task_id']}: {task['name']} ({task['difficulty']})")
|
| 65 |
-
print("\nAction schema:")
|
| 66 |
-
for k, v in result["action_schema"]["actions"].items():
|
| 67 |
-
print(f" {k} = {v}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|