Skip to content

Instantly share code, notes, and snippets.

@MonkeyIsNull
Created February 4, 2014 02:55
Show Gist options
  • Save MonkeyIsNull/8797442 to your computer and use it in GitHub Desktop.
Save MonkeyIsNull/8797442 to your computer and use it in GitHub Desktop.
% 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