1 ;;;;***************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: edge-table-storage.cl
6 ;;;; Purpose: Store precompiled edge table for reversi
7 ;;;; Programer: Kevin M. Rosenberg, M.D.
8 ;;;; Date Started: 1 Nov 2001
9 ;;;; CVS Id: $Id: edge-table-storage.lisp,v 1.1 2002/10/25 08:36:42 kevin Exp $
11 ;;;;***************************************************************************
15 (defparameter *et-path* nil)
17 (eval-when (:compile-toplevel :load-toplevel :execute)
19 (defun store-edge-table (et &optional (path *et-path*))
20 (with-open-file (stream path :direction :output
21 :if-exists :supersede)
22 (print (length et) stream)
23 (dotimes (i (length et))
24 (print (aref et i) stream))))
26 (defun load-edge-table (&optional (path *et-path*))
27 (when (probe-file path)
28 (with-open-file (stream path :direction :input)
29 (let* ((length (read stream))
30 (et (make-array length :element-type 'fixnum)))
32 (setf (aref et i) (read stream)))
35 (setq *et-path* (make-pathname :defaults *load-truename* :name nil :type nil))
37 (unless (probe-file *et-path*)
38 (store-edge-table (make-edge-table)))
41 (setq *edge-table* (load-edge-table))))