<!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::Population

  &mdash; 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 (P)</a> &raquo;
  <span class='title'><span class='object_link'><a href="../NEAT.html" title="NEAT (module)">NEAT</a></span></span>
   &raquo; 
  <span class="title">Population</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::Population

</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::Population</li>

    </ul>
    <a href="#" class="inheritanceTree">show all</a>

  </dd>

<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">lib/rubyneat/population.rb</dd>

</dl> <div class=“clear”></div>

<h2>Overview</h2><div class=“docstring”>

<div class="discussion">

<h1 id=“label-Population+of+NEAT+Critters.”>Population of NEAT Critters.</h1>

<p>The Population In ourselves we have the pool of neurons the critters all use. the pool of neurons are indirects, of course, as during phenotype expression, all the phenotypes shall be created individually.</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="#critters-instance_method" title="#critters (instance method)">- (Object) <strong>critters</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>list of critter in this population.</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#fitness-instance_method" title="#fitness (instance method)">- (Object) <strong>fitness</strong> </a>

</span>

    <span class="note title readonly">readonly</span>

  <span class="summary_desc"><div class='inline'>

<p>Overall population fitness and novelty.</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#hidden_neurons-instance_method" title="#hidden_neurons (instance method)">- (Object) <strong>hidden_neurons</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>List of possible neuron classes for hidden neurons.</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#input_neurons-instance_method" title="#input_neurons (instance method)">- (Object) <strong>input_neurons</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Ordered list or hash of input neuron classes (all critters generated here shall have this).</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#novelty-instance_method" title="#novelty (instance method)">- (Object) <strong>novelty</strong> </a>

</span>

    <span class="note title readonly">readonly</span>

  <span class="summary_desc"><div class='inline'>

<p>Overall population fitness and novelty.</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#output_neurons-instance_method" title="#output_neurons (instance method)">- (Object) <strong>output_neurons</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Ordered list or hash of output neuron classes (all critters generated here shall have this).</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#species-instance_method" title="#species (instance method)">- (Object) <strong>species</strong> </a>

</span>

    <span class="note title readonly">readonly</span>

  <span class="summary_desc"><div class='inline'>

<p>Hash list of species lists.</p> </div></span>

</li>

    <li class="public ">
<span class="summary_signature">

    <a href="#traits-instance_method" title="#traits (instance method)">- (Object) <strong>traits</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Returns the value of attribute traits.</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="#compactify%21-class_method" title="compactify! (class method)">+ (Object) <strong>compactify!</strong>(parm) </a>

</span>

  <span class="summary_desc"><div class='inline'></div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#evaluate%21-class_method" title="evaluate! (class method)">+ (Object) <strong>evaluate!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'></div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#member%3F-class_method" title="member? (class method)">+ (Boolean) <strong>member?</strong>(crit) </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>lists keyed by representative critter.</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="#analyze%21-instance_method" title="#analyze! (instance method)">- (Object) <strong>analyze!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Alalyze evaluation results.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#best_critter-instance_method" title="#best_critter (instance method)">- (Object) <strong>best_critter</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>The “best critter” is the critter with the lowest (closet to zero) fitness rating.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#dump_s-instance_method" title="#dump_s (instance method)">- (Object) <strong>dump_s</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'></div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#evaluate%21-instance_method" title="#evaluate! (instance method)">- (Object) <strong>evaluate!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Called for each sequence.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#evolve-instance_method" title="#evolve (instance method)">- (Object) <strong>evolve</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Call this after evaluation.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#express%21-instance_method" title="#express! (instance method)">- (Object) <strong>express!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Express the entire population.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#initialize-instance_method" title="#initialize (instance method)">- (Population) <strong>initialize</strong>(c, &amp;block) </a>

</span>

  <span class="note title constructor">constructor</span>

  <span class="summary_desc"><div class='inline'>

