1 ;;;;***************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: edge-table-storage.lisp
6 ;;;; Purpose: Store precompiled edge table for reversi
7 ;;;; Programer: Kevin Rosenberg
8 ;;;; Date Started: 1 Nov 2001
10 ;;;; $Id: edge-table-storage.lisp,v 1.2 2002/10/25 09:23:39 kevin Exp $
12 ;;;; This file is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; Reversi users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;;***************************************************************************
21 (eval-when (:compile-toplevel :load-toplevel :execute)
23 (defparameter *et-path* nil)
26 (setq *et-path* (make-pathname
27 :directory (pathname-directory *load-truename*)
28 :host (pathname-host *load-truename*)
29 :device (pathname-device *load-truename*)
32 (setq *et-path* (make-pathname
33 :directory '(:absolute "usr" "share" "common-lisp"
34 "source" "reversi" "data")
38 (defun store-edge-table (et &optional (path *et-path*))
39 (with-open-file (stream path :direction :output
40 :if-exists :supersede)
41 (print (length et) stream)
42 (dotimes (i (length et))
43 (print (aref et i) stream))))
45 (defun load-edge-table (&optional (path *et-path*))
46 (when (probe-file path)
47 (with-open-file (stream path :direction :input)
48 (let* ((length (read stream))
49 (et (make-array length :element-type 'fixnum)))
51 (setf (aref et i) (read stream)))
54 (unless (probe-file *et-path*)
55 (store-edge-table (make-edge-table)))
58 (setq *edge-table* (load-edge-table))))