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.
- checksums.yaml +7 -0
- data/.directory +4 -0
- data/.gitignore.orig +20 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/trader.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/rubyneat.iml +197 -0
- data/.idea/runConfigurations/invpend_neat.xml +26 -0
- data/.idea/runConfigurations/sigdebug_neat.xml +24 -0
- data/.idea/runConfigurations/xor_neat.xml +26 -0
- data/.idea/runConfigurations/xordebug_neat.xml +24 -0
- data/.idea/runConfigurations/xorsin_neat.xml +24 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +1124 -0
- data/.semver +5 -0
- data/.yardoc/checksums +11 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +32 -0
- data/Gemfile.lock +135 -0
- data/Gemfile.lock.orig +147 -0
- data/Guardfile +8 -0
- data/Rakefile +61 -0
- data/bin/neat +83 -0
- data/config/application.rb +5 -0
- data/doc/ControllerPoint.html +125 -0
- data/doc/CuteA.html +286 -0
- data/doc/CuteB.html +297 -0
- data/doc/DSL.html +883 -0
- data/doc/NEAT/BasicNeuronTypes/BiasNeuron.html +518 -0
- data/doc/NEAT/BasicNeuronTypes/CosineNeuron.html +274 -0
- data/doc/NEAT/BasicNeuronTypes/InputNeuron.html +366 -0
- data/doc/NEAT/BasicNeuronTypes/SigmoidNeuron.html +275 -0
- data/doc/NEAT/BasicNeuronTypes/SineNeuron.html +274 -0
- data/doc/NEAT/BasicNeuronTypes/TanhNeuron.html +274 -0
- data/doc/NEAT/BasicNeuronTypes.html +136 -0
- data/doc/NEAT/Controller/NeatSettings.html +3985 -0
- data/doc/NEAT/Controller.html +2490 -0
- data/doc/NEAT/Critter/Genotype/Gene.html +979 -0
- data/doc/NEAT/Critter/Genotype.html +1601 -0
- data/doc/NEAT/Critter/Phenotype.html +603 -0
- data/doc/NEAT/Critter.html +1037 -0
- data/doc/NEAT/DSL.html +1255 -0
- data/doc/NEAT/Evaluator.html +420 -0
- data/doc/NEAT/Evolver/CritterOp.html +551 -0
- data/doc/NEAT/Evolver.html +602 -0
- data/doc/NEAT/Expressor.html +327 -0
- data/doc/NEAT/Graph/DependencyResolver.html +478 -0
- data/doc/NEAT/Graph/GraphException.html +123 -0
- data/doc/NEAT/Graph.html +402 -0
- data/doc/NEAT/NeatException.html +123 -0
- data/doc/NEAT/NeatOb.html +567 -0
- data/doc/NEAT/Neuron.html +1067 -0
- data/doc/NEAT/Operator.html +162 -0
- data/doc/NEAT/Population.html +1961 -0
- data/doc/NEAT/Trait.html +169 -0
- data/doc/NEAT.html +588 -0
- data/doc/_index.html +373 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file_list.html +53 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +373 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1415 -0
- data/doc/top-level-namespace.html +164 -0
- data/foo/foo_aquarium_example.rb +38 -0
- data/foo/foo_gosu.rb +99 -0
- data/foo/foo_rubygoo.rb +104 -0
- data/foo/foo_sdl.rb +34 -0
- data/foo/icon.png +0 -0
- data/lib/rubyneat/critter.rb +374 -0
- data/lib/rubyneat/default_neat.rb +10 -0
- data/lib/rubyneat/dsl.rb +130 -0
- data/lib/rubyneat/evaluator.rb +51 -0
- data/lib/rubyneat/evolver.rb +315 -0
- data/lib/rubyneat/expressor.rb +110 -0
- data/lib/rubyneat/graph.rb +95 -0
- data/lib/rubyneat/neuron.rb +152 -0
- data/lib/rubyneat/population.rb +227 -0
- data/lib/rubyneat/rubyneat.rb +429 -0
- data/lib/rubyneat.rb +8 -0
- data/neater/invpend_neat.rb +150 -0
- data/neater/rnlib/inverted_pendulum.rb +380 -0
- data/neater/rnlib/xor.rb +10 -0
- data/neater/sigdebug_neat.rb +136 -0
- data/neater/xor_neat.rb +137 -0
- data/neater/xoranalog_neat.rb +138 -0
- data/neater/xorsin_neat.rb +143 -0
- data/projectFilesBackup/.idea/rubyneat.iml +180 -0
- data/public/.directory +4 -0
- data/public/background.png +0 -0
- data/public/background.xcf +0 -0
- data/public/cart.png +0 -0
- data/public/cart.xcf +0 -0
- data/public/metalpoles_molton_ball_l.jpg +0 -0
- data/public/old_background.png +0 -0
- data/public/pointer.png +0 -0
- data/public/pointer.xcf +0 -0
- data/public/pole.kra +0 -0
- data/public/pole.png +0 -0
- data/public/pole.xcf +0 -0
- data/public/wheel-of-year-stone-DD-131-WOYS.jpg +0 -0
- data/public/wheel.png +0 -0
- data/public/wheel.xcf +0 -0
- data/public/wood-planks-texture.jpg +0 -0
- data/rdoc/ControllerPoint.html +116 -0
- data/rdoc/CuteA.html +177 -0
- data/rdoc/CuteB.html +178 -0
- data/rdoc/DSLSetup.html +177 -0
- data/rdoc/GameTestWindow.html +242 -0
- data/rdoc/GameWindow.html +292 -0
- data/rdoc/Gemfile.html +215 -0
- data/rdoc/Gemfile_lock.html +327 -0
- data/rdoc/GraphTest.html +210 -0
- data/rdoc/Guardfile.html +198 -0
- data/rdoc/InvertedPendulum/Cart.html +668 -0
- data/rdoc/InvertedPendulum/DSL.html +259 -0
- data/rdoc/InvertedPendulum/InvPendWindow.html +402 -0
- data/rdoc/InvertedPendulum.html +198 -0
- data/rdoc/Logger.html +98 -0
- data/rdoc/NEAT/BasicNeuronTypes/BiasNeuron.html +265 -0
- data/rdoc/NEAT/BasicNeuronTypes/CosineNeuron.html +162 -0
- data/rdoc/NEAT/BasicNeuronTypes/InputNeuron.html +206 -0
- data/rdoc/NEAT/BasicNeuronTypes/SigmoidNeuron.html +162 -0
- data/rdoc/NEAT/BasicNeuronTypes/SineNeuron.html +162 -0
- data/rdoc/NEAT/BasicNeuronTypes/TanhNeuron.html +161 -0
- data/rdoc/NEAT/BasicNeuronTypes.html +107 -0
- data/rdoc/NEAT/Controller/NeatSettings.html +880 -0
- data/rdoc/NEAT/Controller.html +729 -0
- data/rdoc/NEAT/Critter/Genotype/Gene.html +457 -0
- data/rdoc/NEAT/Critter/Genotype.html +735 -0
- data/rdoc/NEAT/Critter/Phenotype.html +330 -0
- data/rdoc/NEAT/Critter.html +489 -0
- data/rdoc/NEAT/DSL.html +729 -0
- data/rdoc/NEAT/Evaluator.html +256 -0
- data/rdoc/NEAT/Evolver/CritterOp.html +349 -0
- data/rdoc/NEAT/Evolver.html +891 -0
- data/rdoc/NEAT/Expressor.html +402 -0
- data/rdoc/NEAT/Graph/DependencyResolver.html +291 -0
- data/rdoc/NEAT/Graph/GraphException.html +105 -0
- data/rdoc/NEAT/Graph.html +263 -0
- data/rdoc/NEAT/NeatException.html +105 -0
- data/rdoc/NEAT/NeatOb.html +325 -0
- data/rdoc/NEAT/Neuron.html +481 -0
- data/rdoc/NEAT/Operator.html +109 -0
- data/rdoc/NEAT/Population.html +935 -0
- data/rdoc/NEAT/Trait.html +117 -0
- data/rdoc/NEAT.html +422 -0
- data/rdoc/Object.html +384 -0
- data/rdoc/Phi.html +98 -0
- data/rdoc/Player.html +383 -0
- data/rdoc/Rakefile.html +254 -0
- data/rdoc/RubyNEAT/Application.html +105 -0
- data/rdoc/RubyNEAT.html +98 -0
- data/rdoc/SDL/Event2.html +98 -0
- data/rdoc/SDL.html +98 -0
- data/rdoc/Vector.html +195 -0
- data/rdoc/created.rid +125 -0
- data/rdoc/doc/ControllerPoint_html.html +299 -0
- data/rdoc/doc/CuteA_html.html +438 -0
- data/rdoc/doc/CuteB_html.html +436 -0
- data/rdoc/doc/DSL_html.html +992 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/BiasNeuron_html.html +617 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/CosineNeuron_html.html +413 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/InputNeuron_html.html +498 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/SigmoidNeuron_html.html +413 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/SineNeuron_html.html +413 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes/TanhNeuron_html.html +412 -0
- data/rdoc/doc/NEAT/BasicNeuronTypes_html.html +310 -0
- data/rdoc/doc/NEAT/Controller/NeatSettings_html.html +3324 -0
- data/rdoc/doc/NEAT/Controller_html.html +2212 -0
- data/rdoc/doc/NEAT/Critter/Genotype/Gene_html.html +997 -0
- data/rdoc/doc/NEAT/Critter/Genotype_html.html +1556 -0
- data/rdoc/doc/NEAT/Critter/Phenotype_html.html +687 -0
- data/rdoc/doc/NEAT/Critter_html.html +1037 -0
- data/rdoc/doc/NEAT/DSL_html.html +1349 -0
- data/rdoc/doc/NEAT/Evaluator_html.html +556 -0
- data/rdoc/doc/NEAT/Evolver/CritterOp_html.html +690 -0
- data/rdoc/doc/NEAT/Evolver_html.html +677 -0
- data/rdoc/doc/NEAT/Expressor_html.html +468 -0
- data/rdoc/doc/NEAT/Graph/DependencyResolver_html.html +598 -0
- data/rdoc/doc/NEAT/Graph/GraphException_html.html +299 -0
- data/rdoc/doc/NEAT/Graph_html.html +527 -0
- data/rdoc/doc/NEAT/NeatException_html.html +299 -0
- data/rdoc/doc/NEAT/NeatOb_html.html +671 -0
- data/rdoc/doc/NEAT/Neuron_html.html +1095 -0
- data/rdoc/doc/NEAT/Operator_html.html +337 -0
- data/rdoc/doc/NEAT/Population_html.html +1795 -0
- data/rdoc/doc/NEAT/Trait_html.html +344 -0
- data/rdoc/doc/NEAT_html.html +736 -0
- data/rdoc/doc/_index_html.html +559 -0
- data/rdoc/doc/class_list_html.html +369 -0
- data/rdoc/doc/css/common_css.html +188 -0
- data/rdoc/doc/css/full_list_css.html +243 -0
- data/rdoc/doc/css/style_css.html +530 -0
- data/rdoc/doc/file_list_html.html +240 -0
- data/rdoc/doc/frames_html.html +217 -0
- data/rdoc/doc/index_html.html +559 -0
- data/rdoc/doc/js/app_js.html +423 -0
- data/rdoc/doc/js/full_list_js.html +372 -0
- data/rdoc/doc/js/jquery_js.html +1536 -0
- data/rdoc/doc/method_list_html.html +1375 -0
- data/rdoc/doc/top-level-namespace_html.html +317 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/fonts.css +167 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +282 -0
- data/rdoc/js/darkfish.js +140 -0
- data/rdoc/js/jquery.js +18 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +109 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +580 -0
- data/rdoc/rubyneat_gemspec.html +387 -0
- data/rdoc/table_of_contents.html +2502 -0
- data/rdoc/xordebug_log.html +170598 -0
- data/rdoc/xorsin_log.html +22569 -0
- data/rubyneat.gemspec +347 -0
- data/rubyneat.gemspec.orig +375 -0
- data/spec/lib/rubyneat/rubyneat_spec.rb +132 -0
- metadata +555 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>class NEAT::Evaluator - rubyneat 0.3.4</title>
|
|
8
|
+
|
|
9
|
+
<link href="../fonts.css" rel="stylesheet">
|
|
10
|
+
<link href="../rdoc.css" rel="stylesheet">
|
|
11
|
+
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
var rdoc_rel_prefix = "../";
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script src="../js/jquery.js"></script>
|
|
17
|
+
<script src="../js/navigation.js"></script>
|
|
18
|
+
<script src="../js/search_index.js"></script>
|
|
19
|
+
<script src="../js/search.js"></script>
|
|
20
|
+
<script src="../js/searcher.js"></script>
|
|
21
|
+
<script src="../js/darkfish.js"></script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<body id="top" role="document" class="class">
|
|
25
|
+
<nav role="navigation">
|
|
26
|
+
<div id="project-navigation">
|
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
28
|
+
<h2>
|
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
|
30
|
+
</h2>
|
|
31
|
+
|
|
32
|
+
<div id="table-of-contents-navigation">
|
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
41
|
+
<div id="search-field-wrapper">
|
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
|
49
|
+
aria-busy="false" aria-expanded="false"
|
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
51
|
+
</form>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<div id="class-metadata">
|
|
59
|
+
|
|
60
|
+
<div id="parent-class-section" class="nav-section">
|
|
61
|
+
<h3>Parent</h3>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<p class="link">Operator
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<!-- Method Quickref -->
|
|
71
|
+
<div id="method-list-section" class="nav-section">
|
|
72
|
+
<h3>Methods</h3>
|
|
73
|
+
|
|
74
|
+
<ul class="link-list" role="directory">
|
|
75
|
+
|
|
76
|
+
<li ><a href="#method-i-analyze_for_fitness-21">#analyze_for_fitness!</a>
|
|
77
|
+
|
|
78
|
+
<li ><a href="#method-i-evaluate-21">#evaluate!</a>
|
|
79
|
+
|
|
80
|
+
<li ><a href="#method-i-ready_for_evaluation">#ready_for_evaluation</a>
|
|
81
|
+
|
|
82
|
+
</ul>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
</div>
|
|
86
|
+
</nav>
|
|
87
|
+
|
|
88
|
+
<main role="main" aria-labelledby="class-NEAT::Evaluator">
|
|
89
|
+
<h1 id="class-NEAT::Evaluator" class="class">
|
|
90
|
+
class NEAT::Evaluator
|
|
91
|
+
</h1>
|
|
92
|
+
|
|
93
|
+
<section class="description">
|
|
94
|
+
|
|
95
|
+
<h1 id="class-NEAT::Evaluator-label-Evaluator+evaluates+phenotype+of+critter+for+fitness%2C+novelty%2C+etc."><a href="Evaluator.html">Evaluator</a> evaluates phenotype of critter for fitness, novelty, etc.<span><a href="#class-NEAT::Evaluator-label-Evaluator+evaluates+phenotype+of+critter+for+fitness%2C+novelty%2C+etc.">¶</a> <a href="#documentation">↑</a></span></h1>
|
|
96
|
+
|
|
97
|
+
<pre>We can have a chain of these evaluators whose outputs are summed, etc.</pre>
|
|
98
|
+
|
|
99
|
+
</section>
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
115
|
+
<header>
|
|
116
|
+
<h3>Public Instance Methods</h3>
|
|
117
|
+
</header>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
<div id="method-i-analyze_for_fitness-21" class="method-detail ">
|
|
121
|
+
|
|
122
|
+
<div class="method-heading">
|
|
123
|
+
<span class="method-name">analyze_for_fitness!</span><span
|
|
124
|
+
class="method-args">(critter)</span>
|
|
125
|
+
|
|
126
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
127
|
+
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
<div class="method-description">
|
|
132
|
+
|
|
133
|
+
<p>Analyze the evaluation and compute a fitness for the given critter. Note
|
|
134
|
+
that if cost_func is set, we call that to integrate the cost to the fitness
|
|
135
|
+
average fitness calculated for the fitness vector.</p>
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
<div class="method-source-code" id="analyze_for_fitness-21-source">
|
|
141
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evaluator.rb, line 40</span>
|
|
142
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">analyze_for_fitness!</span>(<span class="ruby-identifier">critter</span>)
|
|
143
|
+
<span class="ruby-identifier">fitvec</span> = <span class="ruby-ivar">@crit_hist</span>[<span class="ruby-identifier">critter</span>].<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">seq</span>, <span class="ruby-identifier">vio</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">fitness_func</span>.(<span class="ruby-identifier">vio</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">vio</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">seq</span>) }
|
|
144
|
+
<span class="ruby-comment"># Average the fitness vector to get a scalar fitness.</span>
|
|
145
|
+
<span class="ruby-identifier">critter</span>.<span class="ruby-identifier">fitness</span> = <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">cost_func</span>.<span class="ruby-identifier">nil?</span>
|
|
146
|
+
<span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">cost_func</span>.(<span class="ruby-identifier">fitvec</span>, <span class="ruby-identifier">critter</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">fitness_cost</span>)
|
|
147
|
+
<span class="ruby-keyword">else</span>
|
|
148
|
+
<span class="ruby-identifier">fitvec</span>.<span class="ruby-identifier">reduce</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span><span class="ruby-operator">+</span><span class="ruby-identifier">r</span>} <span class="ruby-operator">/</span> <span class="ruby-identifier">fitvec</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">critter</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">fitness_cost</span>
|
|
149
|
+
<span class="ruby-keyword">end</span>
|
|
150
|
+
<span class="ruby-identifier">log</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Fitness Vector: #{fitvec}, fitness of #{critter.fitness} assigned to #{critter}"</span>
|
|
151
|
+
<span class="ruby-keyword">end</span></pre>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
<div id="method-i-evaluate-21" class="method-detail ">
|
|
163
|
+
|
|
164
|
+
<div class="method-heading">
|
|
165
|
+
<span class="method-name">evaluate!</span><span
|
|
166
|
+
class="method-args">(critter)</span>
|
|
167
|
+
|
|
168
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
169
|
+
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
<div class="method-description">
|
|
174
|
+
|
|
175
|
+
<p>Evaluate one step of a sequence of evaluations. For time series and
|
|
176
|
+
realtime ongoing evaluations, @controller.seq_num governs where in the
|
|
177
|
+
sequence everything is.</p>
|
|
178
|
+
|
|
179
|
+
<p>Returns [vin, vout], where vin is the input vector, and vout in the output
|
|
180
|
+
vector from the critter. FIXME: this should not really have to deal with an
|
|
181
|
+
error. FIXME: the error should be handled upstream from here.</p>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<div class="method-source-code" id="evaluate-21-source">
|
|
187
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evaluator.rb, line 24</span>
|
|
188
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">evaluate!</span>(<span class="ruby-identifier">critter</span>)
|
|
189
|
+
<span class="ruby-identifier">vin</span> = <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">query_func</span>.(<span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">seq_num</span>)
|
|
190
|
+
<span class="ruby-ivar">@crit_hist</span>[<span class="ruby-identifier">critter</span>] = {} <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@crit_hist</span>.<span class="ruby-identifier">member?</span> <span class="ruby-identifier">critter</span>
|
|
191
|
+
<span class="ruby-keyword">begin</span>
|
|
192
|
+
<span class="ruby-identifier">vout</span> = <span class="ruby-identifier">critter</span>.<span class="ruby-identifier">phenotype</span>.<span class="ruby-identifier">stimulate</span> <span class="ruby-operator">*</span><span class="ruby-identifier">vin</span>, <span class="ruby-operator">&</span><span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">recurrence_func</span>
|
|
193
|
+
<span class="ruby-identifier">log</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Critter #{critter.name}: vin=#{vin}. vout=#{vout}"</span>
|
|
194
|
+
<span class="ruby-ivar">@crit_hist</span>[<span class="ruby-identifier">critter</span>][<span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">seq_num</span>] = [<span class="ruby-identifier">vin</span>, <span class="ruby-identifier">vout</span>]
|
|
195
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
196
|
+
<span class="ruby-identifier">log</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"Exception #{e} on code:\n#{critter.phenotype.code}"</span>
|
|
197
|
+
<span class="ruby-ivar">@crit_hist</span>[<span class="ruby-identifier">critter</span>][<span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">seq_num</span>] = [<span class="ruby-identifier">vin</span>, <span class="ruby-value">:error</span>]
|
|
198
|
+
<span class="ruby-keyword">end</span>
|
|
199
|
+
<span class="ruby-keyword">end</span></pre>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
<div id="method-i-ready_for_evaluation" class="method-detail ">
|
|
211
|
+
|
|
212
|
+
<div class="method-heading">
|
|
213
|
+
<span class="method-name">ready_for_evaluation</span><span
|
|
214
|
+
class="method-args">(pop)</span>
|
|
215
|
+
|
|
216
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
217
|
+
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
<div class="method-description">
|
|
222
|
+
|
|
223
|
+
<p>This is call prior to any sequence evaluation. Here, we clean up persistent
|
|
224
|
+
tracking information, etc.</p>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
<div class="method-source-code" id="ready_for_evaluation-source">
|
|
230
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evaluator.rb, line 10</span>
|
|
231
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ready_for_evaluation</span>(<span class="ruby-identifier">pop</span>)
|
|
232
|
+
<span class="ruby-ivar">@crit_hist</span> = {}
|
|
233
|
+
<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">initialize_for_recurrence!</span>
|
|
234
|
+
<span class="ruby-keyword">end</span></pre>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
</section>
|
|
246
|
+
|
|
247
|
+
</section>
|
|
248
|
+
</main>
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
<footer id="validator-badges" role="contentinfo">
|
|
252
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
253
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
|
254
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
255
|
+
</footer>
|
|
256
|
+
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>class NEAT::Evolver::CritterOp - rubyneat 0.3.4</title>
|
|
8
|
+
|
|
9
|
+
<link href="../../fonts.css" rel="stylesheet">
|
|
10
|
+
<link href="../../rdoc.css" rel="stylesheet">
|
|
11
|
+
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
var rdoc_rel_prefix = "../../";
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script src="../../js/jquery.js"></script>
|
|
17
|
+
<script src="../../js/navigation.js"></script>
|
|
18
|
+
<script src="../../js/search_index.js"></script>
|
|
19
|
+
<script src="../../js/search.js"></script>
|
|
20
|
+
<script src="../../js/searcher.js"></script>
|
|
21
|
+
<script src="../../js/darkfish.js"></script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<body id="top" role="document" class="class">
|
|
25
|
+
<nav role="navigation">
|
|
26
|
+
<div id="project-navigation">
|
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
28
|
+
<h2>
|
|
29
|
+
<a href="../../index.html" rel="home">Home</a>
|
|
30
|
+
</h2>
|
|
31
|
+
|
|
32
|
+
<div id="table-of-contents-navigation">
|
|
33
|
+
<a href="../../table_of_contents.html#pages">Pages</a>
|
|
34
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
|
35
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
41
|
+
<div id="search-field-wrapper">
|
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
|
49
|
+
aria-busy="false" aria-expanded="false"
|
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
51
|
+
</form>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<div id="class-metadata">
|
|
59
|
+
|
|
60
|
+
<div id="parent-class-section" class="nav-section">
|
|
61
|
+
<h3>Parent</h3>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<p class="link">NeatOb
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<!-- Method Quickref -->
|
|
71
|
+
<div id="method-list-section" class="nav-section">
|
|
72
|
+
<h3>Methods</h3>
|
|
73
|
+
|
|
74
|
+
<ul class="link-list" role="directory">
|
|
75
|
+
|
|
76
|
+
<li class="calls-super" ><a href="#method-c-new">::new</a>
|
|
77
|
+
|
|
78
|
+
<li ><a href="#method-i-add_gene-21">#add_gene!</a>
|
|
79
|
+
|
|
80
|
+
<li ><a href="#method-i-add_neuron-21">#add_neuron!</a>
|
|
81
|
+
|
|
82
|
+
<li ><a href="#method-i-disable_gene-21">#disable_gene!</a>
|
|
83
|
+
|
|
84
|
+
<li ><a href="#method-i-reenable_gene-21">#reenable_gene!</a>
|
|
85
|
+
|
|
86
|
+
</ul>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
</div>
|
|
90
|
+
</nav>
|
|
91
|
+
|
|
92
|
+
<main role="main" aria-labelledby="class-NEAT::Evolver::CritterOp">
|
|
93
|
+
<h1 id="class-NEAT::Evolver::CritterOp" class="class">
|
|
94
|
+
class NEAT::Evolver::CritterOp
|
|
95
|
+
</h1>
|
|
96
|
+
|
|
97
|
+
<section class="description">
|
|
98
|
+
|
|
99
|
+
<p>A set of <a href="../Critter.html">Critter</a> Genotype operators.</p>
|
|
100
|
+
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
117
|
+
<header>
|
|
118
|
+
<h3>Public Class Methods</h3>
|
|
119
|
+
</header>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
<div id="method-c-new" class="method-detail ">
|
|
123
|
+
|
|
124
|
+
<div class="method-heading">
|
|
125
|
+
<span class="method-name">new</span><span
|
|
126
|
+
class="method-args">(evol)</span>
|
|
127
|
+
|
|
128
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
129
|
+
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
<div class="method-description">
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
<div class="method-calls-super">
|
|
139
|
+
Calls superclass method
|
|
140
|
+
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<div class="method-source-code" id="new-source">
|
|
146
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evolver.rb, line 254</span>
|
|
147
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">evol</span>)
|
|
148
|
+
<span class="ruby-keyword">super</span> <span class="ruby-identifier">evol</span>.<span class="ruby-identifier">controller</span>
|
|
149
|
+
<span class="ruby-ivar">@evolver</span> = <span class="ruby-identifier">evol</span>
|
|
150
|
+
<span class="ruby-ivar">@npop</span> = <span class="ruby-identifier">evol</span>.<span class="ruby-identifier">npop</span>
|
|
151
|
+
<span class="ruby-keyword">end</span></pre>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
</section>
|
|
163
|
+
|
|
164
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
165
|
+
<header>
|
|
166
|
+
<h3>Public Instance Methods</h3>
|
|
167
|
+
</header>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<div id="method-i-add_gene-21" class="method-detail ">
|
|
171
|
+
|
|
172
|
+
<div class="method-heading">
|
|
173
|
+
<span class="method-name">add_gene!</span><span
|
|
174
|
+
class="method-args">(crit)</span>
|
|
175
|
+
|
|
176
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
177
|
+
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
<div class="method-description">
|
|
182
|
+
|
|
183
|
+
<h1 id="method-i-add_gene-21-label-Add+a+gene+to+the+genome">Add a gene to the genome<span><a href="#method-i-add_gene-21-label-Add+a+gene+to+the+genome">¶</a> <a href="#documentation">↑</a></span></h1>
|
|
184
|
+
|
|
185
|
+
<pre>Unlike adding a new neuron, adding a new gene
|
|
186
|
+
could result in a circular dependency. If so,
|
|
187
|
+
and if recurrency is switched off, we must detect
|
|
188
|
+
this condition and switch off the offending neurons.
|
|
189
|
+
|
|
190
|
+
Obviously, this might result in a loss of functionality, but
|
|
191
|
+
oh well.
|
|
192
|
+
|
|
193
|
+
An easy and obvious check is to make sure we don't
|
|
194
|
+
accept any inputs from output neurons, and we don't
|
|
195
|
+
do any outputs to input neurons.
|
|
196
|
+
|
|
197
|
+
Constructs for handling recurrency are present in Expressor.</pre>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
<div class="method-source-code" id="add_gene-21-source">
|
|
203
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evolver.rb, line 290</span>
|
|
204
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_gene!</span>(<span class="ruby-identifier">crit</span>)
|
|
205
|
+
<span class="ruby-identifier">n1</span> = <span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">neurons</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">sample</span> <span class="ruby-comment"># input</span>
|
|
206
|
+
<span class="ruby-identifier">n2</span> = <span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">neurons</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">sample</span> <span class="ruby-comment"># output</span>
|
|
207
|
+
|
|
208
|
+
<span class="ruby-comment"># Sanity checks!</span>
|
|
209
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">n1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">n2</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">n1</span>.<span class="ruby-identifier">output?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">n2</span>.<span class="ruby-identifier">input?</span>
|
|
210
|
+
<span class="ruby-identifier">gene</span> = <span class="ruby-constant">Critter</span><span class="ruby-operator">::</span><span class="ruby-constant">Genotype</span><span class="ruby-operator">::</span><span class="ruby-constant">Gene</span>[<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>, <span class="ruby-identifier">n1</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">n2</span>.<span class="ruby-identifier">name</span>, <span class="ruby-constant">NEAT</span><span class="ruby-operator">::</span><span class="ruby-identifier">controller</span>.<span class="ruby-identifier">gaussian</span>]
|
|
211
|
+
<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">add_genes</span> <span class="ruby-identifier">gene</span>
|
|
212
|
+
<span class="ruby-identifier">log</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"add_gene! Added gene #{gene}(#{n1.name} -> #{n2.name}) to #{crit}"</span>
|
|
213
|
+
<span class="ruby-keyword">end</span>
|
|
214
|
+
<span class="ruby-keyword">end</span></pre>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
<div id="method-i-add_neuron-21" class="method-detail ">
|
|
226
|
+
|
|
227
|
+
<div class="method-heading">
|
|
228
|
+
<span class="method-name">add_neuron!</span><span
|
|
229
|
+
class="method-args">(crit)</span>
|
|
230
|
+
|
|
231
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
232
|
+
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
<div class="method-description">
|
|
237
|
+
|
|
238
|
+
<h1 id="method-i-add_neuron-21-label-Add+a+neuron+to+given+critter">Add a neuron to given critter<span><a href="#method-i-add_neuron-21-label-Add+a+neuron+to+given+critter">¶</a> <a href="#documentation">↑</a></span></h1>
|
|
239
|
+
|
|
240
|
+
<pre>Here, we add a neuron by randomly picking a
|
|
241
|
+
gene, and split it into two genes with an intervening
|
|
242
|
+
neuron. The old gene is not replaced, but disabled. 2 new genes are
|
|
243
|
+
created along with the new neuron.</pre>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<div class="method-source-code" id="add_neuron-21-source">
|
|
249
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evolver.rb, line 265</span>
|
|
250
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_neuron!</span>(<span class="ruby-identifier">crit</span>)
|
|
251
|
+
<span class="ruby-identifier">gene</span> = <span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">genes</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">sample</span>
|
|
252
|
+
<span class="ruby-identifier">neu</span> = <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">neural_hidden</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">sample</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">controller</span>)
|
|
253
|
+
<span class="ruby-identifier">g1</span> = <span class="ruby-constant">Critter</span><span class="ruby-operator">::</span><span class="ruby-constant">Genotype</span><span class="ruby-operator">::</span><span class="ruby-constant">Gene</span>[<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>, <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">in_neuron</span>, <span class="ruby-identifier">neu</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">weight</span>]
|
|
254
|
+
<span class="ruby-identifier">g2</span> = <span class="ruby-constant">Critter</span><span class="ruby-operator">::</span><span class="ruby-constant">Genotype</span><span class="ruby-operator">::</span><span class="ruby-constant">Gene</span>[<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>, <span class="ruby-identifier">neu</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">out_neuron</span>, <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">weight</span>]
|
|
255
|
+
<span class="ruby-identifier">gene</span>.<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword">false</span>
|
|
256
|
+
<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">add_neurons</span> <span class="ruby-identifier">neu</span>
|
|
257
|
+
<span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">add_genes</span> <span class="ruby-identifier">g1</span>, <span class="ruby-identifier">g2</span>
|
|
258
|
+
<span class="ruby-identifier">log</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"add_neuron!: neu #{neu}, g1 #{g1}, g2 #{g2}"</span>
|
|
259
|
+
<span class="ruby-keyword">end</span></pre>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
<div id="method-i-disable_gene-21" class="method-detail ">
|
|
271
|
+
|
|
272
|
+
<div class="method-heading">
|
|
273
|
+
<span class="method-name">disable_gene!</span><span
|
|
274
|
+
class="method-args">(crit)</span>
|
|
275
|
+
|
|
276
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
277
|
+
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
<div class="method-description">
|
|
282
|
+
|
|
283
|
+
<p>Pick an enabled gene at random and disable it.</p>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
<div class="method-source-code" id="disable_gene-21-source">
|
|
289
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evolver.rb, line 303</span>
|
|
290
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">disable_gene!</span>(<span class="ruby-identifier">crit</span>)
|
|
291
|
+
<span class="ruby-identifier">gene</span> = <span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">genes</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">reject</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">gene</span><span class="ruby-operator">|</span> <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">disabled?</span> }.<span class="ruby-identifier">sample</span>
|
|
292
|
+
<span class="ruby-identifier">gene</span>.<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">nil?</span>
|
|
293
|
+
<span class="ruby-keyword">end</span></pre>
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
<div id="method-i-reenable_gene-21" class="method-detail ">
|
|
305
|
+
|
|
306
|
+
<div class="method-heading">
|
|
307
|
+
<span class="method-name">reenable_gene!</span><span
|
|
308
|
+
class="method-args">(crit)</span>
|
|
309
|
+
|
|
310
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
311
|
+
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
<div class="method-description">
|
|
316
|
+
|
|
317
|
+
<p>Pick a disabled gene at random and reenable it.</p>
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
<div class="method-source-code" id="reenable_gene-21-source">
|
|
323
|
+
<pre><span class="ruby-comment"># File lib/rubyneat/evolver.rb, line 309</span>
|
|
324
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">reenable_gene!</span>(<span class="ruby-identifier">crit</span>)
|
|
325
|
+
<span class="ruby-identifier">gene</span> = <span class="ruby-identifier">crit</span>.<span class="ruby-identifier">genotype</span>.<span class="ruby-identifier">genes</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">reject</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">gene</span><span class="ruby-operator">|</span> <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">enabled?</span> }.<span class="ruby-identifier">sample</span>
|
|
326
|
+
<span class="ruby-identifier">gene</span>.<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">gene</span>.<span class="ruby-identifier">nil?</span>
|
|
327
|
+
<span class="ruby-keyword">end</span></pre>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
</section>
|
|
339
|
+
|
|
340
|
+
</section>
|
|
341
|
+
</main>
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
<footer id="validator-badges" role="contentinfo">
|
|
345
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
346
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
|
347
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
348
|
+
</footer>
|
|
349
|
+
|