<p>Create initial (ramdom) population of critters.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#initialize_for_recurrence%21-instance_method" title="#initialize_for_recurrence! (instance method)">- (Object) <strong>initialize_for_recurrence!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Make sure all critters are reset and prepared for recurrent network evaluation.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#mutate%21-instance_method" title="#mutate! (instance method)">- (Object) <strong>mutate!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Mutate the genes and neurons.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#report-instance_method" title="#report (instance method)">- (Object) <strong>report</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<h2 id=“label-Generate+a+report+on+the+state+of+this+population.”>Generate a report on the state of this population.</h2> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#speciate%21-instance_method" title="#speciate! (instance method)">- (Object) <strong>speciate!</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Group critters into species Note that the @species objects have useful singleton methods: * @species.member? – checks all of the lists for membership, not just the hash * @<a href=“crit”>species</a>.fitness – fitness of the entire species.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#worst_critter-instance_method" title="#worst_critter (instance method)">- (Object) <strong>worst_critter</strong> </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>The “worst critter” is the critter with the highest (away from zero) fitness rating.</p> </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>, <span class='object_link'><a href="NeatOb.html#to_s-instance_method" title="NEAT::NeatOb#to_s (method)">#to_s</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::Population (class)">Population</a></span></tt>) <strong>initialize</strong>(c, &amp;block)

</h3><div class=“docstring”>

<div class="discussion">

<p>Create initial (ramdom) population of critters</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

37 38 39 40 41 42 43 44 45 46 47 48 49 50</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 37</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>

<span class='kw'>super</span>
<span class='ivar'>@input_neurons</span> <span class='op'>=</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_neural_inputs'>neural_inputs</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span>
<span class='ivar'>@output_neurons</span> <span class='op'>=</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_neural_outputs'>neural_outputs</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span>
<span class='ivar'>@hidden_neurons</span> <span class='op'>=</span> <span class='kw'>unless</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_neural_hidden'>neural_hidden</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
                    <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_neural_hidden'>neural_hidden</span>
                  <span class='kw'>else</span>
                    <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_neuron_catalog'>neuron_catalog</span><span class='period'>.</span><span class='id identifier rubyid_keep_if'>keep_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='kw'>not</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_input?'>input?</span><span class='rbrace'>}</span>
                  <span class='kw'>end</span>
<span class='ivar'>@critters</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='int'>0</span> <span class='op'>...</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span><span class='period'>.</span><span class='id identifier rubyid_start_population_size'>start_population_size</span> <span class='op'>||</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span><span class='period'>.</span><span class='id identifier rubyid_population_size'>population_size</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span>
  <span class='const'>Critter</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
<span class='kw'>end</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="critters=-instance_method"></span>
    <div class="method_details first">
<h3 class="signature first" id="critters-instance_method">

  - (<tt>Object</tt>) <strong>critters</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>list of critter in this population</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

25 26 27</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 25</span>

<span class='kw'>def</span> <span class='id identifier rubyid_critters'>critters</span>

<span class='ivar'>@critters</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id=""></span>
    <div class="method_details ">
<h3 class="signature " id="fitness-instance_method">

  - (<tt>Object</tt>) <strong>fitness</strong>  <span class="extras">(readonly)</span>

</h3><div class=“docstring”>

<div class="discussion">

<p>Overall population fitness and novelty</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

28 29 30</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 28</span>

<span class='kw'>def</span> <span class='id identifier rubyid_fitness'>fitness</span>

<span class='ivar'>@fitness</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id="hidden_neurons=-instance_method"></span>
    <div class="method_details ">
<h3 class="signature " id="hidden_neurons-instance_method">

  - (<tt>Object</tt>) <strong>hidden_neurons</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>List of possible neuron classes for hidden neurons.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

16 17 18</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 16</span>

<span class='kw'>def</span> <span class='id identifier rubyid_hidden_neurons'>hidden_neurons</span>

<span class='ivar'>@hidden_neurons</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id="input_neurons=-instance_method"></span>
    <div class="method_details ">
<h3 class="signature " id="input_neurons-instance_method">

  - (<tt>Object</tt>) <strong>input_neurons</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Ordered list or hash of input neuron classes (all critters generated here shall have this)</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

13 14 15</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 13</span>

<span class='kw'>def</span> <span class='id identifier rubyid_input_neurons'>input_neurons</span>

