/** Metaphysics > Walking Simulator robotwalker.pl From quote: speed, spacing of steps, how high the feet and knees are lifted up. robotwalker(3,3, [[1,3,d,b],[2,3,d,b],[3,3,d,b], [1,2,d,b],[2,2,d,b],[3,2,d,b] [1,1,d,b],[2,1,d,b],[3,1,d,b]], %% call robot X,Y,InitialState,FinalState state 0 state m y 3 a a y y1 : x for x=1 to 3 let d=y-x let m=mod(d/2) if m=m1 then f2 x y next x next y reset all to back ], m 1 f2 x y u f d to x y a b list1, ? list3 list1=[x, y, a, C] append(list2,[[x,y,b,C]],list3) to x y a b list1, ? list3 list1=[x, y, C, a] append(list2,[[x,y,C,b]],list3) to x y a b list1, list2, list3 reset all to back for x=1 to 3 to x y f b next x next y %%** %% X and Y are the number of legs across and along the robot, InitialState includes status (up or down, and forward or backward) of each leg, Program indicates the legs' statuses with time and Frames includes the frame number, position on path and status of each leg robotwalker(X,Y,InitialState,Program,Frames) :- compile1(Query,Functions,Result) :- compile2(Query,Functions,[],Result). compile2(Query,Functions,Variables,Result) :- Query=[Query1|Queries] **/ evaluate(matches(A,B)) :- A=B. evaluate(A,A) :- number(A). evaluate(A,A) :- atom(A). evaluate(equals(A,B),A=D) :- evaluate(B,D). evaluate(A+B,C) :- evaluate(A,D), evaluate(B,E), C is D+E. evaluate(A-B,C) :- evaluate(A,D), evaluate(B,E), C is D-E. evaluate(mod(A,B),C) :- C is mod(A,B). evaluate(Function,Query,Functions,Variables,Result) :- Function = Head :- Body. tokenise(File,Functions) :- open(File,read,Str), readfn([],Functions). readfn(Functions1,Functions2) :- readfnhead(Head), get(':-'), readfnbody(Body). readfnhead(Head) :- readfnname(Name), get('('), readfnargs(Arguments), get(')'), readfnname(Name) :- getword(Name). readfnargs(Arguments) :- readfnbody(Body) :- getword(. get(Char),