| [286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
|---|
| [1258] | 2 | // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. |
|---|
| [286] | 3 | // See LICENSE.txt for details. |
|---|
| [109] | 4 | |
|---|
| [779] | 5 | #ifndef _F1_CONV_H_ |
|---|
| 6 | #define _F1_CONV_H_ |
|---|
| [109] | 7 | |
|---|
| [121] | 8 | #include <frams/genetics/genoconv.h> |
|---|
| [109] | 9 | #include <frams/model/model.h> |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| [408] | 12 | Official Framsticks f1 -> f0 converter. |
|---|
| [109] | 13 | Source code is published as educational example, but currently not |
|---|
| 14 | well documented. |
|---|
| 15 | This converter features building creature using Model class |
|---|
| 16 | and some advanced tricks (changing model data during construction). |
|---|
| 17 | Final f0 genotype is generated by model class. |
|---|
| 18 | |
|---|
| [287] | 19 | <b>SDK 1.0.5 NN extension: (for Framsticks 2.0)</B> |
|---|
| [109] | 20 | |
|---|
| 21 | Until now, only the "standard" Framsticks v1 neuron classes could be used. |
|---|
| [287] | 22 | Starting with SDK 1.0.5 you can use all neuron types. |
|---|
| [109] | 23 | |
|---|
| 24 | \b Syntax: [classname , input_or_parameter:weight , input_or_parameter:weight , ...] |
|---|
| 25 | |
|---|
| 26 | The classname is optional, the default class will be used if it is omitted. |
|---|
| 27 | Note the comma after \b classname. It must be present if you provide the classname. |
|---|
| 28 | This is to distinguish between old muscle syntax and new classname specification: |
|---|
| 29 | - "[|,0:1]" is the neuron of class "|" (bend muscle) with one self connection. |
|---|
| 30 | \image html nn-ex1.gif |
|---|
| 31 | - "[|0:1]" describes the default neuron class (N) connected with the bend muscle (|). |
|---|
| 32 | \image html nn-ex2.gif |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | Neuron parameters can be specified along with inputs, eg: "[myclass,param1:34,param2:56]" |
|---|
| 36 | The names beginning with UPPER case character are assumed to be neuron classes. |
|---|
| 37 | "[myclass,g:1.23,G:2.34]" - the first 'g' is the parameter, the second one is the receptor |
|---|
| 38 | G ("gyroscope"). |
|---|
| 39 | |
|---|
| 40 | Another example: |
|---|
| 41 | |
|---|
| [671] | 42 | "X[G][-1:2.3][-2:3.4]" - The first neuron is the standalone G receptor. Other neuron can use its output |
|---|
| [109] | 43 | signal by specifying it as regular input ("-1:2.3" and "-2:3.4"). This NN contains 3 neurons. |
|---|
| 44 | \image html nn-ex3.gif |
|---|
| 45 | |
|---|
| 46 | "X[G:2.3][G:3.4]" - with the old syntax it is impossible to connect 2 neurons with the same gyroscope, |
|---|
| 47 | because everything inside brackets is private to the neuron, others can't refer to it. |
|---|
| 48 | Adding another neuron with "G" input will add another gyroscope object. This NN contains 4 neurons |
|---|
| 49 | (or 2 neurons if you try it in Framsticks v1). |
|---|
| [671] | 50 | \image html nn-ex4.gif |
|---|
| 51 | |
|---|
| 52 | */ |
|---|
| [1258] | 53 | |
|---|
| 54 | struct GenoConv_f1_Settings |
|---|
| 55 | { |
|---|
| 56 | paInt modifier_compatibility, cq_mod_influence, branch_muscle_range; |
|---|
| 57 | |
|---|
| 58 | static constexpr int MODIF_COMPAT_LEGACY = 0; |
|---|
| 59 | static constexpr int MODIF_COMPAT_ALL_CHANGE_05 = 1; |
|---|
| 60 | |
|---|
| 61 | static constexpr int CQ_INFLUENCE_OLD = 0; |
|---|
| 62 | static constexpr int CQ_INFLUENCE_NEW = 1; |
|---|
| 63 | |
|---|
| 64 | static constexpr int MUSCLE_RANGE_ORIGINAL = 0; |
|---|
| 65 | static constexpr int MUSCLE_RANGE_STRICT = 1; |
|---|
| 66 | static constexpr int MUSCLE_RANGE_UNLIMITED = 2; |
|---|
| 67 | }; |
|---|
| 68 | |
|---|
| [671] | 69 | class GenoConv_f1 : public GenoConverter |
|---|
| [109] | 70 | { |
|---|
| 71 | public: |
|---|
| [1258] | 72 | GenoConv_f1(); |
|---|
| [732] | 73 | SString convert(SString &i, MultiMap *map, bool using_checkpoints); |
|---|
| [671] | 74 | ~GenoConv_f1() {} |
|---|
| [1258] | 75 | |
|---|
| 76 | GenoConv_f1_Settings settings; |
|---|
| 77 | |
|---|
| 78 | Param param; |
|---|
| 79 | ParamInterface* getParam() { return ¶m; } |
|---|
| [109] | 80 | }; |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | #endif |
|---|