Author: gmilare Date: Sun Feb 17 15:29:26 2008 New Revision: 16
Added: utils.lisp Removed: definitions/utils.lisp Modified: graphics/graphics.lisp images.lisp package.lisp the-feebs-war.asd Log:
Modified: graphics/graphics.lisp ============================================================================== --- graphics/graphics.lisp (original) +++ graphics/graphics.lisp Sun Feb 17 15:29:26 2008 @@ -18,8 +18,11 @@ along with The Feebs War. If not, see http://www.gnu.org/licenses/. |#
+ (in-package :the-feebs-war)
+ + (defun print-direction (dir) (case dir (0 #\N)
Modified: images.lisp ============================================================================== --- images.lisp (original) +++ images.lisp Sun Feb 17 15:29:26 2008 @@ -40,10 +40,6 @@ left-square right-square)
-(defun rcurry (func &rest args) - #'(lambda (x) - (apply func x args))) -
;;; Computes what the feeb is seeing
Modified: package.lisp ============================================================================== --- package.lisp (original) +++ package.lisp Sun Feb 17 15:29:26 2008 @@ -122,6 +122,7 @@ (in-package :the-feebs-war)
+ ;;; Directions
(deftype direction ()
Modified: the-feebs-war.asd ============================================================================== --- the-feebs-war.asd (original) +++ the-feebs-war.asd Sun Feb 17 15:29:26 2008 @@ -13,22 +13,24 @@ ; :depends-on (lispbuilder-sdl lispbuilder-sdl-image lispbuilder-sdl-gfx)
:components - (:cl-source-file "package") - (:cl-source-file "system" :depends-on ("package")) - (:cl-source-file "images" :depends-on ("system")) - (:cl-source-file "main" :depends-on ("images" "system")) + ((:cl-source-file "package") + (:cl-source-file "utils" :depends-on ("package")) + (:cl-source-file "system" :depends-on ("utils")) + (:cl-source-file "images" :depends-on ("system")) + (:cl-source-file "main" :depends-on ("images"))
- (:module "definitions" - :components - (:cl-source-file "utils") - (:cl-source-file "rules" :depends-on ("main")) - (:cl-source-file "mazes" :depends-on ("package" "utils")) - (:cl-source-file "extra" :depends-on ("package")) - (:cl-source-file "brains" :depends-on ("package"))) + (:module "definitions" + :depends-on ("main") + :components + ((:cl-source-file "rules") + (:cl-source-file "mazes") + (:cl-source-file "extra") + (:cl-source-file "brains")))
(:module "graphics" + :depends-on ("main") :components - (:file "graphics" :depends-on ("main"))) + ((:file "graphics"))))
;; GPL (:doc-file "licence")
Added: utils.lisp ============================================================================== --- (empty file) +++ utils.lisp Sun Feb 17 15:29:26 2008 @@ -0,0 +1,55 @@ +;;; -*- Common Lisp -*- + +#| Copyright (c) 2007,2008 Gustavo Henrique Milar� + + This file is part of The Feebs War. + + The Feebs War is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + The Feebs War is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The Feebs War. If not, see http://www.gnu.org/licenses/. +|# + + +(in-package :the-feebs-war) + + + +(defun bound-random (start min avg max) + (+ start + (* (expt -1 (random 2)) + (let ((sort (random 2.0))) + (round + (if (< sort 1.0) + (+ min (* sort (- avg min))) + (+ avg (* (1- sort) (- max avg))))))))) + +(defun random-elt (seq) + (if seq + (elt seq (random (length seq))))) + +(defmacro ensure-bound (elt min max) + `(setf ,elt (bound ,elt ,min ,max))) + +(defun bound (elt min max) + (max min (min max elt))) + +(defmacro aif (test then &optional else) + `(let ((it ,test)) + (if it ,then ,else))) + +(defmacro awhen (test &rest body) + `(let ((it ,test)) + (when it ,@body))) + +(defun rcurry (func &rest args) + #'(lambda (x) + (apply func x args)))