<span class='ivar'>@input_neurons</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id=""></span>
    <div class="method_details ">
<h3 class="signature " id="novelty-instance_method">

  - (<tt>Object</tt>) <strong>novelty</strong>  <span class="extras">(readonly)</span>

</h3><div class=“docstring”>

<div class="discussion">

<p>Overall population fitness and novelty</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

28 29 30</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 28</span>

<span class='kw'>def</span> <span class='id identifier rubyid_novelty'>novelty</span>

<span class='ivar'>@novelty</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id="output_neurons=-instance_method"></span>
    <div class="method_details ">
<h3 class="signature " id="output_neurons-instance_method">

  - (<tt>Object</tt>) <strong>output_neurons</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Ordered list or hash of output neuron classes (all critters generated here shall have this)</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

20 21 22</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 20</span>

<span class='kw'>def</span> <span class='id identifier rubyid_output_neurons'>output_neurons</span>

<span class='ivar'>@output_neurons</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id=""></span>
    <div class="method_details ">
<h3 class="signature " id="species-instance_method">

  - (<tt>Object</tt>) <strong>species</strong>  <span class="extras">(readonly)</span>

</h3><div class=“docstring”>

<div class="discussion">

<p>Hash list of species lists</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

31 32 33</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 31</span>

<span class='kw'>def</span> <span class='id identifier rubyid_species'>species</span>

<span class='ivar'>@species</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <span id="traits=-instance_method"></span>
    <div class="method_details ">
<h3 class="signature " id="traits-instance_method">

  - (<tt>Object</tt>) <strong>traits</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Returns the value of attribute traits</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

22 23 24</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 22</span>

<span class='kw'>def</span> <span class='id identifier rubyid_traits'>traits</span>

<span class='ivar'>@traits</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="compactify!-class_method">

  + (<tt>Object</tt>) <strong>compactify!</strong>(parm)

</h3><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 102</span>

<span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_compactify!'>compactify!</span><span class='lparen'>(</span><span class='id identifier rubyid_parm'>parm</span><span class='rparen'>)</span>

<span class='id identifier rubyid_mutt'>mutt</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:mutt</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</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_splist'>splist</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_splist'>splist</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</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_splist'>splist</span><span class='op'>|</span>
  <span class='id identifier rubyid_splist'>splist</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>&gt;=</span> <span class='id identifier rubyid_parm'>parm</span><span class='period'>.</span><span class='id identifier rubyid_smallest_species'>smallest_species</span>
<span class='rbrace'>}</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_splist'>splist</span><span class='op'>|</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_k'>k</span>
  <span class='id identifier rubyid_splist'>splist</span>
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>

<span class='comment'># FIXME this code is not dry!!!!

</span> <span class='kw'>def</span> <span class='id identifier rubyid_mutt'>mutt</span><span class='period'>.</span><span class='id identifier rubyid_fitness='>fitness=</span><span class='lparen'>(</span><span class='id identifier rubyid_fit'>fit</span><span class='rparen'>)</span>

  <span class='ivar'>@fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_fit'>fit</span>
<span class='kw'>end</span>

<span class='kw'>def</span> <span class='id identifier rubyid_mutt'>mutt</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span>
  <span class='ivar'>@fitness</span>
<span class='kw'>end</span>

<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='symbol'>:mutt</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:mutt</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="evaluate!-class_method">

  + (<tt>Object</tt>) <strong>evaluate!</strong>

</h3><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

96 97 98 99 100</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 96</span>

<span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_evaluate!'>evaluate!</span>

<span class='kw'>self</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_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_sp'>sp</span><span class='op'>|</span>
  <span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_sp'>sp</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_crit'>crit</span><span class='op'>|</span> <span class='id identifier rubyid_crit'>crit</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='op'>+</span><span class='id identifier rubyid_b'>b</span><span class='rbrace'>}</span> <span class='op'>/</span> <span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="member?-class_method">

  + (<tt>Boolean</tt>) <strong>member?</strong>(crit)

</h3><div class=“docstring”>

<div class="discussion">

<p>lists keyed by representative critter</p>

</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">

92 93 94</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 92</span>

