On these online notes files on the web page, I placed lots of challenging (buggy and sometime elegant, sometimes ugly) code. In particular, some of you will have major grunt problems with the 15 puzzle operators. Here's a snippet of a nice clean hunk of LISP code that implements the NORTH operator. SOUTH, EAST, and WEST and similarly defined by simply changing the conditional test on the coordinates, and changing the "from row","from column", "to row", "to column" arguments appropirately. I hope this helps some of you....many have already completed the task... so enjoy anyway! ;node is (state operator parent) ;state for 15 puzzle is ( ( row1 ) ( row2 ) ( row3 ) ( row4 ) (r c)) ;where (r c) are the coordinates of the blank ;Notice this is a differenet representation from the early 8 puzzle ;examples. ;Please note that the coordinates are at origin ZERO, meaning ;a row r=0 means the first row, r=1 means the second row, and so on. ;So, given a state like ; ( (1 2 3 4) (5 0 6 7) (8 9 10 11) (12 13 14 15) (1 1)) ;the coorindates (1 1) means that the blank (here represented as the ;number zero) are in the Second row and Second column ;Operator NORTH ;This actually runs correctly! No joke... (defun North (state) (let ((newstate nil)) (cond ( (<= (first (fifth state)) 0) nil) ;blank can't move north (t ;otherwise it can (setf newstate ;newstate not entirely ;necessary, but who knows... (swap (copy-tree state) (first (fifth state)) ;from row (second (fifth state)) ;from column (decf (first (fifth state))) ;to row (second (fifth state))) ;to column ))))) (defun swap (state from-row from-col to-row to-col) (let ( (temp nil) ) (setf temp (nth from-col (nth from-row state))) ;just a simple swap (setf (nth from-col (nth from-row state)) (nth to-col (nth to-row state))) (setf (nth to-col (nth to-row state)) temp) (setf (fifth state) (list to-row to-col)) ;and update of where ;the blanks now resides state) ;close the let and the value of state is return as the ;last expression evaluated in the let environment ) ;close the defun return whatever let returns, i.e. a new state