Function: gomoku-update-score-in-direction
gomoku-update-score-in-direction is a byte-compiled function defined
in gomoku.el.gz.
Signature
(gomoku-update-score-in-direction LEFT RIGHT SQUARE DX DY DVAL)
Documentation
Update scores for all squares in the qtuples starting between the LEFTth square and the RIGHTth after SQUARE, along the DX, DY direction, considering that DVAL has been added on SQUARE.
Source Code
;; Defined in /usr/src/emacs/lisp/play/gomoku.el.gz
(defun gomoku-update-score-in-direction (left right square dx dy dval)
"Update scores for all squares in the qtuples starting between the LEFTth
square and the RIGHTth after SQUARE, along the DX, DY direction, considering
that DVAL has been added on SQUARE."
;; We always have LEFT <= 0, RIGHT <= 0 and DEPL > 0 but we may very well
;; have LEFT > RIGHT, indicating that no qtuple contains SQUARE along that
;; DX,DY direction.
(cond
((> left right)) ; Quit
(t ; Else ..
(let (depl square0 square1 square2 count delta)
(setq depl (gomoku-xy-to-index dx dy)
square0 (+ square (* left depl))
square1 (+ square (* right depl))
square2 (+ square0 (* 4 depl)))
;; Compute the contents of the first qtuple:
(setq square square0
count 0)
(while (<= square square2)
(setq count (+ count (aref gomoku-board square))
square (+ square depl)))
(while (<= square0 square1)
;; Update the squares of the qtuple beginning in SQUARE0 and ending
;; in SQUARE2.
(setq delta (- (aref gomoku-score-trans-table count)
(aref gomoku-score-trans-table (- count dval))))
(cond ((not (zerop delta)) ; or else nothing to update
(setq square square0)
(while (<= square square2)
(if (zerop (aref gomoku-board square)) ; only for free squares
(aset gomoku-score-table square
(+ (aref gomoku-score-table square) delta)))
(setq square (+ square depl)))))
;; Then shift the qtuple one square along DEPL, this only requires
;; modifying SQUARE0 and SQUARE2.
(setq square2 (+ square2 depl)
count (+ count (- (aref gomoku-board square0))
(aref gomoku-board square2))
square0 (+ square0 depl)))))))