]> code.delx.au - gnu-emacs-elpa/blobdiff - chess-random.el
Try to improve the promotion situation on ICS by allowing chess-ply to query for...
[gnu-emacs-elpa] / chess-random.el
index 31553734ddb135e83198b170515b6cdbf21f511b..06a01e60e50ad0ae5cc41eb834819adc363318dc 100644 (file)
@@ -5,13 +5,12 @@
 ;; Just call `chess-fischer-random-position' to generate such a
 ;; position.
 ;;
-;; $Revision$
 
 (require 'chess-pos)
 
 (defvar pieces-vector [?r ?n ?b ?q ?k ?b ?n ?r])
 
-(defun shuffle-vector (vector)
+(defun chess-shuffle-vector (vector)
   "Randomly permute the elements of VECTOR (all permutations equally likely)"
   (let ((i 0)
        j
 
 ;;;###autoload
 (defun chess-fischer-random-position ()
+  "Generate a Fischer Random style position."
   (let (pieces position)
     (while (null position)
-      (setq pieces (shuffle-vector pieces-vector))
+      (setq pieces (chess-shuffle-vector pieces-vector))
       (let (first-bishop first-rook king)
        (catch 'retry
          (dotimes (i 8)
                        (throw 'retry t))
                  (setq first-rook i))))))
          (setq position (chess-pos-create)))))
+
+    ;; set the home row pieces
     (dotimes (i 8)
       (chess-pos-set-piece position (chess-rf-to-index 0 i)
                           (aref pieces i))
       (chess-pos-set-piece position (chess-rf-to-index 7 i)
                           (upcase (aref pieces i))))
+
     position))
 
 (provide 'chess-random)