<span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_crit'>crit</span><span class='rparen'>)</span>

<span class='kw'>super</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_crit'>crit</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='kw'>self</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_li'>li</span><span class='op'>|</span> <span class='id identifier rubyid_li'>li</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span> <span class='id identifier rubyid_crit'>crit</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_t1'>t1</span><span class='comma'>,</span> <span class='id identifier rubyid_t2'>t2</span><span class='op'>|</span> <span class='id identifier rubyid_t1'>t1</span> <span class='kw'>or</span> <span class='id identifier rubyid_t2'>t2</span> <span class='rbrace'>}</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="analyze!-instance_method">

  - (<tt>Object</tt>) <strong>analyze!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Alalyze evaluation results.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

74 75 76</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 74</span>

<span class='kw'>def</span> <span class='id identifier rubyid_analyze!'>analyze!</span>

<span class='ivar'>@critters</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_critter'>critter</span><span class='op'>|</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_evaluator'>evaluator</span><span class='period'>.</span><span class='id identifier rubyid_analyze_for_fitness!'>analyze_for_fitness!</span> <span class='id identifier rubyid_critter'>critter</span> <span class='rbrace'>}</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="best_critter-instance_method">

  - (<tt>Object</tt>) <strong>best_critter</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>The “best critter” is the critter with the lowest (closet to zero) fitness rating.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

176 177 178 179 180 181 182</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 176</span>

<span class='kw'>def</span> <span class='id identifier rubyid_best_critter'>best_critter</span>

<span class='kw'>unless</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_compare_func'>compare_func</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='ivar'>@critters</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_compare_func'>compare_func</span><span class='period'>.</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>else</span>
  <span class='ivar'>@critters</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rbrace'>}</span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="dump_s-instance_method">

  - (<tt>Object</tt>) <strong>dump_s</strong>

</h3><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

194 195 196</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 194</span>

<span class='kw'>def</span> <span class='id identifier rubyid_dump_s'>dump_s</span>

<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'>\npopulation:\n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='ivar'>@critters</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_crit'>crit</span><span class='op'>|</span> <span class='id identifier rubyid_crit'>crit</span><span class='period'>.</span><span class='id identifier rubyid_dump_s'>dump_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='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="evaluate!-instance_method">

  - (<tt>Object</tt>) <strong>evaluate!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Called for each sequence.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

69 70 71</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 69</span>

<span class='kw'>def</span> <span class='id identifier rubyid_evaluate!'>evaluate!</span>

<span class='ivar'>@critters</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_critter'>critter</span><span class='op'>|</span> <span class='id identifier rubyid_critter'>critter</span><span class='period'>.</span><span class='id identifier rubyid_evaluate!'>evaluate!</span> <span class='rbrace'>}</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="evolve-instance_method">

  - (<tt>Object</tt>) <strong>evolve</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Call this after evaluation. Returns a newly-evolved population.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

80 81 82</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 80</span>

<span class='kw'>def</span> <span class='id identifier rubyid_evolve'>evolve</span>

<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_evolve'>evolve</span> <span class='kw'>self</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="express!-instance_method">

  - (<tt>Object</tt>) <strong>express!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Express the entire population.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

64 65 66</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 64</span>

<span class='kw'>def</span> <span class='id identifier rubyid_express!'>express!</span>

<span class='ivar'>@critters</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_critter'>critter</span><span class='op'>|</span> <span class='id identifier rubyid_critter'>critter</span><span class='period'>.</span><span class='id identifier rubyid_express!'>express!</span> <span class='rbrace'>}</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="initialize_for_recurrence!-instance_method">

  - (<tt>Object</tt>) <strong>initialize_for_recurrence!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Make sure all critters are reset and prepared for recurrent network evaluation.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

54 55 56</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 54</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize_for_recurrence!'>initialize_for_recurrence!</span>

<span class='ivar'>@critters</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_crit'>crit</span><span class='op'>|</span> <span class='id identifier rubyid_crit'>crit</span><span class='period'>.</span><span class='id identifier rubyid_initialize_neurons!'>initialize_neurons!</span><span class='rbrace'>}</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="mutate!-instance_method">

  - (<tt>Object</tt>) <strong>mutate!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Mutate the genes and neurons.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

