Noble Ape
The Central Directories of the Noble Ape Simulation.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
universe_internal.h
Go to the documentation of this file.
1 /****************************************************************
2 
3  universe_internal.h
4 
5  =============================================================
6 
7  Copyright 1996-2014 Tom Barbalet. All rights reserved.
8 
9  Permission is hereby granted, free of charge, to any person
10  obtaining a copy of this software and associated documentation
11  files (the "Software"), to deal in the Software without
12  restriction, including without limitation the rights to use,
13  copy, modify, merge, publish, distribute, sublicense, and/or
14  sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following
16  conditions:
17 
18  The above copyright notice and this permission notice shall be
19  included in all copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  OTHER DEALINGS IN THE SOFTWARE.
29 
30  This software and Noble Ape are a continuing work of Tom Barbalet,
31  begun on 13 June 1996. No apes or cats were harmed in the writing
32  of this software.
33 
34  ****************************************************************/
35 
36 #ifndef NOBLEAPE_UNIVERSE_INTERNAL_H
37 #define NOBLEAPE_UNIVERSE_INTERNAL_H
38 
39 #define USE_FIL_VER
40 #define USE_FIL_LAN
41 #define USE_FIL_BEI
42 #undef USE_FIL_SOE
43 #undef USE_FIL_EPI
44 #undef USE_FIL_WEA
45 #undef USE_FIL_BRA
46 
47 /* Land - References */
48 
49 #undef REDUCE_FILE
50 
51 /* Time definitions */
52 
53 #define GENERATIONS_BYTES (sizeof(n_byte)*4)
54 #define DRIVES_BYTES (DRIVES)
55 #define GOALS_BYTES (sizeof(n_byte2)*3)
56 
57 #define SOCIAL_BYTES ((SOCIAL_SIZE*sizeof(noble_social))+(2*4))
58 
59 #ifdef EPISODIC_ON
60 #define EPISODIC_BYTES (EPISODIC_SIZE*sizeof(noble_episodic))
61 #else
62 #define EPISODIC_BYTES 0
63 #endif
64 
65 #ifdef BRAINCODE_ON
66 #define BRAINCODE_BYTES (BRAINCODE_SIZE)
67 #define BRAINCODE_PROBE_BYTES (BRAINCODE_PROBES*sizeof(noble_brain_probe))
68 #else
69 #define BRAINCODE_BYTES 0
70 #define BRAINCODE_PROBE_BYTES 0
71 #endif
72 
73 #ifdef TERRITORY_ON
74 #define TERRITORY_BYTES (TERRITORY_AREA*sizeof(noble_place))
75 #else
76 #define TERRITORY_BYTES 0
77 #endif
78 
79 #define PARA_BYTES 2
80 #define PARA_ENTRIES 2
81 
82 #ifdef IMMUNE_ON
83 #define IMMUNE_BYTES (sizeof(noble_immune_system))
84 #else
85 #define IMMUNE_BYTES 0
86 #endif
87 
88 
89 #define GENETICS_BYTES (sizeof(n_genetics)*CHROMOSOMES)
90 #define GENETICS_ENTRIES 1
91 
92 #define PARENT_BYTES (9+(GENETICS_BYTES*2))
93 
94 #define INVENTORY_BYTES (INVENTORY_SIZE*sizeof(n_byte2))
95 
96 /* offsets within the file */
97 #define INITIAL_BLOCK_BYTES (40+INVENTORY_BYTES)
98 #define OFFSET_PARASITES (INITIAL_BLOCK_BYTES+SHOUT_BYTES)
99 
100 #define OFFSET_PARENTING (OFFSET_PARASITES+PARA_BYTES)
101 
102 #define OFFSET_GENETICS (OFFSET_PARENTING+14+GENETICS_BYTES+(CHROMOSOMES*4))
103 #define OFFSET_SOCIAL (OFFSET_GENETICS+GENETICS_BYTES)
104 #define OFFSET_EPISODIC (OFFSET_SOCIAL+SOCIAL_BYTES)
105 #define OFFSET_TERRITORY (OFFSET_EPISODIC+EPISODIC_BYTES+DRIVES_BYTES+GOALS_BYTES+PREFERENCES+GENERATIONS_BYTES)
106 #define OFFSET_IMMUNE ((OFFSET_GENETICS+GENETICS_BYTES+DRIVES_BYTES+6+PREFERENCES+GENERATIONS_BYTES+8)+TERRITORY_BYTES)
107 #define OFFSET_VASCULAR (OFFSET_IMMUNE+IMMUNE_BYTES)
108 #define OFFSET_METABOLISM (OFFSET_VASCULAR)
109 
110 #define OFFSET_BRAINCODE (OFFSET_METABOLISM)
111 
113 {
114  FIL_VER = (0x10),
115  FIL_LAN = (0x20),
116  FIL_BEI = (0x30),
117  FIL_SOE = (0x40),
118  FIL_EPI = (0x50),
119  FIL_WEA = (0x60),
120  FIL_BRA = (0x70),
121  FIL_END = (0x80)
122 };
123 
124 static const noble_file_entry noble_file_format[]=
125 {
126 #ifdef USE_FIL_VER
127  {"simul{", FIL_VER, 0, 0, "Simulation Version Definition"},
128  {"signa=", FIL_VER | FILE_TYPE_BYTE2, 1, 0, "Simulation signature"},
129  {"verio=", FIL_VER | FILE_TYPE_BYTE2, 1, 2, "Simulation version number"},
130 #endif
131 #ifdef USE_FIL_LAN
132  {"landd{", FIL_LAN, 0, 0, "land definition"},
133  {"dated=", FIL_LAN | FILE_TYPE_BYTE4, 1, 0, "Date in days and millenia"},
134  {"landg=", FIL_LAN | FILE_TYPE_BYTE2, 2, 4, "Seed that created the land"},
135  {"timed=", FIL_LAN | FILE_TYPE_BYTE2, 1, 8, "Time in minutes"},
136 
137 #endif
138  /* the line above is a substantial limit to the simulation space. The weather will limit the map area to;
139  ((sizeof(n_int)/2) * (MAP_AREA)/(256*256)) <= 255
140  */
141 #ifdef USE_FIL_WEA
142  {"weath{", FIL_WEA, 0, 0},
143  {"press=", FIL_WEA | FILE_TYPE_BYTE, sizeof(n_c_int), 0},
144 #endif
145 
146 #ifndef REDUCE_FILE /* FILE_TYPE_PACKED has a different form - no offset and the number is the size of the PACKED_DATA_BLOCK units */
147  /* {"atmos=", FIL_WEA | DONTFILE_TYPE_PACKED, ((sizeof(n_c_int) * MAP_AREA) / (PACKED_DATA_BLOCK*2)), 1},*/
148 #endif
149 
150 #ifdef USE_FIL_BEI
151  {"being{", FIL_BEI, 0, 0, "Being Definition"},
152  {"locat=", FIL_BEI | FILE_TYPE_BYTE2, 2, 0, "Location in x and y coordinates"}, /*n_byte2 x;n_byte2 y;*/
153  {"facin=", FIL_BEI | FILE_TYPE_BYTE, 1, 4, "Direction facing"}, /*n_byte facing;*/
154  {"speed=", FIL_BEI | FILE_TYPE_BYTE, 1, 5, "Speed traveling"}, /*n_byte speed;*/
155  {"energ=", FIL_BEI | FILE_TYPE_BYTE2, 1, 6, "Energy within"}, /*n_byte2 energy;*/
156  {"datob=", FIL_BEI | FILE_TYPE_BYTE4, 1, 8, "Date of birth in days and millenia"}, /*n_byte2 date_of_birth[2];*/
157  {"rando=", FIL_BEI | FILE_TYPE_BYTE2, 2, 12,"Random within"}, /*n_byte2 seed[2];*/
158  {"state=", FIL_BEI | FILE_TYPE_BYTE2, 1, 16,"State description"}, /*n_byte2 state;*/
159 
160  {"brast=", FIL_BEI | FILE_TYPE_BYTE2, 6, 18,"Brain state values"}, /*n_byte2 brain_state[6];*/
161 
162  {"heigt=", FIL_BEI | FILE_TYPE_BYTE2, 1, 30, "Height"}, /*n_byte2 height;*/
163  {"masss=", FIL_BEI | FILE_TYPE_BYTE2, 1, 32, "Mass"}, /*n_byte2 mass;*/
164  {"overr=", FIL_BEI | FILE_TYPE_BYTE2, 1, 34, "ApeScript overrides"}, /*n_byte2 script_overrides;*/
165  {"shout=", FIL_BEI | FILE_TYPE_BYTE, SHOUT_BYTES, 36, "Shouting values"}, /*n_byte shout[SHOUT_BYTES];*/
166  {"crowd=", FIL_BEI | FILE_TYPE_BYTE, 1, 42, "Crowding"}, /*n_byte crowding;*/
167  {"postu=", FIL_BEI | FILE_TYPE_BYTE, 1, 43, "Posture"}, /*n_byte posture;*/
168  {"inven=", FIL_BEI | FILE_TYPE_BYTE2, INVENTORY_SIZE, 44, "Inventory"}, /*n_byte2 inventory[INVENTORY_SIZE];*/
169 
170  {"paras=", FIL_BEI | FILE_TYPE_BYTE, 1, 60, "Number of parasites"}, /*n_byte parasites;*/
171  {"honor=", FIL_BEI | FILE_TYPE_BYTE, 1, 61, "Honor"}, /*n_byte honor;*/
172 
173  {"conce=", FIL_BEI | FILE_TYPE_BYTE4, 1, 62, "Date of conception in days and millenia"}, /*n_byte2 date_of_conception[2];*/
174 
175  {"atten=", FIL_BEI | FILE_TYPE_BYTE, ATTENTION_SIZE, 66, "Attention group"}, /*n_byte attention[ATTENTION_SIZE];*/
176 
177  {"genet=", FIL_BEI | FILE_TYPE_BYTE2, CHROMOSOMES * 2, 72, "Genetics"}, /*n_genetics genetics[CHROMOSOMES];*/
178 
179  {"fetag=", FIL_BEI | FILE_TYPE_BYTE2, CHROMOSOMES * 2, 88, "Father genetics"}, /*n_genetics fetal_genetics[CHROMOSOMES];*/
180 
181  {"fathn=", FIL_BEI | FILE_TYPE_BYTE , 2, 104, "Father family names"}, /*n_byte father_name[2];*/
182 
183 
184  {"sosim=", FIL_BEI | FILE_TYPE_BYTE2, 4, 108, "Social simulation values"}, /* n_byte2 social simulation values x, y, nx, ny */
185 
186  {"drive=", FIL_BEI | FILE_TYPE_BYTE, DRIVES, 116, "Drives"}, /*n_byte drives[DRIVES];*/
187  {"goals=", FIL_BEI | FILE_TYPE_BYTE2, 4, 120, "Goals"},
188 
189  {"prefe=", FIL_BEI | FILE_TYPE_BYTE, PREFERENCES, 128, "Preferences"},
190  {"genex=", FIL_BEI | FILE_TYPE_BYTE2, 1, 142, "Generation Max"},
191  {"genen=", FIL_BEI | FILE_TYPE_BYTE2, 1, 144, "Generation Min"},
192  {"chigx=", FIL_BEI | FILE_TYPE_BYTE2, 1, 146, "Child Generation Max"},
193  {"chign=", FIL_BEI | FILE_TYPE_BYTE2, 1, 148, "Child Generation Min"},
194 #ifdef TERRITORY_ON
195  {"terit=", FIL_BEI | FILE_TYPE_BYTE2, TERRITORY_BYTES/2, 150, "Territory information"},
196 #endif
197 #ifdef IMMUNE_ON
198  {"immun=", FIL_BEI | FILE_TYPE_BYTE, IMMUNE_BYTES, 406, "Immune system information"},
199 #endif
200 
201 #ifdef BRAINCODE_ON
202  {"brreg=", FIL_BEI | FILE_TYPE_BYTE, BRAINCODE_PSPACE_REGISTERS, 451, "Brain code register"},
203  {"brpro=", FIL_BEI | FILE_TYPE_BYTE, (sizeof(noble_brain_probe)*BRAINCODE_PROBES), 454, "Brain code probe"},
204 #endif
205 
206 #endif
207 
208 #ifdef USE_FIL_SOE
209  {"sgcia{", FIL_SOE, 0, 0, "Social graph definition"},
210  {"sgloc=", FIL_SOE | FILE_TYPE_BYTE2, 2, 0, "Location in x and y coordinates"}, /* n_byte2 location[2];*/
211  {"sgtim=", FIL_SOE | FILE_TYPE_BYTE2, 1, 4, "Time in minutes"}, /* n_byte2 time;*/
212  {"sgdat=", FIL_SOE | FILE_TYPE_BYTE4, 1, 6, "Date in days and millenia"}, /* n_byte2 date[2];*/
213  {"sgfin=", FIL_SOE | FILE_TYPE_BYTE2, 1, 10, "First name"},/* n_byte2 first_name;*/
214  {"sgfan=", FIL_SOE | FILE_TYPE_BYTE2, 1, 14, "Family name"},/* n_byte2 family_name;*/
215 
216  {"sgatt=", FIL_SOE | FILE_TYPE_BYTE, 1, 18, "Attraction"},/* n_byte attraction;*/
217  {"sgfof=", FIL_SOE | FILE_TYPE_BYTE, 1, 19, "Friend or foe"},/* n_byte friend_foe;*/
218  {"sgbel=", FIL_SOE | FILE_TYPE_BYTE2, 1, 20, "Belief"},/* n_byte2 belief;*/
219  {"sgfam=", FIL_SOE | FILE_TYPE_BYTE2, 1, 22, "Familiarity"},/* n_byte2 familiarity;*/
220 
221  {"sgrel=", FIL_SOE | FILE_TYPE_BYTE, 1, 24, "Relationship"},/* n_byte relationship;*/
222  {"sgtyp=", FIL_SOE | FILE_TYPE_BYTE, 1, 25, "Entity type"},/* n_byte relationship;*/
223 
224 #ifdef BRAINCODE_ON
225  {"sgbrc=", FIL_SOE | FILE_TYPE_BYTE_EXT, BRAINCODE_SIZE, 26, "Local braincode"}, /*n_byte braincode[BRAINCODE_SIZE];*/
226 #endif
227 
228 #endif
229 
230 #ifdef USE_FIL_EPI
231  {"episo{", FIL_EPI, 0, 0, "Episodic memory definition"},
232  {"eploc=", FIL_EPI | FILE_TYPE_BYTE2, 2, 0, "Location in x and y coordinates"}, /* n_byte2 location[2];*/
233  {"eptim=", FIL_EPI | FILE_TYPE_BYTE2, 1, 4, "Time in minutes"}, /* n_byte2 time;*/
234  {"epdat=", FIL_EPI | FILE_TYPE_BYTE4, 1, 6, "Date in days and millenia"}, /* n_byte2 date[2];*/
235  {"epfin=", FIL_EPI | FILE_TYPE_BYTE2, 2, 10, "First name"},/* n_byte2 first_name;*/
236  {"epfan=", FIL_EPI | FILE_TYPE_BYTE2, 2, 14, "Family name"},/* n_byte2 family_name;*/
237 
238  {"epeve=", FIL_EPI | FILE_TYPE_BYTE, 1, 18, "Event"},/* n_byte event;*/
239  {"epfoo=", FIL_EPI | FILE_TYPE_BYTE, 1, 19, "Food"},/* n_byte food;*/
240  {"epafe=", FIL_EPI | FILE_TYPE_BYTE2, 1, 20, "Affect"},/* n_byte2 affect;*/
241  {"eparg=", FIL_EPI | FILE_TYPE_BYTE2, 1, 22, "Arg"},/* n_byte2 arg;*/
242 #endif
243 
244 #ifndef REDUCE_FILE /* FILE_TYPE_PACKED has a different form - no offset and the number is the size of the PACKED_DATA_BLOCK units */
245  /* {"brdat=", FIL_BRA | DONTFILE_TYPE_PACKED, DOUBLE_BRAIN/PACKED_DATA_BLOCK, 1 },*/
246 #endif
247 
248  {{0, 0, 0, 0, 0, 0, 0},0, 0, 0, 0L}
249 
250 };
251 
252 #define TRACK_BRAIN(loc,lx,ly,lz) ((loc)[(lx)|((ly)<<5)|((lz)<<10)])
253 
254 /* functions */
255 
256 n_int sketch_input(void *code, n_byte kind, n_int value);
257 n_int sketch_output(void * vcode, void * vindividual, n_byte * kind, n_int * number);
258 
259 void sim_end_conditions(void * individual, void * structure, void * data);
260 void sim_start_conditions(void * individual, void * structure, void * data);
261 
262 void console_external_watch(void);
263 
265 
266 void file_audit(void);
267 
268 #endif /* NOBLEAPE_UNIVERSE_INTERNAL_H */