Function: gomoku-init-score-table

gomoku-init-score-table is a byte-compiled function defined in gomoku.el.gz.

Signature

(gomoku-init-score-table)

Documentation

Create the score table vector and fill it with initial values.

Source Code

;; Defined in /usr/src/emacs/lisp/play/gomoku.el.gz
(defun gomoku-init-score-table ()
  "Create the score table vector and fill it with initial values."
  (if (and gomoku-saved-score-table	; Has it been stored last time ?
	   (= gomoku-board-width  gomoku-saved-board-width)
	   (= gomoku-board-height gomoku-saved-board-height))
      (setq gomoku-score-table (copy-sequence gomoku-saved-score-table))
      ;; No, compute it:
      (setq gomoku-score-table
	    (make-vector gomoku-vector-length (* 20 gomoku-nil-score)))
      (let (i j maxi maxj maxi2 maxj2)
	(setq maxi  (/ (1+ gomoku-board-width) 2)
	      maxj  (/ (1+ gomoku-board-height) 2)
	      maxi2 (min 4 maxi)
	      maxj2 (min 4 maxj))
	;; We took symmetry into account and could use it more if the board
	;; would have been square and not rectangular !
	;; In our case we deal with all (i,j) in the set [1..maxi2]*[1..maxj] U
	;; [maxi2+1..maxi]*[1..maxj2]. Maxi2 and maxj2 are used because the
	;; board may well be less than 8 by 8 !
	(setq i 1)
	(while (<= i maxi2)
	  (setq j 1)
	  (while (<= j maxj)
	    (gomoku-init-square-score i j)
	    (setq j (1+ j)))
	  (setq i (1+ i)))
	(while (<= i maxi)
	  (setq j 1)
	  (while (<= j maxj2)
	    (gomoku-init-square-score i j)
	    (setq j (1+ j)))
	  (setq i (1+ i))))
      (setq gomoku-saved-score-table  (copy-sequence gomoku-score-table)
	    gomoku-saved-board-width  gomoku-board-width
	    gomoku-saved-board-height gomoku-board-height)))