nim.l (581B)
1 # 08feb11abu 2 # (c) Software Lab. Alexander Burger 3 4 (load "@lib/simul.l") 5 6 # Nim 7 (de nim Pos 8 (game T NIL 9 '((Flg) # Moves 10 (make 11 (for (I . N) Pos 12 (do N 13 (link 14 (cons (cons I N) I (- N)) ) 15 (dec 'N) ) ) ) ) 16 '((Mov) # Move 17 (dec (nth Pos (car Mov)) (cdr Mov)) ) 18 '((Flg) # Cost 19 (let N (apply + Pos) 20 (if (=0 N) -100 N) ) ) ) ) 21 22 ### Test ### 23 (test 24 '(-100 ((1 . 4) 1 . -4) ((2 . 4) 2 . -4) ((3 . 4) 3 . -4)) 25 (nim 4 4 4) ) 26 27 # vi:et:ts=3:sw=3