Skip to content

Instantly share code, notes, and snippets.

@SamButers
Last active June 16, 2023 09:03
Show Gist options
  • Save SamButers/cb539245f680b25077f0d94264f8758a to your computer and use it in GitHub Desktop.
Save SamButers/cb539245f680b25077f0d94264f8758a to your computer and use it in GitHub Desktop.
using PDDL, SymbolicPlanners, Dates
domain = load_domain("puzznic_domain.pddl")
problem = load_problem("problem-7.pddl")
state = initstate(domain, problem)
spec = MinMetricGoal(problem)
planner = ForwardPlanner()
sol = planner(domain, state, spec)
using PDDL, SymbolicPlanners, Dates
domain = load_domain("puzznic_domain.pddl")
problem = load_problem("problem-7.pddl")
spec = MinMetricGoal(problem)
c_domain, c_state = compiled(domain, problem)
planner = ForwardPlanner()
sol = planner(c_domain, c_state, spec)
(define (problem puzznic-7)
(:domain puzznic)
(:objects block0 - block block1 - block block2 - block block3 - block block4 - block block5 - block block6 - block block7 - block block8 - block block9 - block block10 - block block11 - block block12 - block block13 - block block14 - block block15 - block block16 - block block17 - block block18 - block block19 - block block20 - block block21 - block block22 - matching-block block23 - block block24 - block block25 - block block26 - block block27 - block block28 - block block29 - matching-block block30 - matching-block block31 - block block32 - block block33 - block block34 - block block35 - block block36 - matching-block block37 - matching-block block38 - matching-block block39 - block block40 - block block41 - block block42 - block block43 - matching-block block44 - matching-block block45 - matching-block block46 - matching-block block47 - block block48 - block block49 - block block50 - matching-block block51 - matching-block block52 - matching-block block53 - matching-block block54 - block block55 - block block56 - block block57 - block block58 - block block59 - block block60 - block block61 - block block62 - block block63 - block)
(:init
(is-empty block0)
(right block0 block1)
(down block0 block8)
(is-immovable block1)
(left block1 block0)
(right block1 block2)
(down block1 block9)
(is-immovable block2)
(left block2 block1)
(right block2 block3)
(down block2 block10)
(is-immovable block3)
(left block3 block2)
(right block3 block4)
(down block3 block11)
(is-immovable block4)
(left block4 block3)
(right block4 block5)
(down block4 block12)
(is-immovable block5)
(left block5 block4)
(right block5 block6)
(down block5 block13)
(is-immovable block6)
(left block6 block5)
(right block6 block7)
(down block6 block14)
(is-immovable block7)
(left block7 block6)
(right block7 block8)
(down block7 block15)
(is-immovable block8)
(left block8 block7)
(up block8 block0)
(right block8 block9)
(down block8 block16)
(is-immovable block9)
(left block9 block8)
(up block9 block1)
(right block9 block10)
(down block9 block17)
(is-empty block10)
(left block10 block9)
(up block10 block2)
(right block10 block11)
(down block10 block18)
(is-empty block11)
(left block11 block10)
(up block11 block3)
(right block11 block12)
(down block11 block19)
(is-empty block12)
(left block12 block11)
(up block12 block4)
(right block12 block13)
(down block12 block20)
(is-empty block13)
(left block13 block12)
(up block13 block5)
(right block13 block14)
(down block13 block21)
(is-empty block14)
(left block14 block13)
(up block14 block6)
(right block14 block15)
(down block14 block22)
(is-immovable block15)
(left block15 block14)
(up block15 block7)
(right block15 block16)
(down block15 block23)
(is-immovable block16)
(left block16 block15)
(up block16 block8)
(right block16 block17)
(down block16 block24)
(is-empty block17)
(left block17 block16)
(up block17 block9)
(right block17 block18)
(down block17 block25)
(is-empty block18)
(left block18 block17)
(up block18 block10)
(right block18 block19)
(down block18 block26)
(is-empty block19)
(left block19 block18)
(up block19 block11)
(right block19 block20)
(down block19 block27)
(is-empty block20)
(left block20 block19)
(up block20 block12)
(right block20 block21)
(down block20 block28)
(is-empty block21)
(left block21 block20)
(up block21 block13)
(right block21 block22)
(down block21 block29)
(left block22 block21)
(up block22 block14)
(right block22 block23)
(down block22 block30)
(is-immovable block23)
(left block23 block22)
(up block23 block15)
(right block23 block24)
(down block23 block31)
(is-immovable block24)
(left block24 block23)
(up block24 block16)
(right block24 block25)
(down block24 block32)
(is-empty block25)
(left block25 block24)
(up block25 block17)
(right block25 block26)
(down block25 block33)
(is-empty block26)
(left block26 block25)
(up block26 block18)
(right block26 block27)
(down block26 block34)
(is-empty block27)
(left block27 block26)
(up block27 block19)
(right block27 block28)
(down block27 block35)
(is-empty block28)
(left block28 block27)
(up block28 block20)
(right block28 block29)
(down block28 block36)
(left block29 block28)
(up block29 block21)
(right block29 block30)
(down block29 block37)
(left block30 block29)
(up block30 block22)
(right block30 block31)
(down block30 block38)
(is-immovable block31)
(left block31 block30)
(up block31 block23)
(right block31 block32)
(down block31 block39)
(is-immovable block32)
(left block32 block31)
(up block32 block24)
(right block32 block33)
(down block32 block40)
(is-empty block33)
(left block33 block32)
(up block33 block25)
(right block33 block34)
(down block33 block41)
(is-empty block34)
(left block34 block33)
(up block34 block26)
(right block34 block35)
(down block34 block42)
(is-empty block35)
(left block35 block34)
(up block35 block27)
(right block35 block36)
(down block35 block43)
(left block36 block35)
(up block36 block28)
(right block36 block37)
(down block36 block44)
(left block37 block36)
(up block37 block29)
(right block37 block38)
(down block37 block45)
(left block38 block37)
(up block38 block30)
(right block38 block39)
(down block38 block46)
(is-immovable block39)
(left block39 block38)
(up block39 block31)
(right block39 block40)
(down block39 block47)
(is-immovable block40)
(left block40 block39)
(up block40 block32)
(right block40 block41)
(down block40 block48)
(is-empty block41)
(left block41 block40)
(up block41 block33)
(right block41 block42)
(down block41 block49)
(is-empty block42)
(left block42 block41)
(up block42 block34)
(right block42 block43)
(down block42 block50)
(left block43 block42)
(up block43 block35)
(right block43 block44)
(down block43 block51)
(left block44 block43)
(up block44 block36)
(right block44 block45)
(down block44 block52)
(left block45 block44)
(up block45 block37)
(right block45 block46)
(down block45 block53)
(left block46 block45)
(up block46 block38)
(right block46 block47)
(down block46 block54)
(is-immovable block47)
(left block47 block46)
(up block47 block39)
(right block47 block48)
(down block47 block55)
(is-immovable block48)
(left block48 block47)
(up block48 block40)
(right block48 block49)
(down block48 block56)
(is-empty block49)
(left block49 block48)
(up block49 block41)
(right block49 block50)
(down block49 block57)
(left block50 block49)
(up block50 block42)
(right block50 block51)
(down block50 block58)
(left block51 block50)
(up block51 block43)
(right block51 block52)
(down block51 block59)
(left block52 block51)
(up block52 block44)
(right block52 block53)
(down block52 block60)
(left block53 block52)
(up block53 block45)
(right block53 block54)
(down block53 block61)
(is-immovable block54)
(left block54 block53)
(up block54 block46)
(right block54 block55)
(down block54 block62)
(is-immovable block55)
(left block55 block54)
(up block55 block47)
(right block55 block56)
(down block55 block63)
(is-immovable block56)
(left block56 block55)
(up block56 block48)
(right block56 block57)
(is-immovable block57)
(left block57 block56)
(up block57 block49)
(right block57 block58)
(is-immovable block58)
(left block58 block57)
(up block58 block50)
(right block58 block59)
(is-immovable block59)
(left block59 block58)
(up block59 block51)
(right block59 block60)
(is-immovable block60)
(left block60 block59)
(up block60 block52)
(right block60 block61)
(is-immovable block61)
(left block61 block60)
(up block61 block53)
(right block61 block62)
(is-immovable block62)
(left block62 block61)
(up block62 block54)
(right block62 block63)
(is-empty block63)
(left block63 block62)
(up block63 block55)
(same-color block46 block53)
(same-color block53 block46)
(same-color block38 block45)
(same-color block45 block38)
(same-color block30 block52)
(same-color block52 block30)
(same-color block37 block44)
(same-color block44 block37)
(same-color block22 block50)
(same-color block50 block22)
(same-color block29 block43)
(same-color block43 block29)
(same-color block36 block51)
(same-color block51 block36)
(= (num-steps) 0)
)
(:goal (and
(is-empty block46)
(is-empty block53)
(is-empty block38)
(is-empty block45)
(is-empty block30)
(is-empty block52)
(is-empty block37)
(is-empty block44)
(is-empty block22)
(is-empty block50)
(is-empty block29)
(is-empty block43)
(is-empty block36)
(is-empty block51)
)
)
(:metric minimize (num-steps))
)
(define
(domain puzznic)
(:requirements :strips :typing :negative-preconditions :conditional-effects :numeric-fluents)
(:types
block - object
matching-block - block
)
(:functions
(num-steps)
)
(:predicates
(is-empty ?b - block)
(is-immovable ?b - block)
(is-falling ?b - matching-block)
(is-on-falling-cooldown ?b - matching-block)
(is-marked ?b - matching-block)
(is-matching ?b - matching-block)
(has-match-caused-falling)
(left ?b1 - block ?b2 - block)
(right ?b1 - block ?b2 - block)
(up ?b1 - block ?b2 - block)
(down ?b1 - block ?b2 - block)
(same-color ?b1 - matching-block ?b2 - matching-block)
(blocks-are-falling)
(blocks-are-matching)
(blocks-are-priority-matching)
(at-the-end-of-falling-cycle)
)
(:action SWAP-BLOCK-LEFT
:parameters (?b1 - matching-block ?b2 ?b1up ?b1down ?b1right ?b2up ?b2down ?b2left - block)
:precondition (and
(not (blocks-are-matching))
(not (blocks-are-falling))
(and (not (is-empty ?b1)) (is-empty ?b2))
(not (or (is-immovable ?b1) (is-immovable ?b2)))
(not (is-falling ?b1))
(left ?b1 ?b2)
(and (right ?b1 ?b1right)
(up ?b1 ?b1up)
(down ?b1 ?b1down)
)
(and (left ?b2 ?b2left)
(up ?b2 ?b2up)
(down ?b2 ?b2down)
)
)
:effect (and
(increase (num-steps) 1)
(left ?b2 ?b1)
(right ?b1 ?b2)
(left ?b1 ?b2left)
(right ?b2left ?b1)
(down ?b1 ?b2down)
(up ?b2down ?b1)
(up ?b1 ?b2up)
(down ?b2up ?b1)
(right ?b2 ?b1right)
(left ?b1right ?b2)
(down ?b2 ?b1down)
(up ?b1down ?b2)
(up ?b2 ?b1up)
(down ?b1up ?b2)
(not (right ?b2 ?b1))
(not (left ?b1right ?b1))
(not (down ?b1up ?b1))
(not (up ?b1down ?b1))
(not (right ?b2left ?b2))
(not (down ?b2up ?b2))
(not (up ?b2down ?b2))
(not (left ?b1 ?b2))
(not (right ?b1 ?b1right))
(not (up ?b1 ?b1up))
(not (down ?b1 ?b1down))
(not (left ?b2 ?b2left))
(not (up ?b2 ?b2up))
(not (down ?b2 ?b2down))
(when
(and
(not (is-empty ?b2down))
(or
(and
(not (is-empty ?b2up))
(same-color ?b1 ?b2up)
)
(and
(not (is-empty ?b2down))
(same-color ?b1 ?b2down)
)
(and
(not (is-empty ?b2left))
(same-color ?b1 ?b2left)
)
)
)
(and
(blocks-are-matching)
(blocks-are-priority-matching)
(is-matching ?b1)
(is-marked ?b1)
)
)
(when
(is-empty ?b2down)
(and
(is-falling ?b1)
(not (is-on-falling-cooldown ?b1))
(blocks-are-falling)
)
)
(when
(not (is-empty ?b1up))
(and
(is-falling ?b1up)
(not (is-on-falling-cooldown ?b1up))
(blocks-are-falling)
)
)
)
)
(:action TIMED-SWAP-BLOCK-LEFT
:parameters (?b1 - matching-block ?b2 ?b1up ?b1down ?b1right ?b2up ?b2down ?b2left - block)
:precondition (and
(not (blocks-are-matching))
(at-the-end-of-falling-cycle)
(and (not (is-empty ?b1)) (is-empty ?b2))
(not (or (is-immovable ?b1) (is-immovable ?b2)))
(not (is-falling ?b1))
(left ?b1 ?b2)
(and (right ?b1 ?b1right)
(up ?b1 ?b1up)
(down ?b1 ?b1down)
)
(and (left ?b2 ?b2left)
(up ?b2 ?b2up)
(down ?b2 ?b2down)
)
)
:effect (and
(increase (num-steps) 1)
(left ?b2 ?b1)
(right ?b1 ?b2)
(left ?b1 ?b2left)
(right ?b2left ?b1)
(down ?b1 ?b2down)
(up ?b2down ?b1)
(up ?b1 ?b2up)
(down ?b2up ?b1)
(right ?b2 ?b1right)
(left ?b1right ?b2)
(down ?b2 ?b1down)
(up ?b1down ?b2)
(up ?b2 ?b1up)
(down ?b1up ?b2)
(not (right ?b2 ?b1))
(not (left ?b1right ?b1))
(not (down ?b1up ?b1))
(not (up ?b1down ?b1))
(not (right ?b2left ?b2))
(not (down ?b2up ?b2))
(not (up ?b2down ?b2))
(not (left ?b1 ?b2))
(not (right ?b1 ?b1right))
(not (up ?b1 ?b1up))
(not (down ?b1 ?b1down))
(not (left ?b2 ?b2left))
(not (up ?b2 ?b2up))
(not (down ?b2 ?b2down))
(not (at-the-end-of-falling-cycle))
(forall (?b - matching-block)
(not (is-on-falling-cooldown ?b))
)
(when
(and
(not (is-empty ?b2down))
(or
(and
(not (is-empty ?b2up))
(same-color ?b1 ?b2up)
)
(and
(not (is-empty ?b2down))
(same-color ?b1 ?b2down)
)
(and
(not (is-empty ?b2left))
(same-color ?b1 ?b2left)
)
)
)
(and
(blocks-are-matching)
(blocks-are-priority-matching)
(is-matching ?b1)
(is-marked ?b1)
)
)
(when
(is-empty ?b2down)
(and
(is-falling ?b1)
(not (is-on-falling-cooldown ?b1))
(blocks-are-falling)
)
)
(when
(not (is-empty ?b1up))
(and
(is-falling ?b1up)
(not (is-on-falling-cooldown ?b1up))
(blocks-are-falling)
)
)
)
)
(:action SWAP-BLOCK-RIGHT
:parameters (?b1 - matching-block ?b2 ?b1up ?b1down ?b1left ?b2up ?b2down ?b2right - block)
:precondition (and
(not (blocks-are-matching))
(not (blocks-are-falling))
(and (not (is-empty ?b1)) (is-empty ?b2))
(not (or (is-immovable ?b1) (is-immovable ?b2)))
(not (is-falling ?b1))
(right ?b1 ?b2)
(and (left ?b1 ?b1left)
(up ?b1 ?b1up)
(down ?b1 ?b1down)
)
(and (right ?b2 ?b2right)
(up ?b2 ?b2up)
(down ?b2 ?b2down)
)
)
:effect (and
(increase (num-steps) 1)
(right ?b2 ?b1)
(left ?b1 ?b2)
(right ?b1 ?b2right)
(left ?b2right ?b1)
(down ?b1 ?b2down)
(up ?b2down ?b1)
(up ?b1 ?b2up)
(down ?b2up ?b1)
(left ?b2 ?b1left)
(right ?b1left ?b2)
(down ?b2 ?b1down)
(up ?b1down ?b2)
(up ?b2 ?b1up)
(down ?b1up ?b2)
(not (right ?b1 ?b2))
(not (left ?b1 ?b1left))
(not (up ?b1 ?b1up))
(not (down ?b1 ?b1down))
(not (right ?b2 ?b2right))
(not (up ?b2 ?b2up))
(not (down ?b2 ?b2down))
(not (left ?b2 ?b1))
(not (right ?b1left ?b1))
(not (down ?b1up ?b1))
(not (up ?b1down ?b1))
(not (left ?b2right ?b2))
(not (down ?b2up ?b2))
(not (up ?b2down ?b2))
(when
(and
(not (is-empty ?b2down))
(or
(and
(not (is-empty ?b2up))
(same-color ?b1 ?b2up)
)
(and
(not (is-empty ?b2down))
(same-color ?b1 ?b2down)
)
(and
(not (is-empty ?b2right))
(same-color ?b1 ?b2right)
)
)
)
(and
(blocks-are-matching)
(blocks-are-priority-matching)
(is-matching ?b1)
(is-marked ?b1)
)
)
(when
(is-empty ?b2down)
(and
(is-falling ?b1)
(not (is-on-falling-cooldown ?b1))
(blocks-are-falling)
)
)
(when
(not (is-empty ?b1up))
(and
(is-falling ?b1up)
(not (is-on-falling-cooldown ?b1up))
(blocks-are-falling)
)
)
)
)
(:action TIMED-SWAP-BLOCK-RIGHT
:parameters (?b1 - matching-block ?b2 ?b1up ?b1down ?b1left ?b2up ?b2down ?b2right - block)
:precondition (and
(not (blocks-are-matching))
(at-the-end-of-falling-cycle)
(and (not (is-empty ?b1)) (is-empty ?b2))
(not (or (is-immovable ?b1) (is-immovable ?b2)))
(not (is-falling ?b1))
(right ?b1 ?b2)
(and (left ?b1 ?b1left)
(up ?b1 ?b1up)
(down ?b1 ?b1down)
)
(and (right ?b2 ?b2right)
(up ?b2 ?b2up)
(down ?b2 ?b2down)
)
)
:effect (and
(increase (num-steps) 1)
(right ?b2 ?b1)
(left ?b1 ?b2)
(right ?b1 ?b2right)
(left ?b2right ?b1)
(down ?b1 ?b2down)
(up ?b2down ?b1)
(up ?b1 ?b2up)
(down ?b2up ?b1)
(left ?b2 ?b1left)
(right ?b1left ?b2)
(down ?b2 ?b1down)
(up ?b1down ?b2)
(up ?b2 ?b1up)
(down ?b1up ?b2)
(not (right ?b1 ?b2))
(not (left ?b1 ?b1left))
(not (up ?b1 ?b1up))
(not (down ?b1 ?b1down))
(not (right ?b2 ?b2right))
(not (up ?b2 ?b2up))
(not (down ?b2 ?b2down))
(not (left ?b2 ?b1))
(not (right ?b1left ?b1))
(not (down ?b1up ?b1))
(not (up ?b1down ?b1))
(not (left ?b2right ?b2))
(not (down ?b2up ?b2))
(not (up ?b2down ?b2))
(not (at-the-end-of-falling-cycle))
(forall (?b - matching-block)
(not (is-on-falling-cooldown ?b))
)
(when
(and
(not (is-empty ?b2down))
(or
(and
(not (is-empty ?b2up))
(same-color ?b1 ?b2up)
)
(and
(not (is-empty ?b2down))
(same-color ?b1 ?b2down)
)
(and
(not (is-empty ?b2right))
(same-color ?b1 ?b2right)
)
)
)
(and
(blocks-are-matching)
(blocks-are-priority-matching)
(is-matching ?b1)
(is-marked ?b1)
)
)
(when
(is-empty ?b2down)
(and
(is-falling ?b1)
(not (is-on-falling-cooldown ?b1))
(blocks-are-falling)
)
)
(when
(not (is-empty ?b1up))
(and
(is-falling ?b1up)
(not (is-on-falling-cooldown ?b1up))
(blocks-are-falling)
)
)
)
)
(:action FALL-BLOCK
:parameters (?b1 - matching-block ?b2 ?b1left ?b1right ?b1up ?b2left ?b2right ?b2down - block)
:precondition (and
(not (at-the-end-of-falling-cycle))
(blocks-are-falling)
(not (blocks-are-priority-matching))
(not (is-on-falling-cooldown ?b1))
(is-falling ?b1)
(not (is-falling ?b2))
(not (or (is-immovable ?b1) (is-immovable ?b2)))
(and (not (is-empty ?b1)) (is-empty ?b2))
(down ?b1 ?b2)
(left ?b1 ?b1left)
(right ?b1 ?b1right)
(up ?b1 ?b1up)
(left ?b2 ?b2left)
(right ?b2 ?b2right)
(down ?b2 ?b2down)
)
:effect (and
(up ?b1 ?b2)
(down ?b2 ?b1)
(left ?b1 ?b2left)
(right ?b2left ?b1)
(right ?b1 ?b2right)
(left ?b2right ?b1)
(down ?b1 ?b2down)
(up ?b2down ?b1)
(left ?b2 ?b1left)
(right ?b1left ?b2)
(right ?b2 ?b1right)
(left ?b1right ?b2)
(up ?b2 ?b1up)
(down ?b1up ?b2)
(not (left ?b1 ?b1left))
(not (right ?b1 ?b1right))
(not (up ?b1 ?b1up))
(not (down ?b1 ?b2))
(not (left ?b2 ?b2left))
(not (right ?b2 ?b2right))
(not (down ?b2 ?b2down))
(not (right ?b1left ?b1))
(not (left ?b1right ?b1))
(not (down ?b1up ?b1))
(not (up ?b2 ?b1))
(not (right ?b2left ?b2))
(not (left ?b2right ?b2))
(not (up ?b2down ?b2))
(is-on-falling-cooldown ?b1)
(when
(and
(not (is-empty ?b2down))
(not (is-falling ?b2down))
)
(and
(not (is-falling ?b1))
(when
(or
(and
(not (is-empty ?b2left))
(same-color ?b1 ?b2left)
)
(and
(not (is-empty ?b2right))
(same-color ?b1 ?b2right)
)
(and
(not (is-empty ?b2down))
(same-color ?b1 ?b2down)
)
)
(and
(is-matching ?b1)
(is-marked ?b1)
(blocks-are-matching)
)
)
)
)
(when
(not (is-empty ?b1up))
(and
(is-falling ?b1up)
(not (is-on-falling-cooldown ?b1up))
(blocks-are-falling)
)
)
)
)
(:action END_FALLING
:precondition (and
(blocks-are-falling)
(forall (?b - matching-block)
(not (is-falling ?b))
)
)
:effect (and
(not (blocks-are-falling))
(not (at-the-end-of-falling-cycle))
)
)
(:action ACTIVATE-AT-END-OF-FALLING-CYCLE
:precondition (and
(blocks-are-falling)
(not (at-the-end-of-falling-cycle))
(forall (?b - matching-block)
(or
(not (is-falling ?b))
(is-on-falling-cooldown ?b)
)
)
)
:effect (at-the-end-of-falling-cycle)
)
(:action DEACTIVATE-AT-END-OF-FALLING-CYCLE
:precondition (and
(at-the-end-of-falling-cycle)
(not (blocks-are-matching))
)
:effect (and
(not (at-the-end-of-falling-cycle))
(forall (?b - matching-block)
(not (is-on-falling-cooldown ?b))
)
)
)
(:action SPREAD-MATCH-LEFT
:parameters (?b1 ?b2 - matching-block ?b2up - block)
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(not (is-empty ?b1))
(not (is-empty ?b2))
(not (is-matching ?b2))
(same-color ?b1 ?b2)
(left ?b1 ?b2)
(up ?b2 ?b2up)
)
:effect (and
(is-matching ?b2)
(is-marked ?b2)
(when
(and
(not (is-empty ?b2up))
(not (is-matching ?b2up))
(not (same-color ?b2 ?b2up))
)
(and
(is-falling ?b2up)
(not (is-on-falling-cooldown ?b2up))
(has-match-caused-falling)
)
)
)
)
(:action SPREAD-MATCH-RIGHT
:parameters (?b1 ?b2 - matching-block ?b2up - block)
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(not (is-empty ?b1))
(not (is-empty ?b2))
(not (is-matching ?b2))
(same-color ?b1 ?b2)
(right ?b1 ?b2)
(up ?b2 ?b2up)
)
:effect (and
(is-matching ?b2)
(is-marked ?b2)
(when
(and
(not (is-empty ?b2up))
(not (is-matching ?b2up))
(not (same-color ?b2 ?b2up))
)
(and
(is-falling ?b2up)
(not (is-on-falling-cooldown ?b2up))
(has-match-caused-falling)
)
)
)
)
(:action SPREAD-MATCH-UP
:parameters (?b1 ?b2 - matching-block ?b2up - block)
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(not (is-empty ?b1))
(not (is-empty ?b2))
(not (is-matching ?b2))
(same-color ?b1 ?b2)
(up ?b1 ?b2)
(up ?b2 ?b2up)
)
:effect (and
(is-matching ?b2)
(is-marked ?b2)
(when
(and
(not (is-empty ?b2up))
(not (is-matching ?b2up))
(not (same-color ?b2 ?b2up))
)
(and
(is-falling ?b2up)
(not (is-on-falling-cooldown ?b2up))
(has-match-caused-falling)
)
)
)
)
(:action SPREAD-MATCH-DOWN
:parameters (?b1 ?b2 - matching-block)
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(not (is-empty ?b1))
(not (is-empty ?b2))
(not (is-matching ?b2))
(same-color ?b1 ?b2)
(down ?b1 ?b2)
)
:effect (and
(is-matching ?b2)
(is-marked ?b2)
)
)
(:action REMOVE-MARK
:parameters (?b1 - matching-block ?b1left ?b1up ?b1right ?b1down - block)
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(is-marked ?b1)
(left ?b1 ?b1left)
(up ?b1 ?b1up)
(right ?b1 ?b1right)
(down ?b1 ?b1down)
(or
(is-empty ?b1left)
(is-matching ?b1left)
(not (same-color ?b1 ?b1left))
)
(or
(is-empty ?b1up)
(is-matching ?b1up)
(not (same-color ?b1 ?b1up))
)
(or
(is-empty ?b1right)
(is-matching ?b1right)
(not (same-color ?b1 ?b1right))
)
(or
(is-empty ?b1down)
(is-matching ?b1down)
(not (same-color ?b1 ?b1down))
)
)
:effect (not (is-marked ?b1))
)
(:action MATCH-BLOCKS
:precondition (and
(blocks-are-matching)
(or
(blocks-are-priority-matching)
(not (blocks-are-falling))
(at-the-end-of-falling-cycle)
)
(forall (?b - matching-block)
(not (is-marked ?b))
)
)
:effect (and
(not (blocks-are-matching))
(not (blocks-are-priority-matching))
(forall (?b - matching-block)
(when
(is-matching ?b)
(and
(is-empty ?b)
(not (is-matching ?b))
)
)
)
(when
(has-match-caused-falling)
(blocks-are-falling)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment