;;;;*************************************************************************** ;;;; ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: edge-table-storage.cl ;;;; Purpose: Store precompiled edge table for reversi ;;;; Programer: Kevin M. Rosenberg, M.D. ;;;; Date Started: 1 Nov 2001 ;;;; CVS Id: $Id: edge-table-storage.lisp,v 1.1 2002/10/25 08:36:42 kevin Exp $ ;;;; ;;;;*************************************************************************** (in-package :reversi) (defparameter *et-path* nil) (eval-when (:compile-toplevel :load-toplevel :execute) (defun store-edge-table (et &optional (path *et-path*)) (with-open-file (stream path :direction :output :if-exists :supersede) (print (length et) stream) (dotimes (i (length et)) (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))) (dotimes (i length) (setf (aref et i) (read stream))) et)))) (setq *et-path* (make-pathname :defaults *load-truename* :name nil :type nil)) (unless (probe-file *et-path*) (store-edge-table (make-edge-table))) (unless *edge-table* (setq *edge-table* (load-edge-table))))