Created by Scott Robert Ladd at Coyote Gulch Productions.
00001 //--------------------------------------------------------------------- 00002 // Algorithmic Conjurings @ http://www.coyotegulch.com 00003 // Evocosm -- An Object-Oriented Framework for Evolutionary Algorithms 00004 // 00005 // organism.h 00006 //--------------------------------------------------------------------- 00007 // 00008 // Copyright 1996, 1999, 2002, 2003, 2004, 2005 Scott Robert Ladd 00009 // 00010 // This program is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU General Public License as published by 00012 // the Free Software Foundation; either version 2 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public License 00021 // along with this program; if not, write to the 00022 // Free Software Foundation, Inc. 00023 // 59 Temple Place - Suite 330 00024 // Boston, MA 02111-1307, USA. 00025 // 00026 //----------------------------------------------------------------------- 00027 // 00028 // For more information on this software package, please visit 00029 // Scott's web site, Coyote Gulch Productions, at: 00030 // 00031 // http://www.coyotegulch.com 00032 // 00033 //----------------------------------------------------------------------- 00034 00035 #if !defined(LIBEVOCOSM_ORGANISM_H) 00036 #define LIBEVOCOSM_ORGANISM_H 00037 00038 // Standard C++ Library 00039 #include <cstddef> 00040 00041 // libevocosm 00042 #include "evocommon.h" 00043 00044 namespace libevocosm 00045 { 00046 using std::vector; 00047 00049 00059 template <typename Genotype> 00060 class organism : protected globals 00061 { 00062 protected: 00064 double m_fitness; 00065 00067 Genotype m_genes; 00068 00069 public: 00071 00074 organism() 00075 : m_fitness(0.0), 00076 m_genes() 00077 { 00078 // nada 00079 } 00080 00082 00086 organism(const Genotype & a_value) 00087 : m_fitness(0.0), 00088 m_genes(a_value) 00089 { 00090 // nada 00091 } 00092 00094 00098 organism(const organism & a_source) 00099 : m_fitness(a_source.m_fitness), 00100 m_genes(a_source.m_genes) 00101 { 00102 // nada 00103 } 00104 00106 00111 organism(const organism & a_parent1, const organism & a_parent2) 00112 : m_fitness(a_parent1.m_fitness), 00113 m_genes(a_parent1.m_genes,a_parent2.m_genes) 00114 { 00115 // nada 00116 } 00117 00119 00126 virtual ~organism() 00127 { 00128 // nada 00129 } 00130 00132 00137 organism & operator = (const organism & a_source) 00138 { 00139 m_fitness = a_source.m_fitness; 00140 m_genes = a_source.m_genes; 00141 return *this; 00142 } 00143 00145 00150 virtual bool operator < (const organism & a_right) const 00151 { 00152 return (m_fitness > a_right.m_fitness); 00153 } 00154 00156 00161 virtual void reset_all() 00162 { 00163 m_fitness = 0.0; 00164 } 00165 00167 00179 double & fitness() 00180 { 00181 return m_fitness; 00182 } 00183 00185 00197 double fitness() const 00198 { 00199 return m_fitness; 00200 } 00201 00203 00212 Genotype & genes() 00213 { 00214 return m_genes; 00215 } 00216 00218 00227 const Genotype & genes() const 00228 { 00229 return m_genes; 00230 } 00231 }; 00232 00233 }; 00234 00235 #endif
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.