diff options
| author | Mario Lang <mlang@delysid.org> | 2014-04-15 15:59:37 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-04-15 15:59:37 +0200 |
| commit | 536ff04c7e6bb803919ce810c512412ba7872fed (patch) | |
| tree | 2047d76286ca56a7e860693c3739bb5a7b92bc9c /chess-ai.el | |
| parent | e87a6073cd3901ef6d6e3e50442a52f390fc6eee (diff) | |
chess-ai.el: No need for cl-sort.
Diffstat (limited to 'chess-ai.el')
| -rw-r--r-- | chess-ai.el | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/chess-ai.el b/chess-ai.el index 5f14618..bb43485 100644 --- a/chess-ai.el +++ b/chess-ai.el @@ -36,7 +36,7 @@ (require 'chess-common) (require 'chess-pos) (require 'chess-ply) -(require 'cl-lib) +(eval-when-compile (require 'cl-lib)) (defgroup chess-ai () "A simple chess engine written in Emacs Lisp. @@ -192,14 +192,14 @@ index." (let* ((side-to-move (chess-pos-side-to-move position)) (plies (chess-legal-plies position :color side-to-move))) (if (not capture-only) - (cl-sort plies - (lambda (a b) - (let ((l '(?Q ?R ?B ?N ?P ? )) - (p1 (cadr (chess-ply-changes a))) - (p2 (cadr (chess-ply-changes b)))) - (or (< (length (memq (chess-pos-piece position p1) l)) - (length (memq (chess-pos-piece position p2) l))) - (funcall (if side-to-move #'< #'>) p1 p2))))) + (sort plies + (lambda (a b) + (let ((l '(?Q ?R ?B ?N ?P ? )) + (p1 (cadr (chess-ply-changes a))) + (p2 (cadr (chess-ply-changes b)))) + (or (< (length (memq (chess-pos-piece position p1) l)) + (length (memq (chess-pos-piece position p2) l))) + (funcall (if side-to-move #'< #'>) p1 p2))))) (cl-delete-if (lambda (ply) (= (chess-pos-piece position (cadr (chess-ply-changes ply))) @@ -246,7 +246,7 @@ index." (defun chess-ai-legal-plies (position depth) "Return a sorted list of legal plies for POSITION with scores calculated DEPTH plies deep." - (cl-sort + (sort (mapcar (lambda (ply) (chess-ply-set-keyword ply :score (- (chess-ai-search (chess-ply-next-pos ply) |
