Created
February 4, 2014 02:55
-
-
Save MonkeyIsNull/8797442 to your computer and use it in GitHub Desktop.
This file contains 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
% Monkey problem in Prolog -- Taken from PPAI | |
% Before reading this code: http://www.youtube.com/watch?v=WnlIWpZSPXU | |
% | |
% First up is the move to the final spot we want | |
move(state(middle, onbox, middle, hasnot), %Before | |
grasp, %Action | |
state(middle, onbox, middle, has)). %After -- monkey wins motherfucker! | |
% Action climb | |
move(state(P, onfloor, P, H), | |
climb, | |
state(P, onbox, P, H)). | |
% Action push | |
move(state(P1, onfloor, P1, H), | |
push(P1, P2), | |
state(P2, onfloor, P2, H)). | |
move(state(P1, onfloor, B, H), | |
walk(P1, P2), | |
state(P2, onfloor, B, H)). | |
canget(state(_,_,_, has)). % zee Minkey haz it! | |
canget(State1) :- | |
move(State1, Move, State2), | |
canget(State2). | |
% run with | |
% canget(state(atdoor,onfloor,atwindow,hasnot)). | |
% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment