Function: gametree-compute-reduced-score

gametree-compute-reduced-score is a byte-compiled function defined in gametree.el.gz.

Signature

(gametree-compute-reduced-score)

Documentation

Return current internal node score computed recursively from subnodes.

Subnodes which have been manually scored are honored.

Source Code

;; Defined in /usr/src/emacs/lisp/play/gametree.el.gz
(defun gametree-compute-reduced-score ()
  "Return current internal node score computed recursively from subnodes.
Subnodes which have been manually scored are honored."
  (if (or
       (= 0 (gametree-current-branch-depth))
       (save-excursion (gametree-forward-line) (eobp))
       (and (looking-at gametree-score-regexp)
            (not (null (match-string 2)))))
      (gametree-current-branch-score)
    (let ((depth (gametree-current-branch-depth)))
      (save-excursion
        (gametree-forward-line)
        ;; the case of a leaf node has already been handled, so here I
        ;; know I am on the 1st line of the current subtree.  This can
        ;; be either a leaf child, or a subheading.
        (let ((running gametree-default-score)
              (minmax
               (if (evenp (gametree-current-branch-ply))
                   'max 'min)))
          (while (and (not (eobp))
                      (= 0 (gametree-current-branch-depth))) ;handle leaves
            (setq running (funcall minmax running
                                   (gametree-current-branch-score)))
            (gametree-forward-line))
          (let ((done (and (not (eobp))
                           (< depth (gametree-current-branch-depth)))))
            (while (not done)           ;handle subheadings
              (setq running (funcall minmax running
                                     (gametree-compute-reduced-score)))
              (setq done (ignore-errors (outline-forward-same-level 1)))))
          running)))))