fun findempo [] (x,y) = false | findempo S (x,y) = if hd S = (x,y) then true else findempo (tl S) (x,y); fun voltes xmax ymax Tmax (xage,yage) (xtel,ytel) L = if ( (Tmax = 0) andalso (xage = xtel) andalso (yage = ytel) ) then 1 else if ( (Tmax <= 0) orelse (Tmax > 15) orelse ( xage <= 0 ) orelse ( yage <= 0 ) orelse ( xage > xmax ) orelse ( yage > ymax ) orelse not ( findempo L (xage,yage) ) ) then 0 else letsgo xmax ymax Tmax (xage,yage) 5; fun pamevoltes xmax ymax Tmax (xage,yage) n = if (n = 4) then voltes xmax ymax (Tmax-1) ((xage-1),yage) (xtel,ytel) L else if (n = 3) then voltes xmax ymax (Tmax-1) ((xage+1),yage) (xtel,ytel) L else if (n = 2) then voltes xmax ymax (Tmax-1) (xage,(yage-1)) (xtel,ytel) L else if (n = 1) then voltes xmax ymax (Tmax-1) (xage,(yage+1)) (xtel,ytel) L letsgo xmax ymax Tmax (xage,yage) acc = if (acc = 0) then 0 else pamevoltes xmax ymax Tmax (xage,yage) (acc - 1)