Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun make-two (l board &optional (mover *player*))
- (let ((new-board (copy-array board))
- (retval 0))
- (when (board-clear (car l) (cadr l) new-board)
- (setf (aref new-board (car l) (cadr l)) mover)
- ; reset retval
- (setq retval (find-seq new-board 2 mover)))
- retval))
- (defun myheval2 (i j)
- ;; Heuristic function
- ;; Performs simple clustering
- ;; and rewards multiple threat positions.
- (let ((retval 0))
- (if (board-clear i j (get-board))
- ; compute weighted sum of individual heuristics
- (let* ((winpoints (score (list i j) (get-board) *opponent*))
- (stopwinpoints (score (list i j) (get-board)))
- (fourpoints (make-four (list i j) (get-board) *opponent*) )
- (stopfourpoints (make-four (list i j) (get-board)))
- (threepoints (make-three (list i j) (get-board) *opponent*))
- (stopthreepoints (make-three (list i j) (get-board)))
- (twopoints (make-two (list i j) (get-board) *opponent*))
- )
- (setq retval
- (+ (if (< winpoints 0)
- win-score
- 0)
- (if (> stopwinpoints 0)
- stopwin-score
- 0)
- ;; Multiplying the score with count of occurence
- (* (+
- (* fourpoints four-score)
- (* stopfourpoints stopfour-score)
- (* threepoints three-score)
- (* stopthreepoints stopthree-score)
- (if (> twopoints 1) ;; take only if it gives double 2s
- (* twopoints player-two-score)
- 0)
- )
- ;;multiplying the above by the total occurrences of threats.
- ;; this multiplier stresses the importance of potential multiple
- ;; attacks
- (+ fourpoints stopfourpoints threepoints stopthreepoints twopoints))
- ))) ;;end let
- retval)))
Add Comment
Please, Sign In to add comment