Date: Jul 13, 2013 9:03 PM
Author: Graham Cooper
Subject: SIMPLE NAVIGATION IN PROLOG

http://phpprolog.com/demo/NAVIGATION-IN-PROLOG.png



I stole this Nav Program off Apple Maps!



X 5 go FROM TO :-
road FROM TO

X 6 go FROM TO :-
road FROM HERE
go HERE TO

X 7 road a b
X 8 road b c
X 9 road c d




At first the TRACE to go from a - d looks for a direct road and fails


TRACE
go a d ?


HEAD 1
go FROM TO
TAIL 1
road FROM TO
road [ a ] [ d ]
FALSE 1
FAIL

HEAD 2
go FROM TO
TAIL 1
road FROM HERE
road [ a ] HERE
HEAD 1
road a b
MATCH
TRUE 1
TAIL 2
go HERE TO
go [ b ] [ d ]


Then it tries the 2nd option of rule
go FROM TO :-

and finds a road from a - b instead, then tries that!



Check the full color trace here!

http://phpprolog.com/demo/NAVIGATION-IN-PROLOG.png





Herc
--
www.phpPROLOG.com