anchor.diff:                      (:setup (:done :placing-twice-n)
                        :placing-twice-n
                        (:place :placing-twice-n
  -                      :done :placing-n)
  +                      :done ((fsm)
  +                             (when (eq (rotate-turn game) (head-player game))
  +                               (switch fsm :placing-n))))
                        :placing-n
                        (:place :placing-n
  -                      :done :attacking)
  +                      :done ((fsm)
  +                             (when (eq (rotate-turn game) (head-player game))
  +                               (reset-movable-armies game) 
  +                               (switch fsm :attacking))))
                        :attacking
  -                     (:attack :attacking
  -                      :done :regrouping)
  +                     (:attack ((fsm from to)
  +                               (attack game from to))
  +                      :done ((fsm)
  +                             (switch fsm :regrouping)))
                        :regrouping
  -                     (:move :regrouping
  -                      :done :attacking)
  +                     (:move ((fsm from to amount)
  +                             (move-armies game from to amount))
  +                      :done ((fsm)
  +                             (switch fsm (if (pass-turn game)
  +                                           :placing
  +                                           :attacking))))
                        :placing
                        (:place :placing
  -                      :done :attacking))
  +                      :done ((fsm)
  +                             (when (eq (rotate-turn game) (head-player game))
  +                               (switch fsm :attacking)))))
                       :setup))))
  +
  +(defgeneric read-map (file)
  +  (:method ((list list))
  +   (let* ((territories (make-hash-table :test 'equalp))
  +          (frontiers (make-container 'graph-container)))
  +     (dolist (territory (getf list :territories))
  +       (destructuring-bind (key name extra-armies terr-frontiers) territory
  +         (add-vertex frontiers key)
  +         (setf (gethash key territories)
  +               (make-instance 'territory
  +                              :name name
  +                              :extra-armies extra-armies))
  +         (dolist (frontierkey terr-frontiers)
  +           (add-edge-between-vertexes frontiers key frontierkey))))
  +     (make-instance 'game-map :territories territories :frontiers frontiers)))
  +
  +  (:method ((file stream))
  +   (let* ((*read-eval* nil))
  +     (read-map (read file))))
  +
  +  (:method ((path pathname))
  +   (with-open-file (file path) (read-map file)))
  +
  +  (:method ((path string))
  +   (read-map
  +     (parse-namestring
  +       (if (probe-file path)
  +         path
  +         (format nil "~a.map" path))))))
  +
  +(defgeneric read-game (file)
  +  (:method ((list list))
  +   (let ((game (make-instance 'game
  +                              :game-map (read-map (getf list :game-map))
  +                              :players (getf list :players))))
  +     (loop for (name armies-dist) on (getf list :armies) by #'cddr do
  +           (loop for (territory-key armies) on armies-dist by #'cddr
  +                 for territory = (territory game territory-key) do
  +                 (setf (owner territory) (player game name))
  +                 (setf (armies territory) armies)))
  +     ; TODO: signal error on uninitialized territories
  +     game))
  +
  +  (:method ((file stream))
  +   (let ((*read-eval* nil))
  +     (read-game (read file))))
  +
  +  (:method ((path pathname))
  +   (with-open-file (file path) (read-game file)))
  +
  +  (:method ((path string))
  +   (read-game
  +     (parse-namestring
  +       (if (probe-file path)
  +         path
  +         (format nil "~a.save" path))))))
   
   (defgeneric territory (container key)
     (:method ((container game-map) key)
  
positive.code:    (players nil r)
     (fsm nil)
     (players-round nil)
     (turn-player nil)))
  
  (defgeneric read-map (file)
    (:method ((list list))
     (let* ((territories (make-hash-table :test 'equalp))
            (frontiers (make-container 'graph-container)))
       (dolist (territory (getf list :territories))
         (destructuring-bind (key name extra-armies terr-frontiers) territory
           (add-vertex frontiers key)
           (setf (gethash key territories)
                 (make-instance 'territory
                                :name name
                                :extra-armies extra-armies))
           (dolist (frontierkey terr-frontiers)
             (add-edge-between-vertexes frontiers key frontierkey))))
       (make-instance 'game-map :territories territories :frontiers frontiers)))
  
    (:method ((file stream))
     (let* ((*read-eval* nil))
       (read-map (read file))))
  
    (:method ((path pathname))
     (with-open-file (file path) (read-map file)))
  
    (:method ((path string))
     (read-map
       (parse-namestring
         (if (probe-file path)
           path
           (format nil "~a.map" path))))))
  
  (defgeneric read-game (file)
    (:method ((list list))
     (let ((game (make-instance 'game
                                :game-map (read-map (getf list :game-map))
                                :players (getf list :players))))
       (loop for (name armies-dist) on (getf list :armies) by #'cddr do
             (loop for (territory-key armies) on armies-dist by #'cddr
                   for territory = (territory game territory-key) do
                   (setf (owner territory) (player game name))
                   (setf (armies territory) armies)))
       ; TODO: signal error on uninitialized territories
       game))
  
    (:method ((file stream))
     (let ((*read-eval* nil))
       (read-game (read file))))
  
    (:method ((path pathname))
     (with-open-file (file path) (read-game file)))
  
    (:method ((path string))
     (read-game
       (parse-namestring
         (if (probe-file path)
           path
           (format nil "~a.save" path))))))
  
  (defmethod initialize-instance ((game game) &key game-map players)
    (with-slots ((the-game-map game-map)
  
negative.code:                 collecting (if (equal p (turn-player game))
                               (format nil "-~a-" p)
                               p)))
    (format stream "~&Etapa:~t~a" (state game))
    (format stream "~&Territorios:")
    (loop for v being the hash-values in (territories game) do
          (format stream "~&~t~a~&~t~tDueño:~t~t~a~&~t~tEjércitos:~t~t~a"
  