Update api

This commit is contained in:
Loic Guegan 2019-05-09 18:38:31 +02:00
parent f0ccb136eb
commit d261883d41
6 changed files with 91 additions and 11 deletions

View file

@ -39,6 +39,13 @@
(format t "~%Direction: ~a" dir)
(format t "~%Food: ~a" food)))
(defgeneric dump (g)
(:documentation "Dump a game. Return a plist."))
(defmethod dump ((g game))
(with-slots (snake food game-over) g
(list :snake snake :food food :game-over game-over)))
;;; Note that there is no waranty that nb food are added (ex: if food position collide with snake position)
(defgeneric add-food (g nb)
(:documentation "Add food on the game grid."))