59 60 61</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 59</span>

<span class='kw'>def</span> <span class='id identifier rubyid_mutate!'>mutate!</span>

<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_mutate!'>mutate!</span> <span class='kw'>self</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="report-instance_method">

  - (<tt>Object</tt>) <strong>report</strong>

</h3><div class=“docstring”>

<div class="discussion">

<h2 id=“label-Generate+a+report+on+the+state+of+this+population.”>Generate a report on the state of this population.</h2>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

165 166 167 168 169 170 171 172</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 165</span>

<span class='kw'>def</span> <span class='id identifier rubyid_report'>report</span>

<span class='lbrace'>{</span>
    <span class='label'>fitness:</span>         <span class='id identifier rubyid_report_fitness'>report_fitness</span><span class='comma'>,</span>
    <span class='label'>fitness_species:</span> <span class='id identifier rubyid_report_fitness_species'>report_fitness_species</span><span class='comma'>,</span>
    <span class='label'>best_critter:</span>    <span class='id identifier rubyid_report_best_fit'>report_best_fit</span><span class='comma'>,</span>
    <span class='label'>worst_critter:</span>   <span class='id identifier rubyid_report_worst_fit'>report_worst_fit</span><span class='comma'>,</span>
<span class='rbrace'>}</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="speciate!-instance_method">

  - (<tt>Object</tt>) <strong>speciate!</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>Group critters into species Note that the @species objects have useful singleton methods:</p> <ul><li> <p>@species.member? – checks all of the lists for membership, not just the hash</p> </li><li> <p>@<a href=“crit”>species</a>.fitness – fitness of the entire species</p> </li></ul>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 89</span>

<span class='kw'>def</span> <span class='id identifier rubyid_speciate!'>speciate!</span>

<span class='comment'># We blow away existing species and create our own member? function

</span> <span class='ivar'>@species</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='comment'># lists keyed by representative critter </span> <span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_crit'>crit</span><span class='rparen'>)</span>

  <span class='kw'>super</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span><span class='lparen'>(</span><span class='id identifier rubyid_crit'>crit</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='kw'>self</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_li'>li</span><span class='op'>|</span> <span class='id identifier rubyid_li'>li</span><span class='period'>.</span><span class='id identifier rubyid_member?'>member?</span> <span class='id identifier rubyid_crit'>crit</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_t1'>t1</span><span class='comma'>,</span> <span class='id identifier rubyid_t2'>t2</span><span class='op'>|</span> <span class='id identifier rubyid_t1'>t1</span> <span class='kw'>or</span> <span class='id identifier rubyid_t2'>t2</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>

<span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_evaluate!'>evaluate!</span>
  <span class='kw'>self</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_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_sp'>sp</span><span class='op'>|</span>
    <span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_sp'>sp</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_crit'>crit</span><span class='op'>|</span> <span class='id identifier rubyid_crit'>crit</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='op'>+</span><span class='id identifier rubyid_b'>b</span><span class='rbrace'>}</span> <span class='op'>/</span> <span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
  <span class='kw'>end</span>
<span class='kw'>end</span>

<span class='kw'>def</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_compactify!'>compactify!</span><span class='lparen'>(</span><span class='id identifier rubyid_parm'>parm</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_mutt'>mutt</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:mutt</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</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_splist'>splist</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_splist'>splist</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</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_splist'>splist</span><span class='op'>|</span>
    <span class='id identifier rubyid_splist'>splist</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>&gt;=</span> <span class='id identifier rubyid_parm'>parm</span><span class='period'>.</span><span class='id identifier rubyid_smallest_species'>smallest_species</span>
  <span class='rbrace'>}</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_splist'>splist</span><span class='op'>|</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_k'>k</span>
    <span class='id identifier rubyid_splist'>splist</span>
  <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>

  <span class='comment'># FIXME this code is not dry!!!!

