/[the-feebs-war]/definitions/brains.lisp
ViewVC logotype

Contents of /definitions/brains.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations)
Sat Feb 16 20:01:42 2008 UTC (6 years, 2 months ago) by gmilare
File size: 2117 byte(s)
1 ;;; -*- Common Lisp -*-
2
3 #| Copyright (c) 2007,2008 Gustavo Henrique Milar´┐Ż
4
5 This file is part of The Feebs War.
6
7 The Feebs War is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 The Feebs War is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with The Feebs War. If not, see <http://www.gnu.org/licenses/>.
19 |#
20
21
22 (in-package :the-feebs-war)
23
24
25 ;;; Modified from "cautious-brain"
26
27 (defun auto-brain (status proximity vision vision-left vision-right)
28 (declare (ignore vision-left vision-right))
29 (let ((stuff (my-square proximity)))
30 (cond ((and (member :mushroom stuff :test #'eq)
31 (< (energy-reserve status)
32 (- (get-feeb-parm 'maximum-energy) 20)))
33 :eat-mushroom)
34 ((member :carcass stuff :test #'eq)
35 :eat-carcass)
36 ((and (ready-to-fire status)
37 (> (energy-reserve status) 30)
38 (dotimes (index (min (line-of-sight status) 5))
39 (let ((feeb (find-if #'feeb-image-p (svref vision index))))
40 (if (and feeb
41 (not (eq (feeb-image-facing feeb)
42 (facing status))))
43 (return t)))))
44 :flame)
45 ((and (not (wallp (left-square proximity)))
46 (or (member :mushroom (left-square proximity))
47 (> 3 (random 10))))
48 :turn-left)
49 ((and (not (wallp (right-square proximity)))
50 (or (member :mushroom (right-square proximity))
51 (> 3 (random 10))))
52 :turn-right)
53 ((and (> (line-of-sight status) 0)
54 (not (dotimes (index (min (line-of-sight status) 7))
55 (if (find #'fireball-image-p (svref vision index))
56 (return t)))))
57 :move-forward)
58 (t
59 :turn-around))))
60
61 (defun make-auto-feebs (n)
62 (dotimes (i n)
63 (define-feeb
64 (format nil "System Feeb # ~d" i)
65 #'auto-brain)))

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5