;;; -*- 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) ;;; Modified from "cautious-brain" (defun auto-brain (status proximity vision vision-left vision-right) (declare (ignore vision-left vision-right)) (let ((stuff (my-square proximity))) (cond ((and (member :mushroom stuff :test #'eq) (< (energy-reserve status) (- (get-feeb-parm 'maximum-energy) 20))) :eat-mushroom) ((member :carcass stuff :test #'eq) :eat-carcass) ((and (ready-to-fire status) (> (energy-reserve status) 30) (dotimes (index (min (line-of-sight status) 5)) (let ((feeb (find-if #'feeb-image-p (svref vision index)))) (if (and feeb (not (eq (feeb-image-facing feeb) (facing status)))) (return t))))) :flame) ((and (not (wallp (left-square proximity))) (or (member :mushroom (left-square proximity)) (> 3 (random 10)))) :turn-left) ((and (not (wallp (right-square proximity))) (or (member :mushroom (right-square proximity)) (> 3 (random 10)))) :turn-right) ((and (> (line-of-sight status) 0) (not (dotimes (index (min (line-of-sight status) 7)) (if (find #'fireball-image-p (svref vision index)) (return t))))) :move-forward) (t :turn-around)))) (defun make-auto-feebs (n) (dotimes (i n) (define-feeb (format nil "System Feeb # ~d" i) #'auto-brain)))