<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=“www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Class: NEAT::Critter::Genotype::Gene — Documentation by YARD 0.8.7.3
</title>
<link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
<script type=“text/javascript” charset=“utf-8”>
hasFrames = window.top.frames.main ? true : false; relpath = '../../../'; framesUrl = "../../../frames.html#!" + escape(window.location.href);
</script>
<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script> </head> <body> <div id="header"> <div id="menu"> <a href="../../../_index.html">Index (G)</a> » <span class='title'><span class='object_link'><a href="../../../NEAT.html" title="NEAT (module)">NEAT</a></span></span> » <span class='title'><span class='object_link'><a href="../../Critter.html" title="NEAT::Critter (class)">Critter</a></span></span> » <span class='title'><span class='object_link'><a href="../Genotype.html" title="NEAT::Critter::Genotype (class)">Genotype</a></span></span> » <span class="title">Gene</span> <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search"> <a class="full_list_link" id="class_list_link" href="../../../class_list.html"> Class List </a> <a class="full_list_link" id="method_list_link" href="../../../method_list.html"> Method List </a> <a class="full_list_link" id="file_list_link" href="../../../file_list.html"> File List </a>
</div>
<div class="clear"></div> </div> <iframe id="search_frame"></iframe> <div id="content"><h1>Class: NEAT::Critter::Genotype::Gene
</h1>
<dl class=“box”>
<dt class="r1">Inherits:</dt> <dd class="r1"> <span class="inheritName"><span class='object_link'><a href="../../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></span> <ul class="fullTree"> <li>Object</li> <li class="next"><span class='object_link'><a href="../../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></li> <li class="next">NEAT::Critter::Genotype::Gene</li> </ul> <a href="#" class="inheritanceTree">show all</a> </dd> <dt class="r2 last">Defined in:</dt> <dd class="r2 last">lib/rubyneat/critter.rb</dd>
</dl> <div class=“clear”></div>
<h2>Overview</h2><div class=“docstring”>
<div class="discussion">
<h1 id=“label-Gene+Specification”>Gene Specification</h1>
<p>The Gene specifices a singlular input and output neuron, which represents a connection between them, along with the weight of that connection, which may be positive, negative, or zero.</p>
<p>There is also the enabled flag</p>
</div>
</div> <div class=“tags”>
</div>
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#enabled-instance_method" title="#enabled (instance method)">- (Object) <strong>enabled</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>Is this gene enabled?.</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#genotype-instance_method" title="#genotype (instance method)">- (Object) <strong>genotype</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>parent genotype.</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#in_neuron-instance_method" title="#in_neuron (instance method)">- (Object) <strong>in_neuron</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried).</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#innovation-instance_method" title="#innovation (instance method)">- (Object) <strong>innovation</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>innovation number.</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#out_neuron-instance_method" title="#out_neuron (instance method)">- (Object) <strong>out_neuron</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried).</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#weight-instance_method" title="#weight (instance method)">- (Object) <strong>weight</strong> </a> </span> <span class="summary_desc"><div class='inline'>
<p>weight of the connection.</p> </div></span>
</li>
</ul> <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="../../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3> <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> <h2> Class Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#%5B%5D-class_method" title="[] (class method)">+ (Object) <strong>[]</strong>(genotype, input, output, weight = 0.0, innov = nil) </a> </span> <span class="summary_desc"><div class='inline'>
<p>Create a new Gene and set it up fully.</p> </div></span>
</li>
</ul> <h2> Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#disabled%3F-instance_method" title="#disabled? (instance method)">- (Boolean) <strong>disabled?</strong> </a> </span> <span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#enabled%3F-instance_method" title="#enabled? (instance method)">- (Boolean) <strong>enabled?</strong> </a> </span> <span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#initialize-instance_method" title="#initialize (instance method)">- (Gene) <strong>initialize</strong>(genotype, &block) </a> </span> <span class="note title constructor">constructor</span> <span class="summary_desc"><div class='inline'>
<p>A new instance of Gene.</p> </div></span>
</li>
<li class="public "> <span class="summary_signature"> <a href="#to_s-instance_method" title="#to_s (instance method)">- (Object) <strong>to_s</strong> </a> (also: #dump_s) </span> <span class="summary_desc"><div class='inline'></div></span>
</li>
</ul> <h3 class="inherited">Methods inherited from <span class='object_link'><a href="../../NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3> <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></p> <div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> <h3 class="signature first" id="initialize-instance_method"> - (<tt><span class='object_link'><a href="" title="NEAT::Critter::Genotype::Gene (class)">Gene</a></span></tt>) <strong>initialize</strong>(genotype, &block)
</h3><div class=“docstring”>
<div class="discussion">
<p>Returns a new instance of Gene</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
247 248 249 250 251 252 253 254</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 247</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_genotype'>genotype</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span> <span class='id identifier rubyid_genotype'>genotype</span><span class='period'>.</span><span class='id identifier rubyid_controller'>controller</span> <span class='ivar'>@genotype</span> <span class='op'>=</span> <span class='id identifier rubyid_genotype'>genotype</span> <span class='ivar'>@enabled</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='ivar'>@innovation</span> <span class='op'>=</span> <span class='const'>NEAT</span><span class='op'>::</span><span class='id identifier rubyid_new_innovation'>new_innovation</span> <span class='ivar'>@in_neuron</span> <span class='op'>=</span> <span class='ivar'>@out_neuron</span> <span class='op'>=</span> <span class='kw'>nil</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='kw'>unless</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
</div>
<div id="instance_attr_details" class="attr_details"> <h2>Instance Attribute Details</h2> <span id="enabled=-instance_method"></span> <div class="method_details first"> <h3 class="signature first" id="enabled-instance_method"> - (<tt>Object</tt>) <strong>enabled</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>Is this gene enabled?</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
245 246 247</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 245</span>
<span class='kw'>def</span> <span class='id identifier rubyid_enabled'>enabled</span>
<span class='ivar'>@enabled</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<span id="genotype=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="genotype-instance_method"> - (<tt>Object</tt>) <strong>genotype</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>parent genotype</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
233 234 235</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 233</span>
<span class='kw'>def</span> <span class='id identifier rubyid_genotype'>genotype</span>
<span class='ivar'>@genotype</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<span id="in_neuron=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="in_neuron-instance_method"> - (<tt>Object</tt>) <strong>in_neuron</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
240 241 242</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 240</span>
<span class='kw'>def</span> <span class='id identifier rubyid_in_neuron'>in_neuron</span>
<span class='ivar'>@in_neuron</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<span id="innovation=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="innovation-instance_method"> - (<tt>Object</tt>) <strong>innovation</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>innovation number</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
236 237 238</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 236</span>
<span class='kw'>def</span> <span class='id identifier rubyid_innovation'>innovation</span>
<span class='ivar'>@innovation</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<span id="out_neuron=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="out_neuron-instance_method"> - (<tt>Object</tt>) <strong>out_neuron</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
240 241 242</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 240</span>
<span class='kw'>def</span> <span class='id identifier rubyid_out_neuron'>out_neuron</span>
<span class='ivar'>@out_neuron</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<span id="weight=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="weight-instance_method"> - (<tt>Object</tt>) <strong>weight</strong>
</h3><div class=“docstring”>
<div class="discussion">
<p>weight of the connection</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
243 244 245</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 243</span>
<span class='kw'>def</span> <span class='id identifier rubyid_weight'>weight</span>
<span class='ivar'>@weight</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
</div> <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="[]-class_method"> + (<tt>Object</tt>) <strong>[]</strong>(genotype, input, output, weight = 0.0, innov = nil)
</h3><div class=“docstring”>
<div class="discussion">
<p>Create a new Gene and set it up fully. genotype – genotype input – name of input neuron connection output – name of output neuron connection weight – weight to give neuron (optional) innov – innovation number of gene (optional)</p>
</div>
</div> <div class=“tags”>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
265 266 267 268 269 270 271 272</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 265</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_genotype'>genotype</span><span class='comma'>,</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span> <span class='id identifier rubyid_weight'>weight</span> <span class='op'>=</span> <span class='float'>0.0</span><span class='comma'>,</span> <span class='id identifier rubyid_innov'>innov</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_g'>g</span> <span class='op'>=</span> <span class='const'>Gene</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_genotype'>genotype</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='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span> <span class='const'>Symbol</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_input'>input</span> <span class='op'>:</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</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='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_output'>output</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span> <span class='const'>Symbol</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>:</span> <span class='id identifier rubyid_output'>output</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_weight'>weight</span> <span class='op'>=</span> <span class='id identifier rubyid_weight'>weight</span> <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_innovation'>innovation</span> <span class='op'>=</span> <span class='id identifier rubyid_innov'>innov</span> <span class='kw'>unless</span> <span class='id identifier rubyid_innov'>innov</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>return</span> <span class='id identifier rubyid_g'>g</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
</div> <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="disabled?-instance_method"> - (<tt>Boolean</tt>) <strong>disabled?</strong>
</h3><div class=“docstring”>
<div class="discussion"> </div>
</div> <div class=“tags”>
<p class=“tag_title”>Returns:</p> <ul class=“return”>
<li> <span class='type'>(<tt>Boolean</tt>)</span> </li>
</ul>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
257</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 257</span>
<span class='kw'>def</span> <span class='id identifier rubyid_disabled?'>disabled?</span> <span class='semicolon'>;</span> <span class='kw'>not</span> <span class='id identifier rubyid_enabled?'>enabled?</span> <span class='semicolon'>;</span> <span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<div class="method_details "> <h3 class="signature " id="enabled?-instance_method"> - (<tt>Boolean</tt>) <strong>enabled?</strong>
</h3><div class=“docstring”>
<div class="discussion"> </div>
</div> <div class=“tags”>
<p class=“tag_title”>Returns:</p> <ul class=“return”>
<li> <span class='type'>(<tt>Boolean</tt>)</span> </li>
</ul>
</div><table class=“source_code”>
<tr> <td> <pre class="lines">
256</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 256</span>
<span class='kw'>def</span> <span class='id identifier rubyid_enabled?'>enabled?</span> <span class='semicolon'>;</span> <span class='ivar'>@enabled</span> <span class='semicolon'>;</span> <span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
<div class="method_details "> <h3 class="signature " id="to_s-instance_method"> - (<tt>Object</tt>) <strong>to_s</strong> <span class="aliases">Also known as: <span class="names"><span id='dump_s-instance_method'>dump_s</span></span> </span>
</h3><table class=“source_code”>
<tr> <td> <pre class="lines">
274 275 276</pre>
</td> <td> <pre class="code"><span class="info file"># File 'lib/rubyneat/critter.rb', line 274</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
<span class='kw'>super</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[i%s,w%s,%s]</span><span class='tstring_end'>"</span></span> <span class='op'>%</span> <span class='lbracket'>[</span><span class='ivar'>@innovation</span><span class='comma'>,</span> <span class='ivar'>@weight</span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enabled?'>enabled?</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
</td> </tr>
</table> </div>
</div>
</div>
<div id="footer"> Generated on Sun Mar 16 16:36:51 2014 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.8.7.3 (ruby-2.1.1).
</div>
</body>
</html>