[1242] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/
|
---|
| 2 | // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski.
|
---|
| 3 | // See LICENSE.txt for details.
|
---|
| 4 |
|
---|
| 5 | #include <frams/genetics/geneprops.h>
|
---|
| 6 |
|
---|
| 7 | /*
|
---|
| 8 | Testing the influence of Framsticks f1/f4 modifier sequences. See also geneprops_graph.py
|
---|
| 9 |
|
---|
| 10 | Examples:
|
---|
| 11 |
|
---|
[1302] | 12 | - experimental exponential friction:
|
---|
[1242] | 13 | $ ./geneprops_test f 3 -e | sort -n -k 2
|
---|
| 14 |
|
---|
| 15 | fff 0.0158037
|
---|
| 16 | ff 0.0366025
|
---|
| 17 | Fff 0.0639754
|
---|
| 18 | f 0.1
|
---|
| 19 | fFf 0.147411
|
---|
| 20 | Ff 0.209808
|
---|
| 21 | FFf 0.291926
|
---|
| 22 | - 0.4
|
---|
| 23 | ffF 0.542233
|
---|
| 24 | fF 0.729423
|
---|
| 25 | FfF 0.975778
|
---|
| 26 | F 1.3
|
---|
| 27 | fFF 1.7267
|
---|
| 28 | FF 2.28827
|
---|
| 29 | FFF 3.02733
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | - legacy friction:
|
---|
| 33 | $ ./geneprops_test f 3 -l | sort -n -k 2
|
---|
| 34 |
|
---|
| 35 | fff 0.2048
|
---|
| 36 | ff 0.256
|
---|
| 37 | f 0.32
|
---|
| 38 | - 0.4
|
---|
| 39 | Fff 0.7168
|
---|
| 40 | fFf 0.8448
|
---|
| 41 | Ff 0.896
|
---|
| 42 | ffF 1.0048
|
---|
| 43 | fF 1.056
|
---|
| 44 | F 1.12
|
---|
| 45 | FFf 1.3568
|
---|
| 46 | FfF 1.5168
|
---|
| 47 | fFF 1.6448
|
---|
| 48 | FF 1.696
|
---|
| 49 | FFF 2.1568
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | */
|
---|
| 53 |
|
---|
| 54 | double genePropsValueForModifier(GeneProps& gp, char modifier)
|
---|
| 55 | {
|
---|
| 56 | switch (toupper(modifier))
|
---|
| 57 | {
|
---|
| 58 | case 'L': return gp.length; break;
|
---|
| 59 | case 'W': return gp.weight; break;
|
---|
| 60 | case 'F': return gp.friction; break;
|
---|
| 61 | case 'C': return gp.curvedness; break;
|
---|
| 62 | case 'Q': return gp.twist; break;
|
---|
| 63 | case 'E': return gp.energy; break;
|
---|
| 64 |
|
---|
| 65 | case 'A': return gp.assimilation; break;
|
---|
| 66 | case 'I': return gp.ingestion; break;
|
---|
| 67 | case 'S': return gp.stamina; break;
|
---|
| 68 | case 'M': return gp.muscle_power; break;
|
---|
| 69 |
|
---|
| 70 | case 'D': return gp.cred; break;
|
---|
| 71 | case 'G': return gp.cgreen; break;
|
---|
| 72 | case 'B': return gp.cblue; break;
|
---|
| 73 | }
|
---|
| 74 | return 0;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | int main(int argc, char *argv[])
|
---|
| 78 | {
|
---|
| 79 | char modifier = 'L';
|
---|
| 80 | int maxcount = 4;
|
---|
| 81 |
|
---|
[1260] | 82 | enum Function { Legacy, AllChange05, ExperimentalExponential };
|
---|
| 83 | Function fun = AllChange05;
|
---|
[1242] | 84 |
|
---|
| 85 | int argpos = 0;
|
---|
| 86 | for (int i = 1; i < argc; i++)
|
---|
| 87 | {
|
---|
| 88 | const char* arg = argv[i];
|
---|
| 89 | if (arg[0] == '-')
|
---|
| 90 | switch (arg[1])
|
---|
| 91 | {
|
---|
| 92 | case 'l': fun = Legacy; break;
|
---|
[1260] | 93 | case 'n': fun = AllChange05; break;
|
---|
| 94 | case 'e': fun = ExperimentalExponential; break;
|
---|
[1242] | 95 | case 'h': printf("%s args: [modifier [max_count]] (one of " F14_MODIFIERS ")\n"
|
---|
[1302] | 96 | "\t-l = legacy\n"
|
---|
[1260] | 97 | "\t-n = modern, change=0.5, normalizeBiol4 disabled\n"
|
---|
[1302] | 98 | "\t-e = experimental exponential\n", argv[0]);
|
---|
[1242] | 99 | return 0;
|
---|
| 100 | default: fprintf(stderr, "%s: invalid option: %s\n", argv[0], arg); return 2;
|
---|
| 101 | }
|
---|
| 102 | else
|
---|
| 103 | switch (argpos++)
|
---|
| 104 | {
|
---|
| 105 | case 0: modifier = arg[0]; break;
|
---|
| 106 | case 1: maxcount = atoi(arg); break;
|
---|
| 107 | default: fprintf(stderr, "%s: too many arguments: %s\n", argv[0], arg); return 2;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | char modifier_u = toupper(modifier);
|
---|
| 112 | char modifier_l = tolower(modifier);
|
---|
| 113 |
|
---|
| 114 | GenePropsOps_Exponential exponential_ops;
|
---|
[1260] | 115 | GenePropsOps_Legacy legacy_ops;
|
---|
| 116 | GenePropsOps_AllChange05 allchange05_ops;
|
---|
[1242] | 117 | GenePropsOps *ops;
|
---|
| 118 |
|
---|
| 119 | switch (fun)
|
---|
| 120 | {
|
---|
[1260] | 121 | case Legacy: ops = &legacy_ops; break;
|
---|
| 122 | case ExperimentalExponential: ops = &exponential_ops; break;
|
---|
| 123 | case AllChange05: ops = &allchange05_ops; break;
|
---|
[1242] | 124 | default: ops = NULL;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | char *tmp = new char[maxcount + 1];
|
---|
| 128 | for (int count = 0; count <= maxcount; count++)
|
---|
| 129 | {
|
---|
| 130 | int N = 1 << count;
|
---|
| 131 | for (int i = 0; i < N; i++)
|
---|
| 132 | {
|
---|
| 133 | GeneProps props;
|
---|
| 134 | for (int c = 0; c < count; c++)
|
---|
| 135 | {
|
---|
| 136 | char m = ((1 << c) & i) ? modifier_u : modifier_l;
|
---|
| 137 | tmp[c] = m;
|
---|
[1260] | 138 | props.executeModifier(m, ops);
|
---|
[1242] | 139 | }
|
---|
| 140 | if (count > 0)
|
---|
| 141 | tmp[count] = 0;
|
---|
| 142 | else
|
---|
| 143 | {
|
---|
| 144 | tmp[0] = '-'; tmp[1] = 0;
|
---|
| 145 | }
|
---|
| 146 | double value = genePropsValueForModifier(props, modifier);
|
---|
| 147 | printf("%s\t%g\n", tmp, value);
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | return 0;
|
---|
| 152 | }
|
---|