norvig / paip-lisp

Lisp code for the textbook "Paradigms of Artificial Intelligence Programming"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(debug :search) wrong display of results

wpasieka opened this issue · comments

Dear Mr Norvig,

When running some examples with the debug feature, it seems to be a bug in the code, or I am doing something wrong.

The last result of the first "search" which is (12 13 7) is displayed only when executing another command, like shown below.

I am using CMUCL, but I dont think this is related to the Cl distribution.

Could You please have a look and to advice the solution.

CL-USER>
950(depth-first-search 1 (is 12) (finite-binary-tree 15))
951
952;; Search: (13 7)
953;; Search: (1)
954;; Search: (2 3)
955;; Search: (4 5 3)
956;; Search: (8 9 5 3)
957;; Search: (9 5 3)
958;; Search: (5 3)
959;; Search: (10 11 3)
960;; Search: (11 3)
961;; Search: (3)
962;; Search: (6 7)
963
964 12
965CL-USER> (show-city-path (trip (city 'san-francisco) (city 'boston) 1))
966
967;; Search: (12 13 7)
968;; Search: (#<Path to (SAN-FRANCISCO 122.26 37.47) cost 0.0>)
969;; Search: (#<Path to (RENO 119.49 39.3) cost 4355.0>)
970;; Search: (#<Path to (GRAND-JCT 108.37 39.05) cost 4427.3>)
971;; Search: (#<Path to (DENVER 105.0 39.45) cost 4428.3>)
972;; Search: (#<Path to (KANSAS-CITY 94.35 39.06) cost 4492.0>)
973;; Search: (#<Path to (INDIANAPOLIS 86.1 39.46) cost 4507.1>)
974;; Search: (#<Path to (PITTSBURGH 79.57 40.27) cost 4514.8>)
975#<Path 4514.8 km: San-Francisco - Reno - Grand-Jct - Denver - Kansas-City - Indianapolis - Pittsburgh - Boston>
976CL-USER>

(depth-first-search 1 (is 12) (finite-binary-tree 15))
977
978;; Search: (#<Path to (BOSTON 71.05 42.21) cost 4514.8>)
979;; Search: (1)
980;; Search: (2 3)
981;; Search: (4 5 3)
982;; Search: (8 9 5 3)
983;; Search: (9 5 3)
984;; Search: (5 3)
985;; Search: (10 11 3)
986;; Search: (11 3)
987;; Search: (3)
988;; Search: (6 7)
989
99012

Kind Regards,
Adrian W. Pasieka