source: cpp/frams/genetics/preconfigured.h @ 1182

Last change on this file since 1182 was 976, checked in by Maciej Komosinski, 4 years ago

Renamed three "solid-compatible" receptors to have more informative names

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _PRECONFIGURED_GENETICS_H_
6#define _PRECONFIGURED_GENETICS_H_
7
8#include "genman.h"
9#include "defgenoconv.h"
10
11/** This class handles a typical initialization procedure and configuration of genetics:
12- adds converters between genetic formats as configured by gen-config.h,
13- validation of genotypes by dedicated genetic operators, or by conversion to f0 if no genetic operator is found that can validate a genotype.
14*/
15class PreconfiguredGenetics
16{
17public:
18        DefaultGenoConvManager gcm;
19        GenMan genman;
20        Geno::Validators validators;
21        ModelGenoValidator model_validator; //validation through conversion
22
23        PreconfiguredGenetics()
24        {
25                gcm.addDefaultConverters(); //without converters, the application would only handle "format 0" genotypes
26                if (Geno::useConverters(&gcm) != NULL)
27                        logPrintf("PreconfiguredGenetics", "init", LOG_WARN, "Geno converters already configured"); //someone is using multiple PreconfiguredGenetics objects? (or other potentially unsafe configuration)
28                if (Geno::useValidators(&validators) != NULL)
29                        logPrintf("PreconfiguredGenetics", "init", LOG_WARN, "Geno validators already configured");
30                static const char* genactive_classes[] = { "N", "G", "Gpart", "T", "S", "*", "|", "@", "M", NULL };
31                NeuroClass::resetActive();
32                NeuroClass::setGenActive(genactive_classes);
33                validators += &genman; //primary validation: use the extended validity checking (through dedicated genetic operators)
34                validators += &model_validator; //secondary validation: this simple validator handles all cases when there is no dedicated genetic validation operator, but a converter for a particular format is available. Converters may be less strict in detecting invalid genotypes but using them and checking whether they produced a valid f0 genotype is also some way to tell whether the initial genotype was valid. Otherwise, without dedicated genetic validation operator, we would have no validity check at all.
35        }
36
37        ~PreconfiguredGenetics()
38        {
39                Geno::useConverters(NULL);
40                Geno::useValidators(NULL);
41        }
42};
43
44#endif
Note: See TracBrowser for help on using the repository browser.