gdl/montyhall.gdl @ 49fd0e0e0c80

Add LICENSE
author Steve Losh <steve@stevelosh.com>
date Tue, 14 Mar 2017 13:36:54 +0000
parents 3777bd117949
children (none)
;; GDL-II

(role candidate)
(role random)

(init (closed 1))
(init (closed 2))
(init (closed 3))
(init (step 1))

(<= (legal random (hide_car ?d))
   (true (step 1))
   (true (closed ?d)))
(<= (legal random (open_door ?d))
   (true (step 2))
   (true (closed ?d))
   (not (true (car ?d)))
   (not (true (chosen ?d))))
(<= (legal random noop)
   (true (step 3)))

(<= (legal candidate (choose ?d))
   (true (step 1))
   (true (closed ?d)))
(<= (legal candidate noop)
   (true (step 2)))
(<= (legal candidate switch)
   (true (step 3)))
(<= (legal candidate noop)
   (true (step 3)))

(<= (sees candidate (does candidate ?m))
   (does candidate ?m))
(<= (sees candidate (open_door ?d))
   (does random (open_door ?d)))

(<= (next (car ?d))
   (does random (hide_car ?d)))
(<= (next (car ?d))
   (true (car ?d)))
(<= (next (closed ?d))
   (true (closed ?d))
   (not (does random (open_door ?d))))
(<= (next (chosen ?d))
   (next_chosen ?d))

(<= (next_chosen ?d)
   (does candidate (choose ?d)))
(<= (next_chosen ?d)
   (true (chosen ?d))
   (not (does candidate switch)))
(<= (next_chosen ?d)
   (does candidate switch)
   (true (closed ?d))
   (not (true (chosen ?d))))

(<= (next (step 2))
   (true (step 1)))
(<= (next (step 3))
   (true (step 2)))
(<= (next (step 4))
   (true (step 3)))

(<= (sees candidate (car ?d))
   (true (step 3))
   (true (car ?d))
   (next_chosen ?d))

(<= terminal
   (true (step 4)))

(goal random 100)
(<= (goal candidate 100)
   (true (chosen ?d))
   (true (car ?d)))
(<= (goal candidate 0)
   (true (chosen ?d))
   (not (true (car ?d))))