X-Git-Url: http://git.kpe.io/?p=reversi.git;a=blobdiff_plain;f=edge-table-storage.lisp;h=f8d3b1036ca665e30fb27ef32dd7b8fec9450075;hp=7e8e88da9cb3d4e71449591e26eab7b46c4c1ce6;hb=a8b65e823b3a59faba717887aee3a8a4a8cf0a28;hpb=062d6c95c94ac969bd49083dea184c9bb81d6fea diff --git a/edge-table-storage.lisp b/edge-table-storage.lisp index 7e8e88d..f8d3b10 100644 --- a/edge-table-storage.lisp +++ b/edge-table-storage.lisp @@ -1,7 +1,7 @@ ;;;;*************************************************************************** ;;;; ;;;; FILE IDENTIFICATION -;;;; +;;;; ;;;; Name: edge-table-storage.lisp ;;;; Purpose: Store precompiled edge table for reversi ;;;; Programer: Kevin Rosenberg @@ -22,43 +22,43 @@ (eval-when (:load-toplevel :execute) (let ((precompiled-path (make-pathname - :directory '(:absolute "usr" "share" "common-lisp" - "source" "reversi") - :name "edge-table" - :type "dat"))) + :directory '(:absolute "usr" "share" "common-lisp" + "source" "reversi") + :name "edge-table" + :type "dat"))) (if (probe-file precompiled-path) - (setq *et-path* precompiled-path) + (setq *et-path* precompiled-path) (setq *et-path* (make-pathname - :directory (pathname-directory *load-truename*) - :host (pathname-host *load-truename*) - :device (pathname-device *load-truename*) - :name "edge-table" - :type "dat")))) + :directory (pathname-directory *load-truename*) + :host (pathname-host *load-truename*) + :device (pathname-device *load-truename*) + :name "edge-table" + :type "dat")))) (defun store-edge-table (et &optional (path *et-path*)) (declare (type edge-table et)) (with-open-file (stream path :direction :output - :if-exists :supersede) + :if-exists :supersede) (print (length et) stream) (dotimes (i (length et)) - (declare (fixnum i)) - (print (aref et i) stream)))) - + (declare (fixnum i)) + (print (aref et i) stream)))) + (defun load-edge-table (&optional (path *et-path*)) (when (probe-file path) (with-open-file (stream path :direction :input) - (let* ((length (read stream)) - (et (make-array length :element-type 'fixnum))) - (declare (type (simple-array fixnum (*)) et)) - (dotimes (i length) - (declare (fixnum i)) - (setf (aref et i) (read stream))) - et)))) - + (let* ((length (read stream)) + (et (make-array length :element-type 'fixnum))) + (declare (type (simple-array fixnum (*)) et)) + (dotimes (i length) + (declare (fixnum i)) + (setf (aref et i) (read stream))) + et)))) + (unless (probe-file *et-path*) (format *trace-output* ";; Recompiling edge-table, this make take several minutes") (store-edge-table (make-edge-table))) - + (unless *edge-table* (setq *edge-table* (load-edge-table))))