home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / NEURLNET / NERVES.ZIP / NS.DOC < prev    next >
Encoding:
Text File  |  1991-01-22  |  18.5 KB  |  352 lines

  1. NERVOUS SYSTEM CONSTRUCTION KIT FOR IBM COMPATIBLES
  2.  
  3. VERSION 2.0, 1-22-91
  4.  
  5. >>>>FOR A COPY OF THE MOST RECENT VERSION OF THE PROGRAM AND TURBO-
  6. C/C++ SOURCE CODE (PLEASE SPECIFY DISK TYPE REQUIRED: 360KB, 1.2MB, OR 
  7. 720KB), SEND $10.00 (U.S.$15.00 FOR DELIVERY OUTSIDE NORTH AMERICA); 
  8. REQUIRES EGA OR VGA; SOURCE CODE CAN BE COMPILED WITH BORLAND'S TURBO 
  9. C VERSION 2 OR TURBO C++ VERSION 1<<<<
  10.  
  11. By Pat and Greg Williams, Rt. 1, Box 302, Gravel Switch, KY 40328, 
  12. 606-332-7606. Based on the ideas of Randall D. Beer, Department of 
  13. Computer Engineering and Science, Case Western Reserve University, 
  14. Cleveland, Ohio, as found in his INTELLIGENCE AS ADAPTIVE BEHAVIOR: AN 
  15. EXPERIMENT IN COMPUTATIONAL NEUROETHOLOGY, Academic Press, 1990 (ISBN 
  16. 0-12-084730-2; to order, you can phone A.P. toll-free at 1-800-321-
  17. 5068). 
  18.  
  19. READ THIS FIRST: These executable programs, source code files, and 
  20. associated documentation are supplied AS IS, WITHOUT WARRANTY. All 
  21. consequences of their use (or misuse) are solely the responsibilities 
  22. of the users, and in no case shall Pat Williams, Greg Williams, 
  23. Randall Beer, or Academic Press be liable for damages arising 
  24. therefrom. Modification of the source code is hereby permitted and 
  25. encouraged (we do hope you will share your additions and corrections 
  26. with us and with others). You may distribute copies of the original 
  27. distribution disk as you wish. 
  28.  
  29. FILES ON DISK(S)
  30.  
  31. EXECUTABLES AND AUXILIARY FILES (IN ROOT DIRECTORY):
  32.   EGAVGA.BGI - Borland graphics file used by NS87.EXE, NS.EXE, and 
  33.     NSPLAY.EXE (must be in default directory)
  34.   NS87.EXE - main program for computers with math coprocessors
  35.   NS.EXE - main program for computers without math coprocessors
  36.   NSPLAY.EXE - animation playback program
  37.   NSPRINT.EXE - utility program to print neuron parameters and 
  38.     connections
  39.   L3R3.NEU, EDGE3.NEU, APP3.NEU - sample neuron files
  40.   L3R3.ENV, EDGE3.ENV, APP3.ENV - sample environment files
  41.   SINCOS.TAB - data file used by NS.EXE (must be in default directory)
  42.   NS10.SAV - sample animation data file
  43.   
  44. SOURCE AND AUXILIARY FILES FOR COMPILING NS87.EXE (IN "87" DIRECTORY):
  45.   *.C - C SOURCE FILES
  46.   *.H - C HEADER FILES
  47.   NS87.PRJ - PROJECT FILE FOR TURBO C++
  48.   NS87.PJC - PROJECT FILE FOR TURBO C (MEDIUM MODEL)
  49.  
  50. SOURCE AND AUXILIARY FILES FOR COMPILING NS.EXE (IN "NO87" DIRECTORY):
  51.   *.C - C SOURCE FILES
  52.   *.H - C HEADER FILES
  53.   NS.PRJ - PROJECT FILE FOR TURBO C++
  54.   NS.PRC - PROJECT FILE FOR TURBO C (MEDIUM MODEL)
  55.  
  56. SOURCE AND AUXILIARY FILES FOR COMPILING NSPLAY.EXE (IN "PLAY" 
  57.   DIRECTORY):
  58.   *.C - C SOURCE FILES
  59.   *.H - C HEADER FILES
  60.   NSPLAY.PRJ - PROJECT FILE FOR TURBO C++
  61.   NSPLAY.PRC - PROJECT FILE FOR TURBO C (LARGE MODEL)
  62.  
  63. SOURCE AND AUXILIARY FILES FOR COMPILING NSPRINT.EXE (IN "PRINT" 
  64.   DIRECTORY):
  65.   *.C - C SOURCE FILES
  66.   DEFN.H - C HEADER FILE (MEDIUM MODEL)
  67.  
  68. I. INTRODUCTION
  69.  
  70. When we came upon Dr. Beer's beautifully done book (a revision of his 
  71. 1989 dissertation), we immediately decided to attempt a PC-replication 
  72. of his computer simulation of the real-time behavior of a simplified 
  73. cockroach. The simulation is the first we've seen which starts at the 
  74. level of (reasonably realistically modeled) individual neurons and 
  75. ends up with whole-organism behavior. Dr. Beer's hexapod bug walks 
  76. with various gaits, wanders, follows edges, moves toward "food" when 
  77. its "energy" supply is low, "eats," and manages to avoid conflicts 
  78. among its various types of behavior. As programmed by Dr. Beer, the 
  79. bug has about 80 neurons, with about 150 connections and about 500 
  80. user-settable parameters. The program allows arbitrary connection of 
  81. neurons (and, via modifications to the source code [Turbo C compiler 
  82. needed for this], arbitrary specification of organism and environment 
  83. models), making it a general "construction kit" for small artificial 
  84. neural networks. Note that these networks are NOT of the generalized 
  85. type beloved by "connectionism," but rather are designed to perform 
  86. specific functions within the context of an organism's ecological 
  87. niche. Psychological control theory enthusiasts should note that Dr. 
  88. Beer's bug's nervous system isn't organized as a Powersian 
  89. hierarchical control system (see William T. Powers, BEHAVIOR: THE 
  90. CONTROL OF PERCEPTION, Aldine, Chicago, 1973), but networks organized 
  91. in that way certainly can be constructed using the program. TO 
  92. UNDERSTAND THE PROGRAM, YOU WILL NEED TO READ (AT LEAST PARTS OF) 
  93. INTELLIGENCE AS ADAPTIVE BEHAVIOR.
  94.  
  95. Suggestions, questions, modifications, etc., are welcome. Let us know 
  96. your thoughts about this stuff... down the road possibilities include 
  97. simulations of nematodes (having only a few hundred neurons in their 
  98. entire nervous system), Aplysia (modifiable synapses), spiders (prey-
  99. catching, web building?), and op-amp-circuit realization of neurons 
  100. (for speedier computations in parallel).
  101.  
  102. We recommend INTELLIGENCE AS ADAPTIVE BEHAVIOR not only for its 
  103. development of the bug model, but for its extended critique of 
  104. traditional approaches in Artificial Intelligence. Here's the 
  105. foundation for a new field, folks: non-verbal AI. Thank you, Dr. Beer! 
  106.  
  107. II. RUNNING THE PROGRAM
  108.  
  109. The executable files are NS.EXE (if you don't have a math coprocessor) 
  110. and NS87.EXE (if you have a coprocessor). Results of simulations with 
  111. the two files are quite similar BUT NOT IDENTICAL, because of round-
  112. off and other differences between integer and long calculations in the 
  113. former and float and double calculations in the latter. Actually, you 
  114. can run either file on computers with or without coprocessors, but 
  115. NS.EXE runs about half as fast as NS87.EXE with a coprocessor, and 
  116. NS87.EXE runs about five times slower than NS.EXE without a 
  117. coprocessor.
  118.  
  119. With one of the executable files (and the Borland graphics file 
  120. EGAVGA.BGI, included on the distribution disk) on the default drive, 
  121. at the DOS prompt, type NS or NS87, as appropriate, and press ENTER. 
  122. Within a short time, you should see a menu of eight possibilities, 
  123. each of which can be accessed by pressing the key corresponding to its 
  124. first letter. For example, to quit the program, press Q.
  125.  
  126. There are two types of data files used by NS.EXE or NS87.EXE: neuron 
  127. files, which provide descriptions of particular nervous system 
  128. designs, and environment files, which provide descriptions of 
  129. particular environment ("world") configurations and initial 
  130. conditions. Three sets of neuron and environment files are included: 
  131. WANDER.NEU and WANDER.ENV, EDGE3.NEU and EDGE3.ENV, and APP3.NEU and 
  132. APP3.ENV. You can recall these files, and you can save and recall new 
  133. neuron and environment files. 
  134.  
  135. To see the program in action, press R (for "Read files") and then, at 
  136. the prompt for a neuron file spec, key in WANDER.NEU and press ENTER. 
  137. At the prompt for an environment file spec, key in WANDER.ENV and 
  138. press ENTER. The current neuron and environment files appear at the 
  139. bottom of the menu screen. Now press S (for "Simulate"); you should 
  140. see an EGA-graphics-mode screen with a representation of a bug near 
  141. the lower left corner. To begin the simulation, press ENTER. The bug 
  142. will begin to move, and plots will be drawn at the right side of the 
  143. screen. Each of the plots except the bottom one shows the firing 
  144. frequency of a named neuron in the bug's nervous system (i.e., neuron 
  145. RBR) vs. (simulated, not real) time. The bottom plot shows the gait 
  146. pattern of the bug's legs -- a line means the foot is up (swing mode), 
  147. while no line means the foot is down (stance mode).
  148.  
  149. As shown at the bottom of the simulation screen, you can press SPACE 
  150. to enter single-stepping mode; each time you subsequently press SPACE, 
  151. another point will appear on each plot (corresponding to an increment 
  152. of 0.010 seconds of simulated time; actually, this increment 
  153. corresponds to two "internal" integration intervals, each 0.005 
  154. simulated seconds long). To return to continuous simulation, press 
  155. ENTER.
  156.  
  157. You can get back to the menu screen at any time by pressing Esc, but 
  158. don't do that just yet. First, note the "D:2" message at the bottom of 
  159. the screen. This means that the bug is being redrawn after every 
  160. second simulation step (that is, every 0.020 seconds of simulated 
  161. time). You can speed up the simulation a little by pressing D while in 
  162. the single-step mode, so that the message reads "D:4" (and the bug is 
  163. redrawn after every fourth simulation step, or every 0.040 seconds). 
  164. Subsequent presses of D result in redrawing of the bug every eighth 
  165. step, every 16th step, every 32nd step, every 64th step (giving a very 
  166. "jerky" bug, indeed!), and (back to) every second step. 
  167.  
  168. Also, you can inject current into one of the bug's neurons, provided 
  169. that a variable of that neuron is being plotted. When in the single-
  170. step mode, type N=I and then press ENTER, where the number N 
  171. designates the position (1=top, 5=bottom) of the plot for the current-
  172. injected neuron and I designates the injected current in nanoamps 
  173. (between 0.1 and 99.9, positive or negative). The injected current is 
  174. shown at the bottom right of the screen. For example, to inject -15 
  175. nanoamps into neuron RBL (with its frequency plot in position 3), type 
  176. 3=-15 and press ENTER. Then press SPACE for a single step or ENTER for 
  177. continuous simulation, with the current being injected.
  178.  
  179. The number between the "D:2" message and (when present) the indication 
  180. of injected current is the current energy of the bug. The maximum 
  181. energy is 999 units; during simulation, the energy decreases by one 
  182. unit after every eight steps (that is, after every 0.080 seconds of 
  183. simulated time); when the energy reaches zero units, "RIP" appears and 
  184. the simulation stops.
  185.  
  186. When the single-step mode is on, you can toggle (by pressing TAB) 
  187. between plots and a list of the names of the neurons (up to as many as 
  188. 120) in the nervous system, color-coded according to their firing 
  189. frequency (normalized between 0 and 1). Try it. In the single-step 
  190. mode, press TAB, then press SPACE or ENTER to see the neuron names. 
  191. The colors of the names will change as the simulation runs, according 
  192. to the color key at the bottom right. (Names of neurons with firing 
  193. frequency = 0 are shown in the same color as the "0" in the key; names 
  194. of neurons with firing frequency between 0 and 1/3 are shown in the 
  195. same color as the block between "0" and "1/3" in the key; names of 
  196. neurons with firing frequency between 1/3 and 2/3 are shown in the 
  197. same color as the block between "1/3" and "2/3" in the key; and names 
  198. of neurons with firing frequency between 2/3 and 1 are shown in the 
  199. same color as the block between "2/3" and "1" in the key.
  200.  
  201. When in the single-step mode, you can initiate recording of the 
  202. simulation by pressing a function key (F1 through F10). This causes an 
  203. animation data file to be written to disk as the simulation proceeds; 
  204. later, you can play back the simulation at higher speeds by using 
  205. NSPLAY.EXE. The animation data file is written to the default 
  206. directory unless you previously specified a recording path by pressing 
  207. "P" (for "Path specification for recording") while at the menu screen. 
  208. The name of the animation data file is "NSX.SAV" with X = 1, 2,..., or 
  209. 10, corresponding to the number of the function key pressed to 
  210. initiate recording. Note that there is no warning given about 
  211. overwriting an old file by a new one with the same name! Also note 
  212. that disk errors are handled via DOS -- if you must "abort," then the 
  213. program will terminate and you will be back at the DOS prompt! Once 
  214. recording has been initiated, a message appears at the bottom of the 
  215. screen: "RECORDING=X" (with X = 1, 2,..., or 10). To quit recording at 
  216. any time, press Esc. Other keys work as usual during simulation.
  217.  
  218. Now press Esc to return to the menu screen. Neuron and environment 
  219. files can be constructed, modified, and saved for later recall by 
  220. operations accessed via the menu.
  221.  
  222. Press W (for "Write files"). You are asked whether you want to write a 
  223. neuron file. Press Y (for "Yes"). Press N (for "No") when asked 
  224. whether you want to use the file spec WANDER.NEU. Then, in response to 
  225. the query for a neuron file name, type in TEST.NEU (we recommend using 
  226. the NEU extension for all neuron files) and press ENTER. Press "Y" 
  227. when asked whether you want to write an environment file, press "N" 
  228. when asked if you want to use the file spec WANDER.ENV, and then type 
  229. in TEST.ENV (we recommend using the ENV extension for all environment 
  230. files) and press ENTER. Note that TEST.NEU and TEST.ENV are now the 
  231. current files, as shown at the bottom of the screen. You are going to 
  232. modify these files.
  233.  
  234. Press N (for "Neuron modification"). When prompted for a neuron name, 
  235. press ? and then ENTER to see a listing of all neurons in the nervous 
  236. system specified by file TEST.NEU (which, at this point, is just a 
  237. duplicate of WANDER.NEU, with a different name). Now type LC (capital 
  238. letters, please; neuron names are case-sensitive) and press ENTER. 
  239. Near the top of the screen are several user-settable parameters for 
  240. neuron LC. Use the up and down arrow keys to move the cursor, then 
  241. type in new values. Move the cursor to the Gain value (1.00) and key 
  242. in 0.5, then press ENTER. Now the cursor is on the Intrinsic current 
  243. line; press ENTER to switch to NON-RANDOM, press ENTER again to 
  244. switch to RANDOM, and press ENTER a third time to switch back to NONE. 
  245. You see that there are three possibilities, or cases, for the 
  246. Intrinsic current. Each case is described in detail in Dr. Beer's 
  247. book. For the NON-RANDOM and RANDOM cases, you can specify several 
  248. parameter values. Sensory current function has seven cases, accessed 
  249. in turn by successively pressing ENTER. Similarly, Motor output type 
  250. has three cases. Now move the cursor to the Connections line and press 
  251. ENTER; a new screen appears, allowing specification of the neurons 
  252. which synapse on LC; synaptic connections can be DIRECT, or GATED or 
  253. MODULATED by a third neuron's synapse (see Dr. Beer's book for 
  254. details). Both direct and indirect current factors can be specified. 
  255. To delete a connection, move the cursor to the proper line and press 
  256. Control and D simultaneously. To return to the neuron parameters 
  257. screen, press Esc. You can alter the name of the neuron by editing the 
  258. top line (the "old" neuron is NOT deleted; this allows quick 
  259. duplication of neurons); you can delete the neuron by pressing Control 
  260. and D simultaneously. When you are done making modifications, press 
  261. Control and S simultaneously to save the modifications (otherwise they 
  262. will be lost!), then press Esc to return to the neuron name screen. At 
  263. the neuron name screen, you can key in another neuron name for 
  264. modification and press ENTER (remember, to see a list of all neurons, 
  265. press ? and then ENTER). And, by pressing Control and S 
  266. simultaneously, you can save the modified neuron file (you'll be 
  267. prompted for a file spec). Or you can press Esc to return to the menu 
  268. screen. Up to 200 neurons can be specified in a neuron file for use in 
  269. NS87.EXE; up to 150 neurons can be specified
  270.  
  271. At the menu screen, press E (for "Environment specification") to enter 
  272. the number of food patches, the coordinates of the centers of the food 
  273. patches, the sizes (in energy units) of the food patches, the number 
  274. of obstacle blocks, and the coordinates of the upper left corners of 
  275. the blocks. Press Esc before answering the final prompt to stop the 
  276. succession of prompts (retaining parameter values specified to that 
  277. point). 
  278.  
  279. At the menu screen, press I (for "Initialize conditions" -- although 
  280. this can be done in the middle of a simulation, if you want) to enter 
  281. the coordinates of the bug, the angle of the bug, and the energy of 
  282. the bug. Press Esc to stop the succession of prompts (retaining 
  283. parameter values specified to that point).
  284.  
  285. At the menu screen, press G (for "Graph specification") to set up the 
  286. plotted graphs (1=top through 5=bottom) at the right of the simulation 
  287. screen. You are prompted for the type (none, neuron variable, or gait 
  288. pattern) for each graph number. If you choose to plot a neuron 
  289. variable, then you are prompted for neuron name and variable type 
  290. (voltage, frequency, or current); if you choose to plot voltage or 
  291. current, you are prompted for the axis scale (in millivolts or 
  292. picoamps, respectively). Press Esc to stop the succession of prompts 
  293. (retaining parameter values specified to that point).
  294.  
  295. At the menu screen, press W (for "Write files") to save neuron and/or 
  296. environment files with the current parameter values.
  297.  
  298. III. SIMULATION FILES
  299.  
  300. The three sets of ready-to-run simulation files included with the 
  301. program can be modified as desired.
  302.  
  303. WANDER.NEU and WANDER.ENV: Wandering controller neural circuits only.
  304.  
  305. EDGE3.NEU and EDGE3.ENV: Wandering controller and edge-following 
  306. neural circuits only; obstacle blocks.
  307.  
  308. APP3.NEU and APP3.ENV: Wandering controller, edge-following, 
  309. appetitive, and consummatory neural circuits; obstacle blocks and food 
  310. patch.
  311.  
  312. IV. ANIMATION PLAYBACK PROGRAM
  313.  
  314. The program NSPLAY.EXE runs animation data files previously written 
  315. during simulations. Animation playback speeds can be much higher than 
  316. the speed of the original simulation in NS.EXE or NS87.EXE (for 
  317. example, faster than real-time on our 16MHz 386SX with no math 
  318. coprocessor). At the DOS prompt, with NSPLAY.EXE in the current 
  319. directory, type:
  320.  
  321.   NSPLAY [PATH, IF NECESSARY]NSX.SAV
  322.  
  323. (where X = 1, 2,..., or 3, corresponding to an existing animation data 
  324. file) and press ENTER.
  325.  
  326. The distribution disk includes the sample animation data file 
  327. NS10.SAV; with both NSPLAY.EXE and NS10.SAV in the default directory, 
  328. type:
  329.  
  330.   NSPLAY NS10.SAV
  331.  
  332. and press ENTER. Assuming that sufficient memory is available, the 
  333. animation file is read (use a RAM disk for highest speed!) and the 
  334. simulation screen appears. Press ENTER to begin the animation at the 
  335. highest possible speed. Press SPACE to single-step. In single-step 
  336. mode, press - (repeatedly if desired) to slow the animation; press + 
  337. (repeatedly if desired) to speed it up. When the recorded simulation 
  338. is complete, the animation file is read again and the process repeats. 
  339. Press Esc at any time to return to DOS. 
  340.  
  341. V. NEURON PRINT PROGRAM
  342.  
  343. NSPRINT.EXE prints out a listing of all the neurons (with parameters 
  344. and connections) in any neuron file. To run this utility, at the DOS 
  345. prompt type: 
  346.  
  347.   NSPRINT filename
  348.  
  349. and press ENTER. The filename includes the drive, path, and extension 
  350. if necessary. For example, you might type NSPRINT C:WANDER.NEU, then 
  351. press ENTER. Then follow instructions given by the program.
  352.