Last active
December 24, 2015 14:59
-
-
Save rm-hull/6816234 to your computer and use it in GitHub Desktop.
Adapted to clojurescript flavor, derived from https://github.com/clojure/core.logic/wiki/Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns classic-ai-example | |
(:require-macros [cljs.core.logic.macros :as m]) | |
(:use [cljs.core.logic :only [-take*]])) | |
(m/defne moveo [before action after] | |
([[:middle :onbox :middle :hasnot] | |
:grasp | |
[:middle :onbox :middle :has]]) | |
([[pos :onfloor pos has] | |
:climb | |
[pos :onbox pos has]]) | |
([[pos1 :onfloor pos1 has] | |
:push | |
[pos2 :onfloor pos2 has]]) | |
([[pos1 :onfloor box has] | |
:walk | |
[pos2 :onfloor box has]])) | |
(m/defne cangeto [state out] | |
([[_ _ _ :has] true]) | |
([_ _] (m/fresh [action next] | |
(moveo state action next) | |
(cangeto next out)))) | |
(println | |
(m/run 1 [q] | |
(cangeto [:atdoor :onfloor :atwindow :hasnot] q))) ; (true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment