summaryrefslogtreecommitdiff
path: root/chess-pos.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-08 23:18:37 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-08 23:18:37 +0000
commitf105ea934d5a66d8d30a711e619835596ad2d28b (patch)
tree436e10b788f6412322e8b3796fb4973e85b16892 /chess-pos.el
parentc67544683ffed1660bad0d5e67a6e5d47e288be1 (diff)
*** no comment ***
Diffstat (limited to 'chess-pos.el')
-rw-r--r--chess-pos.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/chess-pos.el b/chess-pos.el
index 915e5b9..d6aa178 100644
--- a/chess-pos.el
+++ b/chess-pos.el
@@ -213,7 +213,7 @@ If PIECE-OR-COLOR is t for white or nil for black, any piece of that
color will do."
(let ((p (chess-pos-piece position index)))
(cond
- ((= p ? ) (= p piece-or-color))
+ ((= p ? ) (eq p piece-or-color))
((eq piece-or-color t) (< p ?a))
((eq piece-or-color nil) (> p ?a))
(t (= p piece-or-color)))))
@@ -228,6 +228,24 @@ color will do."
(push i found)))
found))
+(defconst chess-pos-piece-values
+ '((?p . 1)
+ (?n . 3)
+ (?b . 3)
+ (?q . 9)
+ (?r . 5)
+ (?k . 0)))
+
+(defun chess-pos-material-value (position color)
+ "Return the aggregate material value in POSITION for COLOR."
+ (let ((pieces (chess-pos-search position color))
+ (value 0))
+ (dolist (index pieces)
+ (setq value
+ (+ value (cdr (assq (downcase (chess-pos-piece position index))
+ chess-pos-piece-values)))))
+ value))
+
(defun chess-pos-move (position &rest changes)
"Move a piece on the POSITION directly, using the indices FROM and TO.
This function does not check any rules, it only makes sure you are not