Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

geno_fx.h

Go to the documentation of this file.
00001 // This file is a part of Framsticks GenoFX library.
00002 // Copyright (C) 2002  Maciej Komosinski.  See LICENSE.txt for details.
00003 // Refer to http://www.frams.alife.pl/ for further information.
00004 
00005 #ifndef _GENO_FX_H_
00006 #define _GENO_FX_H_
00007 
00008 #include "nonstd.h"
00009 #include "modelparts.h"
00010 
00015 #define GENOPER_OK          0 
00016 #define GENOPER_OPFAIL     -1 
00017 #define GENOPER_REPAIR     -2 
00018 #define GENOPER_NOOPER     -3 
00019 
00020 
00021 
00023 #define GENSTYLE_NONE       0 
00024 #define GENSTYLE_INVALID    1 
00025 #define GENSTYLE_BOLD       2 
00026 #define GENSTYLE_ITALIC     4 
00027 #define GENSTYLE_STRIKEOUT  8 
00028 //UNDERLINE used to mark errors
00029 
00030 
00033 #define GENRGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
00034 #define GENSTYLE_RGBS(r,g,b,s) ((unsigned long)((unsigned char)s)<<24 | GENRGB(r,g,b))
00035 #define GENSTYLE_CS(rgb,s) ((unsigned long)((unsigned char)s)<<24 | rgb)
00036 
00037 #define GENGETSTYLE(style) ((style)>>24)
00038 #define GENGETCOLOR(style) ((style)&0x00ffffff)
00039 
00040 #define GENCOLOR_TEXT    GENRGB(0,0,0) 
00041 #define GENCOLOR_NUMBER  GENRGB(200,0,0) 
00042 
00043 
00044 
00045 
00075 class Geno_fx
00076 {
00077  public:
00078    Param par;
00079    char supported_format; 
00080    SString name; 
00081    Geno_fx() : par(empty_paramtab) {supported_format='x'; name="Default";}
00082 
00087    virtual int checkValidity(const char *geno) {return GENOPER_NOOPER;}
00088 
00094    virtual int validate(char *&geno) {return GENOPER_NOOPER;}
00095 
00127    virtual int mutate(char *&geno,float& chg) {return GENOPER_NOOPER;}
00128 
00144    virtual int crossOver(char *&g1,char *&g2,float& chg1,float& chg2) {return GENOPER_NOOPER;}
00145 
00147    virtual char* getSimplest() {return NULL;}
00148 
00155    virtual unsigned long style(const char *geno,int pos) {return GENSTYLE_RGBS(0,0,0,GENSTYLE_NONE);}
00156 
00158    virtual float similarity(const char*,const char*) {return GENOPER_NOOPER;}
00159    virtual ~Geno_fx() {} 
00160 //   virtual char getFormat() {return 255;} //returns supported genotype format, for ex. '1'
00161 //   virtual int enabled() {return 1;} // should be enabled by default
00162 
00165         static int roulette(const double *probtab,int count);   
00166    static bool getMinMaxDef(ParamInterface *p,int propindex,double &mn,double &mx,double &def); 
00167    static int selectRandomProperty(Neuro* n); 
00168    static double mutateNeuProperty(double current,Neuro *n,int propindex); 
00169    static bool mutateProperty(ParamInterface &p,int propindex); 
00170    static double mutateValue(double current,double vmin,double vmax); 
00171    static NeuroClass* getRandomNeuroClass(); 
00172    static NeuroClass* parseNeuroClass(char *&s); 
00173    static int neuroClassProp(char *&s,NeuroClass *nc,bool also_v1_N_props=false); 
00174    static bool isWS(const char c); 
00175    static void skipWS(char *&s); 
00176    static bool areAlike(char*,char*); 
00177         static char* strchrn0(const char *str,char ch); 
00178    static bool isNeuroClassName(const char firstchar); 
00179 
00180 };
00181 
00182 
00183 #endif
00184 

Generated on Sun Sep 15 00:58:39 2002 for Framsticks GenoFX by doxygen1.2.17