qtgui: parent the agent injector/brain viewer correctly, and fix some onSelect functi...
[openc2e.git] / oldBrain.h
blobbf1b4b68a2069bc421362b1d829674bcfe0d14ad
1 /*
2 * oldBrain.h
3 * openc2e
5 * Created by Alyssa Milburn on Mon Aug 13 2007.
6 * Copyright (c) 2007 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef __OLDBRAIN_H
21 #define __OLDBRAIN_H
23 #include "genome.h"
24 #include <boost/shared_ptr.hpp>
25 #include <set>
26 #include <map>
28 using boost::shared_ptr;
30 struct oldNeuron {
31 unsigned char state, output;
34 struct oldDendrite {
35 oldNeuron *src, *dest;
36 unsigned char strength, stw, ltw, suscept;
39 class oldLobe {
40 protected:
41 class oldBrain *parent;
42 oldBrainLobeGene *ourGene;
43 std::vector<oldNeuron> neurons;
44 std::vector<oldDendrite> dendrites[2];
45 oldLobe *sourceLobe[2];
46 bool inited;
48 public:
49 oldLobe(class oldBrain *b, oldBrainLobeGene *g);
50 bool wasInited() { return inited; }
51 void tick();
52 void init();
53 void wipe();
54 oldBrainLobeGene *getGene() { return ourGene; }
55 unsigned int getNoNeurons() { return neurons.size(); }
56 unsigned int getNoDendrites(unsigned int t) { return dendrites[t].size(); }
57 oldNeuron *getNeuron(unsigned int i) { return &neurons[i]; }
58 oldDendrite *getDendrite(unsigned int t, unsigned int i) { return &dendrites[t][i]; }
61 class oldBrain {
62 protected:
63 // TODO: should be oldCreature?
64 class oldCreature *parent;
66 public:
67 std::map<unsigned int, oldLobe *> lobes;
69 oldBrain(oldCreature *p);
70 void tick();
71 void processGenes();
72 void init();
73 oldLobe *getLobeByTissue(unsigned int id);
74 oldCreature *getParent() { return parent; }
77 #endif
79 /* vim: set noet: */