rubyneat 0.3.5.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. checksums.yaml +7 -0
  2. data/.directory +4 -0
  3. data/.gitignore.orig +20 -0
  4. data/.idea/.name +1 -0
  5. data/.idea/.rakeTasks +7 -0
  6. data/.idea/dictionaries/trader.xml +3 -0
  7. data/.idea/encodings.xml +5 -0
  8. data/.idea/misc.xml +5 -0
  9. data/.idea/modules.xml +9 -0
  10. data/.idea/rubyneat.iml +197 -0
  11. data/.idea/runConfigurations/invpend_neat.xml +26 -0
  12. data/.idea/runConfigurations/sigdebug_neat.xml +24 -0
  13. data/.idea/runConfigurations/xor_neat.xml +26 -0
  14. data/.idea/runConfigurations/xordebug_neat.xml +24 -0
  15. data/.idea/runConfigurations/xorsin_neat.xml +24 -0
  16. data/.idea/scopes/scope_settings.xml +5 -0
  17. data/.idea/vcs.xml +7 -0
  18. data/.idea/workspace.xml +1124 -0
  19. data/.semver +5 -0
  20. data/.yardoc/checksums +11 -0
  21. data/.yardoc/object_types +0 -0
  22. data/.yardoc/objects/root.dat +0 -0
  23. data/.yardoc/proxy_types +0 -0
  24. data/Gemfile +32 -0
  25. data/Gemfile.lock +135 -0
  26. data/Gemfile.lock.orig +147 -0
  27. data/Guardfile +8 -0
  28. data/Rakefile +61 -0
  29. data/bin/neat +83 -0
  30. data/config/application.rb +5 -0
  31. data/doc/ControllerPoint.html +125 -0
  32. data/doc/CuteA.html +286 -0
  33. data/doc/CuteB.html +297 -0
  34. data/doc/DSL.html +883 -0
  35. data/doc/NEAT/BasicNeuronTypes/BiasNeuron.html +518 -0
  36. data/doc/NEAT/BasicNeuronTypes/CosineNeuron.html +274 -0
  37. data/doc/NEAT/BasicNeuronTypes/InputNeuron.html +366 -0
  38. data/doc/NEAT/BasicNeuronTypes/SigmoidNeuron.html +275 -0
  39. data/doc/NEAT/BasicNeuronTypes/SineNeuron.html +274 -0
  40. data/doc/NEAT/BasicNeuronTypes/TanhNeuron.html +274 -0
  41. data/doc/NEAT/BasicNeuronTypes.html +136 -0
  42. data/doc/NEAT/Controller/NeatSettings.html +3985 -0
  43. data/doc/NEAT/Controller.html +2490 -0
  44. data/doc/NEAT/Critter/Genotype/Gene.html +979 -0
  45. data/doc/NEAT/Critter/Genotype.html +1601 -0
  46. data/doc/NEAT/Critter/Phenotype.html +603 -0
  47. data/doc/NEAT/Critter.html +1037 -0
  48. data/doc/NEAT/DSL.html +1255 -0
  49. data/doc/NEAT/Evaluator.html +420 -0
  50. data/doc/NEAT/Evolver/CritterOp.html +551 -0
  51. data/doc/NEAT/Evolver.html +602 -0
  52. data/doc/NEAT/Expressor.html +327 -0
  53. data/doc/NEAT/Graph/DependencyResolver.html +478 -0
  54. data/doc/NEAT/Graph/GraphException.html +123 -0
  55. data/doc/NEAT/Graph.html +402 -0
  56. data/doc/NEAT/NeatException.html +123 -0
  57. data/doc/NEAT/NeatOb.html +567 -0
  58. data/doc/NEAT/Neuron.html +1067 -0
  59. data/doc/NEAT/Operator.html +162 -0
  60. data/doc/NEAT/Population.html +1961 -0
  61. data/doc/NEAT/Trait.html +169 -0
  62. data/doc/NEAT.html +588 -0
  63. data/doc/_index.html +373 -0
  64. data/doc/class_list.html +54 -0
  65. data/doc/css/common.css +1 -0
  66. data/doc/css/full_list.css +57 -0
  67. data/doc/css/style.css +339 -0
  68. data/doc/file_list.html +53 -0
  69. data/doc/frames.html +26 -0
  70. data/doc/index.html +373 -0
  71. data/doc/js/app.js +219 -0
  72. data/doc/js/full_list.js +178 -0
  73. data/doc/js/jquery.js +4 -0
  74. data/doc/method_list.html +1415 -0
  75. data/doc/top-level-namespace.html +164 -0
  76. data/foo/foo_aquarium_example.rb +38 -0
  77. data/foo/foo_gosu.rb +99 -0
  78. data/foo/foo_rubygoo.rb +104 -0
  79. data/foo/foo_sdl.rb +34 -0
  80. data/foo/icon.png +0 -0
  81. data/lib/rubyneat/critter.rb +374 -0
  82. data/lib/rubyneat/default_neat.rb +10 -0
  83. data/lib/rubyneat/dsl.rb +130 -0
  84. data/lib/rubyneat/evaluator.rb +51 -0
  85. data/lib/rubyneat/evolver.rb +315 -0
  86. data/lib/rubyneat/expressor.rb +110 -0
  87. data/lib/rubyneat/graph.rb +95 -0
  88. data/lib/rubyneat/neuron.rb +152 -0
  89. data/lib/rubyneat/population.rb +227 -0
  90. data/lib/rubyneat/rubyneat.rb +429 -0
  91. data/lib/rubyneat.rb +8 -0
  92. data/neater/invpend_neat.rb +150 -0
  93. data/neater/rnlib/inverted_pendulum.rb +380 -0
  94. data/neater/rnlib/xor.rb +10 -0
  95. data/neater/sigdebug_neat.rb +136 -0
  96. data/neater/xor_neat.rb +137 -0
  97. data/neater/xoranalog_neat.rb +138 -0
  98. data/neater/xorsin_neat.rb +143 -0
  99. data/projectFilesBackup/.idea/rubyneat.iml +180 -0
  100. data/public/.directory +4 -0
  101. data/public/background.png +0 -0
  102. data/public/background.xcf +0 -0
  103. data/public/cart.png +0 -0
  104. data/public/cart.xcf +0 -0
  105. data/public/metalpoles_molton_ball_l.jpg +0 -0
  106. data/public/old_background.png +0 -0
  107. data/public/pointer.png +0 -0
  108. data/public/pointer.xcf +0 -0
  109. data/public/pole.kra +0 -0
  110. data/public/pole.png +0 -0
  111. data/public/pole.xcf +0 -0
  112. data/public/wheel-of-year-stone-DD-131-WOYS.jpg +0 -0
  113. data/public/wheel.png +0 -0
  114. data/public/wheel.xcf +0 -0
  115. data/public/wood-planks-texture.jpg +0 -0
  116. data/rdoc/ControllerPoint.html +116 -0
  117. data/rdoc/CuteA.html +177 -0
  118. data/rdoc/CuteB.html +178 -0
  119. data/rdoc/DSLSetup.html +177 -0
  120. data/rdoc/GameTestWindow.html +242 -0
  121. data/rdoc/GameWindow.html +292 -0
  122. data/rdoc/Gemfile.html +215 -0
  123. data/rdoc/Gemfile_lock.html +327 -0
  124. data/rdoc/GraphTest.html +210 -0
  125. data/rdoc/Guardfile.html +198 -0
  126. data/rdoc/InvertedPendulum/Cart.html +668 -0
  127. data/rdoc/InvertedPendulum/DSL.html +259 -0
  128. data/rdoc/InvertedPendulum/InvPendWindow.html +402 -0
  129. data/rdoc/InvertedPendulum.html +198 -0
  130. data/rdoc/Logger.html +98 -0
  131. data/rdoc/NEAT/BasicNeuronTypes/BiasNeuron.html +265 -0
  132. data/rdoc/NEAT/BasicNeuronTypes/CosineNeuron.html +162 -0
  133. data/rdoc/NEAT/BasicNeuronTypes/InputNeuron.html +206 -0
  134. data/rdoc/NEAT/BasicNeuronTypes/SigmoidNeuron.html +162 -0
  135. data/rdoc/NEAT/BasicNeuronTypes/SineNeuron.html +162 -0
  136. data/rdoc/NEAT/BasicNeuronTypes/TanhNeuron.html +161 -0
  137. data/rdoc/NEAT/BasicNeuronTypes.html +107 -0
  138. data/rdoc/NEAT/Controller/NeatSettings.html +880 -0
  139. data/rdoc/NEAT/Controller.html +729 -0
  140. data/rdoc/NEAT/Critter/Genotype/Gene.html +457 -0
  141. data/rdoc/NEAT/Critter/Genotype.html +735 -0
  142. data/rdoc/NEAT/Critter/Phenotype.html +330 -0
  143. data/rdoc/NEAT/Critter.html +489 -0
  144. data/rdoc/NEAT/DSL.html +729 -0
  145. data/rdoc/NEAT/Evaluator.html +256 -0
  146. data/rdoc/NEAT/Evolver/CritterOp.html +349 -0
  147. data/rdoc/NEAT/Evolver.html +891 -0
  148. data/rdoc/NEAT/Expressor.html +402 -0
  149. data/rdoc/NEAT/Graph/DependencyResolver.html +291 -0
  150. data/rdoc/NEAT/Graph/GraphException.html +105 -0
  151. data/rdoc/NEAT/Graph.html +263 -0
  152. data/rdoc/NEAT/NeatException.html +105 -0
  153. data/rdoc/NEAT/NeatOb.html +325 -0
  154. data/rdoc/NEAT/Neuron.html +481 -0
  155. data/rdoc/NEAT/Operator.html +109 -0
  156. data/rdoc/NEAT/Population.html +935 -0
  157. data/rdoc/NEAT/Trait.html +117 -0
  158. data/rdoc/NEAT.html +422 -0
  159. data/rdoc/Object.html +384 -0
  160. data/rdoc/Phi.html +98 -0
  161. data/rdoc/Player.html +383 -0
  162. data/rdoc/Rakefile.html +254 -0
  163. data/rdoc/RubyNEAT/Application.html +105 -0
  164. data/rdoc/RubyNEAT.html +98 -0
  165. data/rdoc/SDL/Event2.html +98 -0
  166. data/rdoc/SDL.html +98 -0
  167. data/rdoc/Vector.html +195 -0
  168. data/rdoc/created.rid +125 -0
  169. data/rdoc/doc/ControllerPoint_html.html +299 -0
  170. data/rdoc/doc/CuteA_html.html +438 -0
  171. data/rdoc/doc/CuteB_html.html +436 -0
  172. data/rdoc/doc/DSL_html.html +992 -0
  173. data/rdoc/doc/NEAT/BasicNeuronTypes/BiasNeuron_html.html +617 -0
  174. data/rdoc/doc/NEAT/BasicNeuronTypes/CosineNeuron_html.html +413 -0
  175. data/rdoc/doc/NEAT/BasicNeuronTypes/InputNeuron_html.html +498 -0
  176. data/rdoc/doc/NEAT/BasicNeuronTypes/SigmoidNeuron_html.html +413 -0
  177. data/rdoc/doc/NEAT/BasicNeuronTypes/SineNeuron_html.html +413 -0
  178. data/rdoc/doc/NEAT/BasicNeuronTypes/TanhNeuron_html.html +412 -0
  179. data/rdoc/doc/NEAT/BasicNeuronTypes_html.html +310 -0
  180. data/rdoc/doc/NEAT/Controller/NeatSettings_html.html +3324 -0
  181. data/rdoc/doc/NEAT/Controller_html.html +2212 -0
  182. data/rdoc/doc/NEAT/Critter/Genotype/Gene_html.html +997 -0
  183. data/rdoc/doc/NEAT/Critter/Genotype_html.html +1556 -0
  184. data/rdoc/doc/NEAT/Critter/Phenotype_html.html +687 -0
  185. data/rdoc/doc/NEAT/Critter_html.html +1037 -0
  186. data/rdoc/doc/NEAT/DSL_html.html +1349 -0
  187. data/rdoc/doc/NEAT/Evaluator_html.html +556 -0
  188. data/rdoc/doc/NEAT/Evolver/CritterOp_html.html +690 -0
  189. data/rdoc/doc/NEAT/Evolver_html.html +677 -0
  190. data/rdoc/doc/NEAT/Expressor_html.html +468 -0
  191. data/rdoc/doc/NEAT/Graph/DependencyResolver_html.html +598 -0
  192. data/rdoc/doc/NEAT/Graph/GraphException_html.html +299 -0
  193. data/rdoc/doc/NEAT/Graph_html.html +527 -0
  194. data/rdoc/doc/NEAT/NeatException_html.html +299 -0
  195. data/rdoc/doc/NEAT/NeatOb_html.html +671 -0
  196. data/rdoc/doc/NEAT/Neuron_html.html +1095 -0
  197. data/rdoc/doc/NEAT/Operator_html.html +337 -0
  198. data/rdoc/doc/NEAT/Population_html.html +1795 -0
  199. data/rdoc/doc/NEAT/Trait_html.html +344 -0
  200. data/rdoc/doc/NEAT_html.html +736 -0
  201. data/rdoc/doc/_index_html.html +559 -0
  202. data/rdoc/doc/class_list_html.html +369 -0
  203. data/rdoc/doc/css/common_css.html +188 -0
  204. data/rdoc/doc/css/full_list_css.html +243 -0
  205. data/rdoc/doc/css/style_css.html +530 -0
  206. data/rdoc/doc/file_list_html.html +240 -0
  207. data/rdoc/doc/frames_html.html +217 -0
  208. data/rdoc/doc/index_html.html +559 -0
  209. data/rdoc/doc/js/app_js.html +423 -0
  210. data/rdoc/doc/js/full_list_js.html +372 -0
  211. data/rdoc/doc/js/jquery_js.html +1536 -0
  212. data/rdoc/doc/method_list_html.html +1375 -0
  213. data/rdoc/doc/top-level-namespace_html.html +317 -0
  214. data/rdoc/fonts/Lato-Light.ttf +0 -0
  215. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  216. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  217. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  218. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  219. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  220. data/rdoc/fonts.css +167 -0
  221. data/rdoc/images/add.png +0 -0
  222. data/rdoc/images/arrow_up.png +0 -0
  223. data/rdoc/images/brick.png +0 -0
  224. data/rdoc/images/brick_link.png +0 -0
  225. data/rdoc/images/bug.png +0 -0
  226. data/rdoc/images/bullet_black.png +0 -0
  227. data/rdoc/images/bullet_toggle_minus.png +0 -0
  228. data/rdoc/images/bullet_toggle_plus.png +0 -0
  229. data/rdoc/images/date.png +0 -0
  230. data/rdoc/images/delete.png +0 -0
  231. data/rdoc/images/find.png +0 -0
  232. data/rdoc/images/loadingAnimation.gif +0 -0
  233. data/rdoc/images/macFFBgHack.png +0 -0
  234. data/rdoc/images/package.png +0 -0
  235. data/rdoc/images/page_green.png +0 -0
  236. data/rdoc/images/page_white_text.png +0 -0
  237. data/rdoc/images/page_white_width.png +0 -0
  238. data/rdoc/images/plugin.png +0 -0
  239. data/rdoc/images/ruby.png +0 -0
  240. data/rdoc/images/tag_blue.png +0 -0
  241. data/rdoc/images/tag_green.png +0 -0
  242. data/rdoc/images/transparent.png +0 -0
  243. data/rdoc/images/wrench.png +0 -0
  244. data/rdoc/images/wrench_orange.png +0 -0
  245. data/rdoc/images/zoom.png +0 -0
  246. data/rdoc/index.html +282 -0
  247. data/rdoc/js/darkfish.js +140 -0
  248. data/rdoc/js/jquery.js +18 -0
  249. data/rdoc/js/navigation.js +142 -0
  250. data/rdoc/js/search.js +109 -0
  251. data/rdoc/js/search_index.js +1 -0
  252. data/rdoc/js/searcher.js +228 -0
  253. data/rdoc/rdoc.css +580 -0
  254. data/rdoc/rubyneat_gemspec.html +387 -0
  255. data/rdoc/table_of_contents.html +2502 -0
  256. data/rdoc/xordebug_log.html +170598 -0
  257. data/rdoc/xorsin_log.html +22569 -0
  258. data/rubyneat.gemspec +347 -0
  259. data/rubyneat.gemspec.orig +375 -0
  260. data/spec/lib/rubyneat/rubyneat_spec.rb +132 -0
  261. metadata +555 -0
