-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudoku.hddl
48 lines (48 loc) · 2.44 KB
/
sudoku.hddl
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
(define (domain sudoku)
(:requirements :hierarchy :typing :strips :universal-preconditions)
(:types row col digit box)
(:predicates
(cell-at-box ?b - box ?c - col ?r - row)
(digit-at ?d - digit ?c - col ?r - row)
(digit-at-box ?d - digit ?b - box)
(filled ?c - col ?r - row)
(inc-row ?a ?b - row)
(inc-col ?a ?b - col))
(:constants
d1 d2 d3 d4 d5 d6 d7 d8 d9 - digit
b0 b1 b2 b3 b4 b5 b6 b7 b8 - box
c0 c1 c2 c3 c4 c5 c6 c7 c8 - col
r0 r1 r2 r3 r4 r5 r6 r7 r8 - row)
(:task all-check :parameters())
(:task fill-cell :parameters (?b - box ?c - col ?r - row ?d - digit))
(:task check-box :parameters (?b - box ?d - digit))
(:task check-row :parameters (?r - row ?d - digit))
(:task check-column :parameters (?c - col ?d - digit))
(:method m-all-check
:parameters ()
:task (all-check)
:precondition (and (forall (?r - row ?c - col) (filled ?c ?r))))
(:method m-fill-cell
:parameters (?b - box ?c - col ?r - row ?d - digit)
:task (fill-cell ?b ?c ?r ?d)
:precondition (and (not (filled ?c ?r)))
:ordered-subtasks (and (check-box ?b ?d) (check-row ?r ?d) (check-column ?c ?d) (FILL-CELL ?b ?c ?r ?d)))
(:method m-check-row
:parameters (?c0 ?c1 ?c2 ?c3 ?c4 ?c5 ?c6 ?c7 ?c8 - col ?r - row ?d - digit)
:task (check-row ?r ?d)
:precondition (and (inc-col ?c0 ?c1) (inc-col ?c1 ?c2) (inc-col ?c2 ?c3) (inc-col ?c3 ?c4) (inc-col ?c4 ?c5) (inc-col ?c5 ?c6) (inc-col ?c6 ?c7) (inc-col ?c7 ?c8)
(forall (?c - col) (not (digit-at ?d ?c ?r)))))
(:method m-check-column
:parameters (?c - col ?r0 ?r1 ?r2 ?r3 ?r4 ?r5 ?r6 ?r7 ?r8 - row ?d - digit)
:task (check-column ?c ?d)
:precondition (and (inc-row ?r0 ?r1) (inc-row ?r1 ?r2) (inc-row ?r2 ?r3) (inc-row ?r3 ?r4) (inc-row ?r4 ?r5) (inc-row ?r5 ?r6) (inc-row ?r6 ?r7) (inc-row ?r7 ?r8)
(forall (?r - row) (not (digit-at ?d ?c ?r)))))
(:method m-check-box
:parameters (?b - box ?d - digit)
:task (check-box ?b ?d)
:precondition (and (not (digit-at-box ?d ?b))))
(:action FILL-CELL
:parameters (?b - box ?c - col ?r - row ?d - digit)
:precondition (and (cell-at-box ?b ?c ?r))
:effect (and (digit-at ?d ?c ?r) (digit-at-box ?d ?b) (filled ?c ?r)))
)