;;; -*- 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 . |# (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)))