-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_pddl_bulk.sh
executable file
·87 lines (75 loc) · 3.03 KB
/
generate_pddl_bulk.sh
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
78
79
80
81
82
83
84
85
86
87
#!/bin/zsh
# define the tasks to skip
declare -a skip_task_array=("PDDL Files" "Farm_Wheat" "Craft_Item" "Grow_Tree", "Scaled_Move_to_Location" "Scaled_Move_to_Location_extended")
# define the difficulty levels
declare -a difficulty_array=("Easy" "Medium" "Hard")
# define the default observation ranges, as well as any task-specific overrides
# note that the overrides will have to specially handled later on
declare -A obsrange_array=(
[Easy]="(13, 9, 13)"
[Medium]="(21, 15, 21)"
[Hard]="(71, 31, 71)"
)
declare -A cabin_obsrange_array=(
[Easy]="(21, 11, 21)"
[Medium]="(41, 11, 41)"
[Hard]="(65, 11, 65)"
)
declare -A cuttree_obsrange_array=(
[Easy]="(21, 31, 21)"
[Medium]="(41, 31, 41)"
[Hard]="(65, 31, 65)"
)
# define the pddl types
declare -a pddl_types=("numerical" "propositional")
# loop through the tasks, difficulties, and pddl types
for task in ./task-worlds/*; do
# extract the task name from the file path (it will be the last element)
task=$(basename $task)
# check if the task is in the skip array
skip=false
for element in "${skip_task_array[@]}"; do
if [[ "${element}" == "${task}" ]]; then
echo "========== Skipping task ${task}... =========="
skip=true
fi
done
if [ $skip = true ]; then
continue
fi
echo "========== Processing task ${task} =========="
for difficulty in ${difficulty_array[@]}; do
for pddl_type in ${pddl_types[@]}; do
# define the task folder and yaml file
task_folder="./task-worlds/${task}/${task}_${difficulty}"
yaml_file="${task_folder}.yaml"
# define the observation range, and check if there is a task-specific override
obsrange=${obsrange_array[$difficulty]}
if [ $task = "Build_Cabin" ]; then
obsrange=${cabin_obsrange_array[$difficulty]}
elif [ $task = "Cut_Tree" ]; then
obsrange=${cuttree_obsrange_array[$difficulty]}
fi
echo "Generating PDDL for ${task}_${difficulty} for ${pddl_type} pddl..."
# check if the yaml file exists - there may be special cases where it does not
if [ ! -f $yaml_file ]; then
echo "YAML file ${yaml_file} does not exist! Skipping..."
continue
fi
# generate the pddl
output_path="problems/tasks/${task}/${difficulty}/${pddl_type}/${task}_${difficulty}"
python src/main.py \
--generate-pddl \
--pddl-type ${pddl_type} \
--world-config "${yaml_file}" \
--domain-name "${task}_${difficulty}" \
--problem-name "${task}_${difficulty}_problem" \
--domain-file "${output_path}_domain.pddl" \
--problem-file "${output_path}_problem.pddl" \
--max-inventory-stack 64 \
--observation-range "${obsrange}"
# kill the minecraft java process
pkill -9 -f java
done
done
done