@@ -0,0 +1,1601 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: NEAT::Critter::Genotype
8
+
9
+ &mdash; Documentation by YARD 0.8.7.4
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!NEAT/Critter/Genotype.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (G)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../NEAT.html" title="NEAT (module)">NEAT</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Critter.html" title="NEAT::Critter (class)">Critter</a></span></span>
36
+ &raquo;
37
+ <span class="title">Genotype</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: NEAT::Critter::Genotype
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next"><span class='object_link'><a href="../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></li>
82
+
83
+ <li class="next">NEAT::Critter::Genotype</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+ <dt class="r2 last">Defined in:</dt>
99
+ <dd class="r2 last">lib/rubyneat/critter.rb</dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <h1 id="label-Genotype+part+of+the+Critter">Genotype part of the Critter</h1>
108
+
109
+ <p>List of connections, basically.</p>
110
+
111
+ <p>Also, basic phentypic expression (which may be overriden by the expressor)</p>
112
+
113
+ <h1 id="label-Notes">Notes</h1>
114
+
115
+ <p>Currently, all lists of neurons and genes are Hashes. The neurons are
116
+ indexed by their own names, and the genes are indexed by their innovation
117
+ numbers.</p>
118
+
119
+
120
+ </div>
121
+ </div>
122
+ <div class="tags">
123
+
124
+
125
+ </div><h2>Defined Under Namespace</h2>
126
+ <p class="children">
127
+
128
+
129
+
130
+
131
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Genotype/Gene.html" title="NEAT::Critter::Genotype::Gene (class)">Gene</a></span>
132
+
133
+
134
+ </p>
135
+
136
+
137
+
138
+
139
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
140
+ <ul class="summary">
141
+
142
+ <li class="public ">
143
+ <span class="summary_signature">
144
+
145
+ <a href="#critter-instance_method" title="#critter (instance method)">- (Object) <strong>critter</strong> </a>
146
+
147
+
148
+
149
+ </span>
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+ <span class="summary_desc"><div class='inline'>
163
+ <p>Critter to which we belong.</p>
164
+ </div></span>
165
+
166
+ </li>
167
+
168
+
169
+ <li class="public ">
170
+ <span class="summary_signature">
171
+
172
+ <a href="#dangling_neurons-instance_method" title="#dangling_neurons (instance method)">- (Object) <strong>dangling_neurons</strong> </a>
173
+
174
+
175
+
176
+ (also: #dangling_neurons?)
177
+
178
+ </span>
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ <span class="summary_desc"><div class='inline'>
192
+ <p>This will be set to true if there are dangling neurons.</p>
193
+ </div></span>
194
+
195
+ </li>
196
+
197
+
198
+ <li class="public ">
199
+ <span class="summary_signature">
200
+
201
+ <a href="#genes-instance_method" title="#genes (instance method)">- (Object) <strong>genes</strong> </a>
202
+
203
+
204
+
205
+ </span>
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+ <span class="summary_desc"><div class='inline'>
219
+ <p>Genes keyed by innovation numbers.</p>
220
+ </div></span>
221
+
222
+ </li>
223
+
224
+
225
+ <li class="public ">
226
+ <span class="summary_signature">
227
+
228
+ <a href="#neural_gene_map-instance_method" title="#neural_gene_map (instance method)">- (Object) <strong>neural_gene_map</strong> </a>
229
+
230
+
231
+
232
+ </span>
233
+
234
+
235
+
236
+
237
+ <span class="note title readonly">readonly</span>
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'>
248
+ <p>Map neurons to the genes that marks them as output { oneu_name =&gt; [
249
+ gene_1, gene_2,… gene_n], …} Just take the in_neuron name and the weight to
250
+ do the call to that neuron function with the appropriate weights.</p>
251
+ </div></span>
252
+
253
+ </li>
254
+
255
+
256
+ <li class="public ">
257
+ <span class="summary_signature">
258
+
259
+ <a href="#neural_inputs-instance_method" title="#neural_inputs (instance method)">- (Object) <strong>neural_inputs</strong> </a>
260
+
261
+
262
+
263
+ </span>
264
+
265
+
266
+
267
+
268
+ <span class="note title readonly">readonly</span>
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+ <span class="summary_desc"><div class='inline'>
279
+ <p>Instantiations of neural inputs and outputs.</p>
280
+ </div></span>
281
+
282
+ </li>
283
+
284
+
285
+ <li class="public ">
286
+ <span class="summary_signature">
287
+
288
+ <a href="#neural_outputs-instance_method" title="#neural_outputs (instance method)">- (Object) <strong>neural_outputs</strong> </a>
289
+
290
+
291
+
292
+ </span>
293
+
294
+
295
+
296
+
297
+ <span class="note title readonly">readonly</span>
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+ <span class="summary_desc"><div class='inline'>
308
+ <p>Instantiations of neural inputs and outputs.</p>
309
+ </div></span>
310
+
311
+ </li>
312
+
313
+
314
+ <li class="public ">
315
+ <span class="summary_signature">
316
+
317
+ <a href="#neurons-instance_method" title="#neurons (instance method)">- (Object) <strong>neurons</strong> </a>
318
+
319
+
320
+
321
+ </span>
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'>
335
+ <p>List of neurons hashed by name.</p>
336
+ </div></span>
337
+
338
+ </li>
339
+
340
+
341
+ </ul>
342
+
343
+
344
+
345
+
346
+
347
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3>
348
+ <p class="inherited"><span class='object_link'><a href="../NeatOb.html#controller-instance_method" title="NEAT::NeatOb#controller (method)">#controller</a></span>, <span class='object_link'><a href="../NeatOb.html#name-instance_method" title="NEAT::NeatOb#name (method)">#name</a></span></p>
349
+
350
+
351
+
352
+ <h2>
353
+ Instance Method Summary
354
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
355
+ </h2>
356
+
357
+ <ul class="summary">
358
+
359
+ <li class="public ">
360
+ <span class="summary_signature">
361
+
362
+ <a href="#add_genes-instance_method" title="#add_genes (instance method)">- (Object) <strong>add_genes</strong>(*genes) </a>
363
+
364
+
365
+
366
+ </span>
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ <span class="summary_desc"><div class='inline'>
377
+ <p>Genes added here MUST correspond to pre-existing neurons.</p>
378
+ </div></span>
379
+
380
+ </li>
381
+
382
+
383
+ <li class="public ">
384
+ <span class="summary_signature">
385
+
386
+ <a href="#add_neurons-instance_method" title="#add_neurons (instance method)">- (Object) <strong>add_neurons</strong>(*neus) </a>
387
+
388
+
389
+
390
+ </span>
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+ <span class="summary_desc"><div class='inline'>
401
+ <p>Add new neurons to the fold.</p>
402
+ </div></span>
403
+
404
+ </li>
405
+
406
+
407
+ <li class="public ">
408
+ <span class="summary_signature">
409
+
410
+ <a href="#dump_s-instance_method" title="#dump_s (instance method)">- (Object) <strong>dump_s</strong> </a>
411
+
412
+
413
+
414
+ </span>
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+ <span class="summary_desc"><div class='inline'></div></span>
425
+
426
+ </li>
427
+
428
+
429
+ <li class="public ">
430
+ <span class="summary_signature">
431
+
432
+ <a href="#fitness_cost-instance_method" title="#fitness_cost (instance method)">- (Object) <strong>fitness_cost</strong> </a>
433
+
434
+
435
+
436
+ </span>
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+ <span class="summary_desc"><div class='inline'>
447
+ <p>Calculate the cost of this genotype.</p>
448
+ </div></span>
449
+
450
+ </li>
451
+
452
+
453
+ <li class="public ">
454
+ <span class="summary_signature">
455
+
456
+ <a href="#forget%21-instance_method" title="#forget! (instance method)">- (Object) <strong>forget!</strong> </a>
457
+
458
+
459
+
460
+ </span>
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+ <span class="summary_desc"><div class='inline'>
471
+ <p>Make the neurons forget their wiring.</p>
472
+ </div></span>
473
+
474
+ </li>
475
+
476
+
477
+ <li class="public ">
478
+ <span class="summary_signature">
479
+
480
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Genotype) <strong>initialize</strong>(critter, mating = false, &amp;block) </a>
481
+
482
+
483
+
484
+ </span>
485
+
486
+
487
+ <span class="note title constructor">constructor</span>
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+ <span class="summary_desc"><div class='inline'>
497
+ <p>A new instance of Genotype.</p>
498
+ </div></span>
499
+
500
+ </li>
501
+
502
+
503
+ <li class="public ">
504
+ <span class="summary_signature">
505
+
506
+ <a href="#innervate%21-instance_method" title="#innervate! (instance method)">- (Object) <strong>innervate!</strong>(*hneus) </a>
507
+
508
+
509
+
510
+ </span>
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+ <span class="summary_desc"><div class='inline'>
521
+ <p>We take the neural hashes (presumably from other neurons), and innervate
522
+ them.</p>
523
+ </div></span>
524
+
525
+ </li>
526
+
527
+
528
+ <li class="public ">
529
+ <span class="summary_signature">
530
+
531
+ <a href="#neucleate-instance_method" title="#neucleate (instance method)">- (Object) <strong>neucleate</strong>(clean: true, &amp;block) </a>
532
+
533
+
534
+
535
+ </span>
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+ <span class="summary_desc"><div class='inline'>
546
+ <p>We add genes given here to the genome.</p>
547
+ </div></span>
548
+
549
+ </li>
550
+
551
+
552
+ <li class="public ">
553
+ <span class="summary_signature">
554
+
555
+ <a href="#nuke_redundancies%21-instance_method" title="#nuke_redundancies! (instance method)">- (Object) <strong>nuke_redundancies!</strong> </a>
556
+
557
+
558
+
559
+ </span>
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+ <span class="summary_desc"><div class='inline'>
570
+ <p>Remove any redundancies in the genome, any genes refering to the same two
571
+ neurons.</p>
572
+ </div></span>
573
+
574
+ </li>
575
+
576
+
577
+ <li class="public ">
578
+ <span class="summary_signature">
579
+
580
+ <a href="#prune%21-instance_method" title="#prune! (instance method)">- (Object) <strong>prune!</strong> </a>
581
+
582
+
583
+
584
+ </span>
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+ <span class="summary_desc"><div class='inline'>
595
+ <p>Go through the list of neurons and drop any neurons not referenced by the
596
+ genes.</p>
597
+ </div></span>
598
+
599
+ </li>
600
+
601
+
602
+ <li class="public ">
603
+ <span class="summary_signature">
604
+
605
+ <a href="#wire%21-instance_method" title="#wire! (instance method)">- (Object) <strong>wire!</strong> </a>
606
+
607
+
608
+
609
+ </span>
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+ <span class="summary_desc"><div class='inline'>
620
+ <p>Wire up the neurons based on the genes.</p>
621
+ </div></span>
622
+
623
+ </li>
624
+
625
+
626
+ </ul>
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3>
639
+ <p class="inherited"><span class='object_link'><a href="../NeatOb.html#log-instance_method" title="NEAT::NeatOb#log (method)">#log</a></span>, <span class='object_link'><a href="../NeatOb.html#log-class_method" title="NEAT::NeatOb.log (method)">log</a></span>, <span class='object_link'><a href="../NeatOb.html#to_s-instance_method" title="NEAT::NeatOb#to_s (method)">#to_s</a></span></p>
640
+
641
+ <div id="constructor_details" class="method_details_list">
642
+ <h2>Constructor Details</h2>
643
+
644
+ <div class="method_details first">
645
+ <h3 class="signature first" id="initialize-instance_method">
646
+
647
+ - (<tt><span class='object_link'><a href="" title="NEAT::Critter::Genotype (class)">Genotype</a></span></tt>) <strong>initialize</strong>(critter, mating = false, &amp;block)
648
+
649
+
650
+
651
+
652
+
653
+ </h3><div class="docstring">
654
+ <div class="discussion">
655
+
656
+ <p>Returns a new instance of Genotype</p>
657
+
658
+
659
+ </div>
660
+ </div>
661
+ <div class="tags">
662
+
663
+
664
+ </div><table class="source_code">
665
+ <tr>
666
+ <td>
667
+ <pre class="lines">
668
+
669
+
670
+ 88
671
+ 89
672
+ 90
673
+ 91
674
+ 92
675
+ 93
676
+ 94
677
+ 95
678
+ 96
679
+ 97
680
+ 98
681
+ 99
682
+ 100
683
+ 101
684
+ 102
685
+ 103
686
+ 104
687
+ 105
688
+ 106</pre>
689
+ </td>
690
+ <td>
691
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 88</span>
692
+
693
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_critter'>critter</span><span class='comma'>,</span> <span class='id identifier rubyid_mating'>mating</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
694
+ <span class='kw'>super</span> <span class='id identifier rubyid_critter'>critter</span><span class='period'>.</span><span class='id identifier rubyid_controller'>controller</span>
695
+ <span class='ivar'>@critter</span> <span class='op'>=</span> <span class='id identifier rubyid_critter'>critter</span>
696
+
697
+ <span class='comment'># Initialize basic structures
698
+ </span> <span class='ivar'>@genes</span> <span class='op'>=</span> <span class='kw'>nil</span>
699
+ <span class='ivar'>@neural_inputs</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@critter</span><span class='period'>.</span><span class='id identifier rubyid_population'>population</span><span class='period'>.</span><span class='id identifier rubyid_input_neurons'>input_neurons</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_sym'>sym</span><span class='comma'>,</span> <span class='id identifier rubyid_ineu'>ineu</span><span class='op'>|</span>
700
+ <span class='lbracket'>[</span><span class='id identifier rubyid_sym'>sym</span><span class='comma'>,</span> <span class='id identifier rubyid_ineu'>ineu</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@controller</span><span class='comma'>,</span> <span class='id identifier rubyid_sym'>sym</span><span class='rparen'>)</span><span class='rbracket'>]</span>
701
+ <span class='rbrace'>}</span><span class='rbracket'>]</span>
702
+
703
+ <span class='ivar'>@neural_outputs</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@critter</span><span class='period'>.</span><span class='id identifier rubyid_population'>population</span><span class='period'>.</span><span class='id identifier rubyid_output_neurons'>output_neurons</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_sym'>sym</span><span class='comma'>,</span> <span class='id identifier rubyid_ineu'>ineu</span><span class='op'>|</span>
704
+ <span class='lbracket'>[</span><span class='id identifier rubyid_sym'>sym</span><span class='comma'>,</span> <span class='id identifier rubyid_ineu'>ineu</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@controller</span><span class='comma'>,</span> <span class='id identifier rubyid_sym'>sym</span><span class='rparen'>)</span><span class='rbracket'>]</span>
705
+ <span class='rbrace'>}</span><span class='rbracket'>]</span>
706
+ <span class='ivar'>@neurons</span> <span class='op'>=</span> <span class='ivar'>@neural_inputs</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span> <span class='comment'># this must be a shallow clone!
707
+ </span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span> <span class='ivar'>@neural_outputs</span>
708
+
709
+ <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_evolver'>evolver</span><span class='period'>.</span><span class='id identifier rubyid_gen_initial_genes!'>gen_initial_genes!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_mating'>mating</span>
710
+ <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
711
+ <span class='kw'>end</span></pre>
712
+ </td>
713
+ </tr>
714
+ </table>
715
+ </div>
716
+
717
+ </div>
718
+
719
+ <div id="instance_attr_details" class="attr_details">
720
+ <h2>Instance Attribute Details</h2>
721
+
722
+
723
+ <span id="critter=-instance_method"></span>
724
+ <div class="method_details first">
725
+ <h3 class="signature first" id="critter-instance_method">
726
+
727
+ - (<tt>Object</tt>) <strong>critter</strong>
728
+
729
+
730
+
731
+
732
+
733
+ </h3><div class="docstring">
734
+ <div class="discussion">
735
+
736
+ <p>Critter to which we belong</p>
737
+
738
+
739
+ </div>
740
+ </div>
741
+ <div class="tags">
742
+
743
+
744
+ </div><table class="source_code">
745
+ <tr>
746
+ <td>
747
+ <pre class="lines">
748
+
749
+
750
+ 67
751
+ 68
752
+ 69</pre>
753
+ </td>
754
+ <td>
755
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 67</span>
756
+
757
+ <span class='kw'>def</span> <span class='id identifier rubyid_critter'>critter</span>
758
+ <span class='ivar'>@critter</span>
759
+ <span class='kw'>end</span></pre>
760
+ </td>
761
+ </tr>
762
+ </table>
763
+ </div>
764
+
765
+
766
+ <span id="dangling_neurons=-instance_method"></span>
767
+ <div class="method_details ">
768
+ <h3 class="signature " id="dangling_neurons-instance_method">
769
+
770
+ - (<tt>Object</tt>) <strong>dangling_neurons</strong>
771
+
772
+
773
+
774
+ <span class="aliases">Also known as:
775
+ <span class="names"><span id='dangling_neurons?-instance_method'>dangling_neurons?</span></span>
776
+ </span>
777
+
778
+
779
+
780
+ </h3><div class="docstring">
781
+ <div class="discussion">
782
+
783
+ <p>This will be set to true if there are dangling neurons.</p>
784
+
785
+
786
+ </div>
787
+ </div>
788
+ <div class="tags">
789
+
790
+
791
+ </div><table class="source_code">
792
+ <tr>
793
+ <td>
794
+ <pre class="lines">
795
+
796
+
797
+ 79
798
+ 80
799
+ 81</pre>
800
+ </td>
801
+ <td>
802
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 79</span>
803
+
804
+ <span class='kw'>def</span> <span class='id identifier rubyid_dangling_neurons'>dangling_neurons</span>
805
+ <span class='ivar'>@dangling_neurons</span>
806
+ <span class='kw'>end</span></pre>
807
+ </td>
808
+ </tr>
809
+ </table>
810
+ </div>
811
+
812
+
813
+ <span id="genes=-instance_method"></span>
814
+ <div class="method_details ">
815
+ <h3 class="signature " id="genes-instance_method">
816
+
817
+ - (<tt>Object</tt>) <strong>genes</strong>
818
+
819
+
820
+
821
+
822
+
823
+ </h3><div class="docstring">
824
+ <div class="discussion">
825
+
826
+ <p>Genes keyed by innovation numbers</p>
827
+
828
+
829
+ </div>
830
+ </div>
831
+ <div class="tags">
832
+
833
+
834
+ </div><table class="source_code">
835
+ <tr>
836
+ <td>
837
+ <pre class="lines">
838
+
839
+
840
+ 70
841
+ 71
842
+ 72</pre>
843
+ </td>
844
+ <td>
845
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 70</span>
846
+
847
+ <span class='kw'>def</span> <span class='id identifier rubyid_genes'>genes</span>
848
+ <span class='ivar'>@genes</span>
849
+ <span class='kw'>end</span></pre>
850
+ </td>
851
+ </tr>
852
+ </table>
853
+ </div>
854
+
855
+
856
+ <span id=""></span>
857
+ <div class="method_details ">
858
+ <h3 class="signature " id="neural_gene_map-instance_method">
859
+
860
+ - (<tt>Object</tt>) <strong>neural_gene_map</strong> <span class="extras">(readonly)</span>
861
+
862
+
863
+
864
+
865
+
866
+ </h3><div class="docstring">
867
+ <div class="discussion">
868
+
869
+ <p>Map neurons to the genes that marks them as output { oneu_name =&gt; [
870
+ gene_1, gene_2,… gene_n], …} Just take the in_neuron name and the weight to
871
+ do the call to that neuron function with the appropriate weights</p>
872
+
873
+
874
+ </div>
875
+ </div>
876
+ <div class="tags">
877
+
878
+
879
+ </div><table class="source_code">
880
+ <tr>
881
+ <td>
882
+ <pre class="lines">
883
+
884
+
885
+ 86
886
+ 87
887
+ 88</pre>
888
+ </td>
889
+ <td>
890
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 86</span>
891
+
892
+ <span class='kw'>def</span> <span class='id identifier rubyid_neural_gene_map'>neural_gene_map</span>
893
+ <span class='ivar'>@neural_gene_map</span>
894
+ <span class='kw'>end</span></pre>
895
+ </td>
896
+ </tr>
897
+ </table>
898
+ </div>
899
+
900
+
901
+ <span id=""></span>
902
+ <div class="method_details ">
903
+ <h3 class="signature " id="neural_inputs-instance_method">
904
+
905
+ - (<tt>Object</tt>) <strong>neural_inputs</strong> <span class="extras">(readonly)</span>
906
+
907
+
908
+
909
+
910
+
911
+ </h3><div class="docstring">
912
+ <div class="discussion">
913
+
914
+ <p>Instantiations of neural inputs and outputs</p>
915
+
916
+
917
+ </div>
918
+ </div>
919
+ <div class="tags">
920
+
921
+
922
+ </div><table class="source_code">
923
+ <tr>
924
+ <td>
925
+ <pre class="lines">
926
+
927
+
928
+ 76
929
+ 77
930
+ 78</pre>
931
+ </td>
932
+ <td>
933
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 76</span>
934
+
935
+ <span class='kw'>def</span> <span class='id identifier rubyid_neural_inputs'>neural_inputs</span>
936
+ <span class='ivar'>@neural_inputs</span>
937
+ <span class='kw'>end</span></pre>
938
+ </td>
939
+ </tr>
940
+ </table>
941
+ </div>
942
+
943
+
944
+ <span id=""></span>
945
+ <div class="method_details ">
946
+ <h3 class="signature " id="neural_outputs-instance_method">
947
+
948
+ - (<tt>Object</tt>) <strong>neural_outputs</strong> <span class="extras">(readonly)</span>
949
+
950
+
951
+
952
+
953
+
954
+ </h3><div class="docstring">
955
+ <div class="discussion">
956
+
957
+ <p>Instantiations of neural inputs and outputs</p>
958
+
959
+
960
+ </div>
961
+ </div>
962
+ <div class="tags">
963
+
964
+
965
+ </div><table class="source_code">
966
+ <tr>
967
+ <td>
968
+ <pre class="lines">
969
+
970
+
971
+ 76
972
+ 77
973
+ 78</pre>
974
+ </td>
975
+ <td>
976
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 76</span>
977
+
978
+ <span class='kw'>def</span> <span class='id identifier rubyid_neural_outputs'>neural_outputs</span>
979
+ <span class='ivar'>@neural_outputs</span>
980
+ <span class='kw'>end</span></pre>
981
+ </td>
982
+ </tr>
983
+ </table>
984
+ </div>
985
+
986
+
987
+ <span id="neurons=-instance_method"></span>
988
+ <div class="method_details ">
989
+ <h3 class="signature " id="neurons-instance_method">
990
+
991
+ - (<tt>Object</tt>) <strong>neurons</strong>
992
+
993
+
994
+
995
+
996
+
997
+ </h3><div class="docstring">
998
+ <div class="discussion">
999
+
1000
+ <p>List of neurons hashed by name</p>
1001
+
1002
+
1003
+ </div>
1004
+ </div>
1005
+ <div class="tags">
1006
+
1007
+
1008
+ </div><table class="source_code">
1009
+ <tr>
1010
+ <td>
1011
+ <pre class="lines">
1012
+
1013
+
1014
+ 73
1015
+ 74
1016
+ 75</pre>
1017
+ </td>
1018
+ <td>
1019
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 73</span>
1020
+
1021
+ <span class='kw'>def</span> <span class='id identifier rubyid_neurons'>neurons</span>
1022
+ <span class='ivar'>@neurons</span>
1023
+ <span class='kw'>end</span></pre>
1024
+ </td>
1025
+ </tr>
1026
+ </table>
1027
+ </div>
1028
+
1029
+ </div>
1030
+
1031
+
1032
+ <div id="instance_method_details" class="method_details_list">
1033
+ <h2>Instance Method Details</h2>
1034
+
1035
+
1036
+ <div class="method_details first">
1037
+ <h3 class="signature first" id="add_genes-instance_method">
1038
+
1039
+ - (<tt>Object</tt>) <strong>add_genes</strong>(*genes)
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+ </h3><div class="docstring">
1046
+ <div class="discussion">
1047
+
1048
+ <p>Genes added here MUST correspond to pre-existing neurons. Be sure to do
1049
+ add_neurons first!!!!</p>
1050
+
1051
+
1052
+ </div>
1053
+ </div>
1054
+ <div class="tags">
1055
+
1056
+
1057
+ </div><table class="source_code">
1058
+ <tr>
1059
+ <td>
1060
+ <pre class="lines">
1061
+
1062
+
1063
+ 163
1064
+ 164
1065
+ 165
1066
+ 166
1067
+ 167
1068
+ 168
1069
+ 169</pre>
1070
+ </td>
1071
+ <td>
1072
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 163</span>
1073
+
1074
+ <span class='kw'>def</span> <span class='id identifier rubyid_add_genes'>add_genes</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_genes'>genes</span><span class='rparen'>)</span>
1075
+ <span class='id identifier rubyid_genes'>genes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_gene'>gene</span><span class='op'>|</span>
1076
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NeatException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Neuron </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span><span class='embexpr_end'>}</span><span class='tstring_content'> missing</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span> <span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span>
1077
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NeatException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Neuron </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='embexpr_end'>}</span><span class='tstring_content'> missing</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span> <span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span>
1078
+ <span class='ivar'>@genes</span><span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_innovation'>innovation</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_gene'>gene</span>
1079
+ <span class='kw'>end</span>
1080
+ <span class='kw'>end</span></pre>
1081
+ </td>
1082
+ </tr>
1083
+ </table>
1084
+ </div>
1085
+
1086
+ <div class="method_details ">
1087
+ <h3 class="signature " id="add_neurons-instance_method">
1088
+
1089
+ - (<tt>Object</tt>) <strong>add_neurons</strong>(*neus)
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+ </h3><div class="docstring">
1096
+ <div class="discussion">
1097
+
1098
+ <p>Add new neurons to the fold</p>
1099
+
1100
+
1101
+ </div>
1102
+ </div>
1103
+ <div class="tags">
1104
+
1105
+
1106
+ </div><table class="source_code">
1107
+ <tr>
1108
+ <td>
1109
+ <pre class="lines">
1110
+
1111
+
1112
+ 155
1113
+ 156
1114
+ 157
1115
+ 158
1116
+ 159</pre>
1117
+ </td>
1118
+ <td>
1119
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 155</span>
1120
+
1121
+ <span class='kw'>def</span> <span class='id identifier rubyid_add_neurons'>add_neurons</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_neus'>neus</span><span class='rparen'>)</span>
1122
+ <span class='id identifier rubyid_neus'>neus</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_neu'>neu</span><span class='op'>|</span>
1123
+ <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_neu'>neu</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_neu'>neu</span>
1124
+ <span class='kw'>end</span>
1125
+ <span class='kw'>end</span></pre>
1126
+ </td>
1127
+ </tr>
1128
+ </table>
1129
+ </div>
1130
+
1131
+ <div class="method_details ">
1132
+ <h3 class="signature " id="dump_s-instance_method">
1133
+
1134
+ - (<tt>Object</tt>) <strong>dump_s</strong>
1135
+
1136
+
1137
+
1138
+
1139
+
1140
+ </h3><table class="source_code">
1141
+ <tr>
1142
+ <td>
1143
+ <pre class="lines">
1144
+
1145
+
1146
+ 218
1147
+ 219
1148
+ 220
1149
+ 221
1150
+ 222</pre>
1151
+ </td>
1152
+ <td>
1153
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 218</span>
1154
+
1155
+ <span class='kw'>def</span> <span class='id identifier rubyid_dump_s'>dump_s</span>
1156
+ <span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\ngenes:\n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_gene'>gene</span><span class='op'>|</span>
1157
+ <span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\nneurons:\n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_neu'>neu</span><span class='op'>|</span>
1158
+ <span class='id identifier rubyid_neu'>neu</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1159
+ <span class='kw'>end</span></pre>
1160
+ </td>
1161
+ </tr>
1162
+ </table>
1163
+ </div>
1164
+
1165
+ <div class="method_details ">
1166
+ <h3 class="signature " id="fitness_cost-instance_method">
1167
+
1168
+ - (<tt>Object</tt>) <strong>fitness_cost</strong>
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+ </h3><div class="docstring">
1175
+ <div class="discussion">
1176
+
1177
+ <p>Calculate the cost of this genotype.</p>
1178
+
1179
+
1180
+ </div>
1181
+ </div>
1182
+ <div class="tags">
1183
+
1184
+
1185
+ </div><table class="source_code">
1186
+ <tr>
1187
+ <td>
1188
+ <pre class="lines">
1189
+
1190
+
1191
+ 213
1192
+ 214
1193
+ 215
1194
+ 216</pre>
1195
+ </td>
1196
+ <td>
1197
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 213</span>
1198
+
1199
+ <span class='kw'>def</span> <span class='id identifier rubyid_fitness_cost'>fitness_cost</span>
1200
+ <span class='id identifier rubyid_p'>p</span> <span class='op'>=</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span>
1201
+ <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_fitness_cost_per_neuron'>fitness_cost_per_neuron</span> <span class='op'>*</span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>+</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_fitness_cost_per_gene'>fitness_cost_per_gene</span> <span class='op'>*</span> <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
1202
+ <span class='kw'>end</span></pre>
1203
+ </td>
1204
+ </tr>
1205
+ </table>
1206
+ </div>
1207
+
1208
+ <div class="method_details ">
1209
+ <h3 class="signature " id="forget!-instance_method">
1210
+
1211
+ - (<tt>Object</tt>) <strong>forget!</strong>
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+ </h3><div class="docstring">
1218
+ <div class="discussion">
1219
+
1220
+ <p>Make the neurons forget their wiring.</p>
1221
+
1222
+
1223
+ </div>
1224
+ </div>
1225
+ <div class="tags">
1226
+
1227
+
1228
+ </div><table class="source_code">
1229
+ <tr>
1230
+ <td>
1231
+ <pre class="lines">
1232
+
1233
+
1234
+ 134
1235
+ 135
1236
+ 136
1237
+ 137</pre>
1238
+ </td>
1239
+ <td>
1240
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 134</span>
1241
+
1242
+ <span class='kw'>def</span> <span class='id identifier rubyid_forget!'>forget!</span>
1243
+ <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_neu'>neu</span><span class='op'>|</span> <span class='id identifier rubyid_neu'>neu</span><span class='period'>.</span><span class='id identifier rubyid_clear_graph'>clear_graph</span> <span class='rbrace'>}</span>
1244
+ <span class='ivar'>@neural_gene_map</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span> <span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
1245
+ <span class='kw'>end</span></pre>
1246
+ </td>
1247
+ </tr>
1248
+ </table>
1249
+ </div>
1250
+
1251
+ <div class="method_details ">
1252
+ <h3 class="signature " id="innervate!-instance_method">
1253
+
1254
+ - (<tt>Object</tt>) <strong>innervate!</strong>(*hneus)
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+ </h3><div class="docstring">
1261
+ <div class="discussion">
1262
+
1263
+ <p>We take the neural hashes (presumably from other neurons), and innervate
1264
+ them. We do this in distinctions based on the neuron&#39;s names. FIXME We
1265
+ need to randomly select a neuron in the case of clashes.</p>
1266
+
1267
+
1268
+ </div>
1269
+ </div>
1270
+ <div class="tags">
1271
+ <p class="tag_title">Parameters:</p>
1272
+ <ul class="param">
1273
+
1274
+ <li>
1275
+
1276
+ <span class='name'>hneus</span>
1277
+
1278
+
1279
+ <span class='type'>(<tt>Hash</tt>)</span>
1280
+
1281
+
1282
+
1283
+ &mdash;
1284
+ <div class='inline'>
1285
+ <p>– hashes of neurons to innervate</p>
1286
+ </div>
1287
+
1288
+ </li>
1289
+
1290
+ </ul>
1291
+
1292
+
1293
+ </div><table class="source_code">
1294
+ <tr>
1295
+ <td>
1296
+ <pre class="lines">
1297
+
1298
+
1299
+ 175
1300
+ 176
1301
+ 177
1302
+ 178
1303
+ 179</pre>
1304
+ </td>
1305
+ <td>
1306
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 175</span>
1307
+
1308
+ <span class='kw'>def</span> <span class='id identifier rubyid_innervate!'>innervate!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_hneus'>hneus</span><span class='rparen'>)</span>
1309
+ <span class='id identifier rubyid_hneus'>hneus</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_neus'>neus</span><span class='op'>|</span>
1310
+ <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span> <span class='id identifier rubyid_neus'>neus</span><span class='period'>.</span><span class='id identifier rubyid_dclone'>dclone</span>
1311
+ <span class='kw'>end</span>
1312
+ <span class='kw'>end</span></pre>
1313
+ </td>
1314
+ </tr>
1315
+ </table>
1316
+ </div>
1317
+
1318
+ <div class="method_details ">
1319
+ <h3 class="signature " id="neucleate-instance_method">
1320
+
1321
+ - (<tt>Object</tt>) <strong>neucleate</strong>(clean: true, &amp;block)
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+ </h3><div class="docstring">
1328
+ <div class="discussion">
1329
+
1330
+ <p>We add genes given here to the genome. An array of genes is returned from
1331
+ the block and we simply add them in.</p>
1332
+
1333
+
1334
+ </div>
1335
+ </div>
1336
+ <div class="tags">
1337
+ <p class="tag_title">Parameters:</p>
1338
+ <ul class="param">
1339
+
1340
+ <li>
1341
+
1342
+ <span class='name'>clean</span>
1343
+
1344
+
1345
+ <span class='type'>(<tt>boolean</tt>)</span>
1346
+
1347
+
1348
+
1349
+ </li>
1350
+
1351
+ <li>
1352
+
1353
+ <span class='name'>block</span>
1354
+
1355
+
1356
+ <span class='type'>(<tt>Proc</tt>)</span>
1357
+
1358
+
1359
+
1360
+ </li>
1361
+
1362
+ </ul>
1363
+
1364
+
1365
+ </div><table class="source_code">
1366
+ <tr>
1367
+ <td>
1368
+ <pre class="lines">
1369
+
1370
+
1371
+ 113
1372
+ 114
1373
+ 115
1374
+ 116
1375
+ 117
1376
+ 118
1377
+ 119
1378
+ 120
1379
+ 121
1380
+ 122
1381
+ 123</pre>
1382
+ </td>
1383
+ <td>
1384
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 113</span>
1385
+
1386
+ <span class='kw'>def</span> <span class='id identifier rubyid_neucleate'>neucleate</span><span class='lparen'>(</span><span class='label'>clean:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1387
+ <span class='id identifier rubyid_genes'>genes</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_g'>g</span><span class='op'>|</span>
1388
+ <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_genotype'>genotype</span> <span class='op'>=</span> <span class='kw'>self</span>
1389
+ <span class='lbracket'>[</span><span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_innovation'>innovation</span><span class='comma'>,</span> <span class='id identifier rubyid_g'>g</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='rbracket'>]</span>
1390
+ <span class='kw'>if</span> <span class='id identifier rubyid_clean'>clean</span>
1391
+ <span class='ivar'>@genes</span> <span class='op'>=</span> <span class='id identifier rubyid_genes'>genes</span>
1392
+ <span class='kw'>else</span>
1393
+ <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span> <span class='id identifier rubyid_genes'>genes</span>
1394
+ <span class='kw'>end</span>
1395
+ <span class='id identifier rubyid_nuke_redundancies!'>nuke_redundancies!</span>
1396
+ <span class='kw'>end</span></pre>
1397
+ </td>
1398
+ </tr>
1399
+ </table>
1400
+ </div>
1401
+
1402
+ <div class="method_details ">
1403
+ <h3 class="signature " id="nuke_redundancies!-instance_method">
1404
+
1405
+ - (<tt>Object</tt>) <strong>nuke_redundancies!</strong>
1406
+
1407
+
1408
+
1409
+
1410
+
1411
+ </h3><div class="docstring">
1412
+ <div class="discussion">
1413
+
1414
+ <p>Remove any redundancies in the genome, any genes refering to the same two
1415
+ neurons. Simply choose one and delete the rest. TODO: implement
1416
+ nuke_redundancies!</p>
1417
+
1418
+
1419
+ </div>
1420
+ </div>
1421
+ <div class="tags">
1422
+
1423
+
1424
+ </div><table class="source_code">
1425
+ <tr>
1426
+ <td>
1427
+ <pre class="lines">
1428
+
1429
+
1430
+ 129
1431
+ 130
1432
+ 131</pre>
1433
+ </td>
1434
+ <td>
1435
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 129</span>
1436
+
1437
+ <span class='kw'>def</span> <span class='id identifier rubyid_nuke_redundancies!'>nuke_redundancies!</span>
1438
+ <span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nuke_redundancies! NIY</span><span class='tstring_end'>&#39;</span></span>
1439
+ <span class='kw'>end</span></pre>
1440
+ </td>
1441
+ </tr>
1442
+ </table>
1443
+ </div>
1444
+
1445
+ <div class="method_details ">
1446
+ <h3 class="signature " id="prune!-instance_method">
1447
+
1448
+ - (<tt>Object</tt>) <strong>prune!</strong>
1449
+
1450
+
1451
+
1452
+
1453
+
1454
+ </h3><div class="docstring">
1455
+ <div class="discussion">
1456
+
1457
+ <p>Go through the list of neurons and drop any neurons not referenced by the
1458
+ genes.</p>
1459
+
1460
+ <p>Then go through the genes and drop any that are dangling (i.e. no matching
1461
+ neurons)</p>
1462
+
1463
+ <p>Then make sure that @neural_inputs and @neural_outputs reference the actual
1464
+ instance neurons in @neurons</p>
1465
+
1466
+ <p>TODO add this circularity check to prune!</p>
1467
+
1468
+
1469
+ </div>
1470
+ </div>
1471
+ <div class="tags">
1472
+
1473
+
1474
+ </div><table class="source_code">
1475
+ <tr>
1476
+ <td>
1477
+ <pre class="lines">
1478
+
1479
+
1480
+ 191
1481
+ 192
1482
+ 193
1483
+ 194
1484
+ 195
1485
+ 196
1486
+ 197
1487
+ 198
1488
+ 199
1489
+ 200
1490
+ 201
1491
+ 202
1492
+ 203
1493
+ 204
1494
+ 205
1495
+ 206
1496
+ 207
1497
+ 208
1498
+ 209
1499
+ 210</pre>
1500
+ </td>
1501
+ <td>
1502
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 191</span>
1503
+
1504
+ <span class='kw'>def</span> <span class='id identifier rubyid_prune!'>prune!</span>
1505
+ <span class='comment'># Take care of dangling neurons
1506
+ </span> <span class='id identifier rubyid_neunames'>neunames</span> <span class='op'>=</span> <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_g'>g</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span><span class='comma'>,</span> <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_to_set'>to_set</span>
1507
+ <span class='ivar'>@neurons</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span>
1508
+ <span class='kw'>not</span> <span class='id identifier rubyid_neunames'>neunames</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
1509
+ <span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span>
1510
+ <span class='lbracket'>[</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_n'>n</span><span class='rbracket'>]</span>
1511
+ <span class='kw'>end</span><span class='rbracket'>]</span>
1512
+
1513
+ <span class='comment'># Take care of dangling genes
1514
+ </span> <span class='ivar'>@genes</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_gene'>gene</span><span class='op'>|</span>
1515
+ <span class='kw'>not</span> <span class='lparen'>(</span><span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span><span class='rparen'>)</span> <span class='kw'>and</span> <span class='ivar'>@neurons</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='rparen'>)</span><span class='rparen'>)</span>
1516
+ <span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_gene'>gene</span><span class='op'>|</span>
1517
+ <span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_gene'>gene</span><span class='rbracket'>]</span>
1518
+ <span class='kw'>end</span><span class='rbracket'>]</span>
1519
+
1520
+ <span class='comment'># Make sure @neural_inputs and @neural_outputs are consistent
1521
+ </span> <span class='ivar'>@neural_inputs</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@neural_inputs</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rbracket'>]</span>
1522
+ <span class='ivar'>@neural_outputs</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='ivar'>@neural_outputs</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rbracket'>]</span>
1523
+ <span class='kw'>end</span></pre>
1524
+ </td>
1525
+ </tr>
1526
+ </table>
1527
+ </div>
1528
+
1529
+ <div class="method_details ">
1530
+ <h3 class="signature " id="wire!-instance_method">
1531
+
1532
+ - (<tt>Object</tt>) <strong>wire!</strong>
1533
+
1534
+
1535
+
1536
+
1537
+
1538
+ </h3><div class="docstring">
1539
+ <div class="discussion">
1540
+
1541
+ <p>Wire up the neurons based on the genes.</p>
1542
+
1543
+
1544
+ </div>
1545
+ </div>
1546
+ <div class="tags">
1547
+
1548
+
1549
+ </div><table class="source_code">
1550
+ <tr>
1551
+ <td>
1552
+ <pre class="lines">
1553
+
1554
+
1555
+ 140
1556
+ 141
1557
+ 142
1558
+ 143
1559
+ 144
1560
+ 145
1561
+ 146
1562
+ 147
1563
+ 148
1564
+ 149
1565
+ 150
1566
+ 151
1567
+ 152</pre>
1568
+ </td>
1569
+ <td>
1570
+ <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 140</span>
1571
+
1572
+ <span class='kw'>def</span> <span class='id identifier rubyid_wire!'>wire!</span>
1573
+ <span class='id identifier rubyid_forget!'>forget!</span>
1574
+ <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_innov'>innov</span><span class='comma'>,</span> <span class='id identifier rubyid_gene'>gene</span><span class='op'>|</span>
1575
+ <span class='kw'>if</span> <span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_enabled?'>enabled?</span>
1576
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NeatException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Can&#39;t find </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1577
+ <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='ivar'>@neurons</span><span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span><span class='rbracket'>]</span>
1578
+ <span class='ivar'>@neural_gene_map</span><span class='lbracket'>[</span><span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_out_neuron'>out_neuron</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_gene'>gene</span> <span class='kw'>unless</span> <span class='id identifier rubyid_gene'>gene</span><span class='period'>.</span><span class='id identifier rubyid_in_neuron'>in_neuron</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1579
+ <span class='kw'>end</span>
1580
+ <span class='kw'>end</span> <span class='kw'>unless</span> <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1581
+ <span class='kw'>if</span> <span class='ivar'>@genes</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1582
+ <span class='gvar'>$log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Genes Not Present</span><span class='tstring_end'>&#39;</span></span>
1583
+ <span class='kw'>end</span>
1584
+ <span class='kw'>end</span></pre>
1585
+ </td>
1586
+ </tr>
1587
+ </table>
1588
+ </div>
1589
+
1590
+ </div>
1591
+
1592
+ </div>
1593
+
1594
+ <div id="footer">
1595
+ Generated on Sun Apr 13 15:54:02 2014 by
1596
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1597
+ 0.8.7.4 (ruby-2.1.1).
1598
+ </div>
1599
+
1600
+ </body>
1601
+ </html>