Guest User

Untitled

a guest
Dec 6th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.67 KB | None | 0 0
  1.   (defun make-two (l board &optional (mover *player*))
  2.     (let ((new-board (copy-array board))
  3.       (retval 0))
  4.       (when (board-clear (car l) (cadr l) new-board)
  5.     (setf (aref new-board (car l) (cadr l)) mover)
  6.                     ; reset retval
  7.     (setq retval (find-seq new-board 2 mover)))
  8.       retval))
  9.  
  10.   (defun myheval2 (i j)
  11.     ;; Heuristic function
  12.     ;; Performs simple clustering
  13.     ;; and rewards multiple threat positions.
  14.     (let ((retval 0))
  15.       (if (board-clear i j (get-board))
  16.           ; compute weighted sum of individual heuristics
  17.       (let* ((winpoints (score (list i j) (get-board) *opponent*))
  18.          (stopwinpoints (score (list i j) (get-board)))
  19.          (fourpoints (make-four (list i j) (get-board) *opponent*) )
  20.          (stopfourpoints (make-four (list i j) (get-board)))
  21.          (threepoints  (make-three (list i j) (get-board) *opponent*))
  22.          (stopthreepoints  (make-three (list i j) (get-board)))
  23.          (twopoints  (make-two (list i j) (get-board) *opponent*))
  24.          )
  25.         (setq retval
  26.           (+ (if (< winpoints 0)
  27.              win-score
  28.              0)
  29.              (if (> stopwinpoints 0)
  30.              stopwin-score
  31.              0)
  32.              ;; Multiplying the score with count of occurence
  33.              (* (+
  34.              (* fourpoints four-score)
  35.              (* stopfourpoints  stopfour-score)
  36.              (* threepoints  three-score)
  37.              (* stopthreepoints stopthree-score)
  38.              (if (> twopoints 1) ;; take only if it gives double 2s
  39.                  (* twopoints  player-two-score)
  40.                  0)
  41.              )
  42.             ;;multiplying the above by the total occurrences of threats.
  43.             ;; this multiplier stresses the importance of potential multiple
  44.             ;; attacks
  45.             (+ fourpoints stopfourpoints threepoints stopthreepoints twopoints))
  46.              ))) ;;end let
  47.       retval)))
Add Comment
Please, Sign In to add comment