-
Notifications
You must be signed in to change notification settings - Fork 0
/
genPddlProblem.py
executable file
·51 lines (40 loc) · 1.33 KB
/
genPddlProblem.py
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
#!/usr/bin/python
###############################################
# #
# Generador de problemas en pddl #
# Recibe: #
# N: tamano del grid (NxN) #
# OX: coordenada origen x #
# OY: coordenada origen y #
# DX: coordenada destino x #
# DY: coordenada destino y #
# #
###############################################
import sys
import random
def uso():
print "USO: ./genPddlProblem.py <tamano del grid> <origen x> <origen y> <destino x> <destino y> <archivo salida>"
if (len(sys.argv)!=7):
uso()
exit(0)
N = sys.argv[1]
OX = sys.argv[2]
OY = sys.argv[3]
DX = sys.argv[4]
DY = sys.argv[5]
outfile = sys.argv[6]
# Se abre el archivo para su escritura
of = open(outfile,"w")
# Se escriben los datos del grid, uno por linea
of.write("(define (problem SEMAFOROS-GRID)\n\n")
of.write("(:domain SEMAFOROS)\n\n")
of.write("(:objects")
for i in range (0,int(N)):
for j in range (0,int(N)):
of.write(" i"+str(i)+str(j))
of.write(")\n\n")
of.write("(:INIT (turno_carro)\n")
of.write("\t(carro_"+OX+"_"+OY+")\n")
of.write("\t(t0))\n\n")
of.write("(:goal (and (carro_"+DX+"_"+DY+") (turno_carro)))\n\n)")
of.close()