;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Russell & Norvig's Wumpus World in GDL ;; ;; Author: Michael Thielscher ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Fluents ;;;;;;;;;; ;; at(?x,?m,?n) ?x :: agent | wumpus | pit | gold ;; ?m,?n :: 1 | 2 | 3 | 4 | ... ;; orientation(?o) ?o :: north | south | east | west ;; has(?x) ?o :: arrow | gold ;; dead(?x) ?x :: agent | wumpus ;; exited ;; ;; Actions ;;;;;;;;;; ;; go; turn_left; turn_right; grab; shoot; exit ;; ;; Percepts ;;;;;;;;;;; ;; bump; breeze; stench; glitter ;; ;; roles and initial state (role agent) (init (at agent 1 1)) (init (orientation north)) (init (has arrow)) (init (at wumpus 3 2)) (init (at pit 1 3)) (init (at pit 2 4)) (init (at pit 4 1)) (init (at pit 4 5)) (init (at gold 5 5)) ;; action preconditions (<= (legal agent go)) (<= (legal agent turn_left)) (<= (legal agent turn_right)) (<= (legal agent shoot) (true (has arrow))) (<= (legal agent grab) (true (at agent ?m ?n)) (true (at gold ?m ?n))) (<= (legal agent exit) (true (at agent 1 1))) ;; action effects (<= (next (at agent ?m ?n)) (next_position ?m ?n)) (<= (next (orientation ?o)) (does agent turn_left) (true (orientation ?p)) (clockwise ?o ?p)) (<= (next (orientation ?o)) (does agent turn_right) (true (orientation ?p)) (clockwise ?p ?o)) (<= (next (orientation ?o)) (true (orientation ?o)) (not (does agent turn_left)) (not (does agent turn_right))) (<= (next (has gold)) (does agent grab)) (<= (next (has gold)) (true (has gold))) (<= (next (at gold ?m ?n)) (true (at gold ?m ?n)) (not (does agent grab))) (<= (next (has arrow)) (true (has arrow)) (not (does agent shoot))) (<= (next (dead wumpus)) (does agent shoot) (true (at agent ?i ?j)) (true (at wumpus ?m ?n)) (true (orientation ?o)) (trajectory ?i ?j ?o ?m ?n)) (<= (next (dead wumpus)) (true (dead wumpus))) (<= (next (dead agent)) (next_position ?m ?n) (true (at pit ?m ?n))) (<= (next (dead agent)) (next_position ?m ?n) (true (at wumpus ?m ?n)) (not (true (dead wumpus)))) (<= (next exited) (does agent exit)) (<= (next (at wumpus ?m ?n)) (true (at wumpus ?m ?n))) (<= (next (at pit ?m ?n)) (true (at pit ?m ?n))) ;; percepts (<= (sees agent stench) (next_position ?m ?n) (next_to wumpus ?m ?n)) (<= (sees agent breeze) (next_position ?m ?n) (next_to pit ?m ?n)) (<= (sees agent glitter) (next_position ?m ?n) (true (at gold ?m ?n)) (not (does agent grab))) (<= (sees agent bump) (does agent go) facing_wall) ;; termination & goal (<= terminal (true exited)) (<= terminal (true (dead agent))) (<= (goal agent 100) (true (has gold)) (not (true (dead agent)))) (<= (goal agent 0) (true (dead agent))) ;; auxiliary (<= (next_position ?m ?n) (does agent go) (true (at agent ?i ?j)) (true (orientation ?o)) (adjacent ?i ?j ?o ?m ?n)) (<= (next_position ?m ?n) (does agent go) facing_wall (true (at agent ?m ?n))) (<= (next_position ?m ?n) (not (does agent go)) (true (at agent ?m ?n))) (<= (next_to ?x ?m ?n) (true (at ?x ?i ?j)) (adjacent ?m ?n ?o ?i ?j)) (<= (trajectory ?m ?n ?o ?m ?n) (coordinate ?m) (coordinate ?n) (direction ?o)) (<= (trajectory ?i ?j ?o ?m ?n) (adjacent ?i ?j ?o ?k ?l) (trajectory ?k ?l ?o ?m ?n)) (<= (adjacent ?m ?i north ?m ?j) (succ ?i ?j) (coordinate ?m)) (<= (adjacent ?m ?i south ?m ?j) (succ ?j ?i) (coordinate ?m)) (<= (adjacent ?i ?n east ?j ?n) (succ ?i ?j) (coordinate ?n)) (<= (adjacent ?i ?n west ?j ?n) (succ ?j ?i) (coordinate ?n)) (<= facing_wall (true (at agent ?m ?n)) (max ?n) (true (orientation north))) (<= facing_wall (true (at agent ?m 1)) (true (orientation south))) (<= facing_wall (true (at agent ?m ?n)) (max ?m) (true (orientation east))) (<= facing_wall (true (at agent 1 ?n)) (true (orientation west))) (direction north) (direction south) (direction east) (direction west) (clockwise north east) (clockwise east south) (clockwise south west) (clockwise west north) (coordinate 1) (coordinate 2) (coordinate 3) (coordinate 4) (coordinate 5) (succ 1 2) (succ 2 3) (succ 3 4) (succ 4 5) (max 5)