</span> <span class='kw'>def</span> <span class='id identifier rubyid_mutt'>mutt</span><span class='period'>.</span><span class='id identifier rubyid_fitness='>fitness=</span><span class='lparen'>(</span><span class='id identifier rubyid_fit'>fit</span><span class='rparen'>)</span>

    <span class='ivar'>@fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_fit'>fit</span>
  <span class='kw'>end</span>

  <span class='kw'>def</span> <span class='id identifier rubyid_mutt'>mutt</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span>
    <span class='ivar'>@fitness</span>
  <span class='kw'>end</span>

  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='symbol'>:mutt</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='symbol'>:mutt</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span>

<span class='comment'># Some convience parms

</span> <span class='id identifier rubyid_parm'>parm</span> <span class='op'>=</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span>

<span class='comment'># And so now we iterate...

</span> <span class='ivar'>@critters</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_crit'>crit</span><span class='op'>|</span>

<span class='id identifier rubyid_wearein'>wearein</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@species</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_ck'>ck</span><span class='comma'>,</span> <span class='id identifier rubyid_list'>list</span><span class='op'>|</span>
  <span class='id identifier rubyid_delta'>delta</span> <span class='op'>=</span> <span class='id identifier rubyid_crit'>crit</span><span class='period'>.</span><span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_ck'>ck</span><span class='rparen'>)</span>
  <span class='comment'>#log.debug { &quot;delta for #{crit} and #{ck} is #{delta}&quot; }

</span> <span class='kw'>if</span> <span class='id identifier rubyid_delta'>delta</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_parm'>parm</span><span class='period'>.</span><span class='id identifier rubyid_compatibility_threshold'>compatibility_threshold</span>

    <span class='id identifier rubyid_list'>list</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_crit'>crit</span>
    <span class='id identifier rubyid_wearein'>wearein</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>break</span>
  <span class='kw'>end</span>
<span class='kw'>end</span>

<span class='comment'># New species?

</span> <span class='kw'>unless</span> <span class='id identifier rubyid_wearein'>wearein</span>

    <span class='ivar'>@species</span><span class='lbracket'>[</span><span class='id identifier rubyid_crit'>crit</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_species'>species</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_crit'>crit</span><span class='rbracket'>]</span>
    <span class='kw'>def</span> <span class='id identifier rubyid_species'>species</span><span class='period'>.</span><span class='id identifier rubyid_fitness='>fitness=</span><span class='lparen'>(</span><span class='id identifier rubyid_fit'>fit</span><span class='rparen'>)</span>
      <span class='ivar'>@fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_fit'>fit</span>
    <span class='kw'>end</span>
    <span class='kw'>def</span> <span class='id identifier rubyid_species'>species</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span>
      <span class='ivar'>@fitness</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span>

<span class='comment'># Compactify the species if less than smallest_species

</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_compactify!'>compactify!</span> <span class='id identifier rubyid_parm'>parm</span>

<span class='comment'># And now we evaluate all species for fitness...

</span> <span class='ivar'>@species</span><span class='period'>.</span><span class='id identifier rubyid_evaluate!'>evaluate!</span>

<span class='comment'># Dump for debugging reasons

</span> <span class='ivar'>@species</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_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_sp'>sp</span><span class='op'>|</span>

  <span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&gt;&gt; Species </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='embexpr_end'>}</span><span class='tstring_content'> has </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='embexpr_end'>}</span><span class='tstring_content'> members with a </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sp'>sp</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='embexpr_end'>}</span><span class='tstring_content'> fitness</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="worst_critter-instance_method">

  - (<tt>Object</tt>) <strong>worst_critter</strong>

</h3><div class=“docstring”>

<div class="discussion">

<p>The “worst critter” is the critter with the highest (away from zero) fitness rating.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

186 187 188 189 190 191 192</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/population.rb', line 186</span>

<span class='kw'>def</span> <span class='id identifier rubyid_worst_critter'>worst_critter</span>

<span class='kw'>unless</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_compare_func'>compare_func</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='ivar'>@critters</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_compare_func'>compare_func</span><span class='period'>.</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>else</span>
  <span class='ivar'>@critters</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span><span class='rbrace'>}</span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

</div>

</div>

  <div id="footer">
Generated on Sun Mar 16 16:36:52 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>