source: cpp/frams/genetics/geneprops.h @ 972

Last change on this file since 972 was 772, checked in by Maciej Komosinski, 7 years ago

Unified #define modifiers in f1 and f4, fixes issue number 16 [refs #62]

File size: 4.8 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _GENEPROPS_H
6#define _GENEPROPS_H
7
8#include <common/nonstd_math.h>
9#include <frams/model/model.h>
10
11
12
13
14
15#define F14_MODIFIERS_VISUAL "DdGgBbHh"
16#define F14_MODIFIERS_RARE "EeWwAaSs" //expdef would need to handle these properly/specifically to ensure reasonable behavior, and hardly any expdef does. Modifying initial energy of a creature as a result of its genes (Ee) is in general not a good idea. Weight (Ww) works only in water, and in water sinking/going up should usually be caused by real "intentional" activity of a creature, not by its inherited weight. For assimilation (Aa), there is a dedicated parameter in CreaturesGroup. Stamina (Ss) is no longer needed as destructive collisions are not supported, and even if they were, some expdef would need to impose reasonable restrictions on the value of this parameter (e.g. similar to normalizeBiol4()) so there is some cost associated with it, and the specific consequences of destructions should be defined as needed.
17#define F14_MODIFIERS "LlRrCcQqFfMmIi" F14_MODIFIERS_RARE F14_MODIFIERS_VISUAL
18
19
20
21
22
23/**
24 * Contains physical, biological and other properties of
25 * stick, except for rotation. The constructor initializes properties of sticks with
26 * default values. In order to change a property of a stick, the executeModifier() method
27 * should be called. Modification of length, curvedness and twist properties
28 * usually affects further sticks, so new sticks should have properties of
29 * parents (prop) modified with the prop.propagateAlong() method.
30 * "Biological" properties (assimilation, stamina, muscle strength and
31 * ingestion) should be normalized after modification with normalizeBiol4().
32 */
33struct GeneProps
34{
35public:
36        double length;            ///<incremented by L, decremented by l. Physical property, length of stick
37        double curvedness;        ///<incremented by C, decremented by c. Curvedness of sticks
38        double weight;            ///<incremented by W, decremented by w. Physical property, weight of stick (in water environment light sticks swim on the surface)
39        double friction;          ///<incremented by F, decremented by f. Physical property, friction of a stick (sticks will slide on the ground or stick to it)
40
41        double muscle_power;      ///<incremented by M, decremented by m. Biological property, muscle strength (muscle speed). Strong muscles act with bigger force, gain higher speed, can resist bigger stress, and use more energy
42        double assimilation;      ///<incremented by A, decremented by a. Biological property, assimilation, photosynthesis (a vertical stick can assimilate twice as much as horizontal one)
43        double stamina;           ///<incremented by S, decremented by s. Biological property, stamina (increases chance of survival during fights)
44        double ingestion;         ///<incremented by I, decremented by i. Biological property, ingestion (ability to gain energy from food)
45
46        double twist;             ///<incremented by Q, decremented by q. Twist of a stick
47        double energy;            ///<incremented by E, decremented by e. Energy of a creature
48
49        double muscle_bend_range; ///<Used only by conv_f1
50        bool muscle_reset_range;  ///<Used only by conv_f1
51
52        double visual_size;       ///<incremented by H, decremented by h. Part's visual size, only affects appearance
53        double cred;              ///<incremented by D, decremented by d. Part's red color proportion
54        double cgreen;            ///<incremented by B, decremented by b. Part's blue color proportion
55        double cblue;             ///<incremented by G, decremented by g. Part's green color proportion
56
57        static GeneProps standard_values;
58
59        /**
60         * Constructor initializing all properties with default values.
61         */
62        GeneProps();
63
64        /**
65         * Normalizes biological properties (muscle_power,
66         * assimilation, stamina, and ingestion). This method is called in
67         * executeModifier() when any of the biological properties is modified. All values
68         * of those properties sum up to 1.
69         */
70        void normalizeBiol4();
71
72        /**
73         * Checks whether the given character is property modifier. If yes, the property
74         * is modified and properties are normalized when needed.
75         * @param modif character that might be a property modifier
76         * @return 0 if the provided character was property modifier, -1 otherwise
77         */
78        int executeModifier(char modif);
79
80        /**
81         * Adjusts current properties for the next stick. In order to set
82         * new properties to the created stick, the copy of the previous stick should be created,
83         * and propagateAlong() should be used for that copy.
84         * @param use_reset_range true if this method should modify muscle_bend_range (used in f1 conversion).
85         */
86        void propagateAlong(bool use_f1_muscle_reset_range);
87};
88
89#endif // _GENEPROPS_H
Note: See TracBrowser for help on using the repository browser.