-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneticPolygon.h
135 lines (91 loc) · 4.8 KB
/
GeneticPolygon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* Interactive Gym Environment and Educational Kit (iGeek) @version 0.x
@link https://github.com/KabukiStarship/iGeek.git
@file /geneticpolygon.h
@author Cale McCollough <https://cookingwithcale.org>
@license Copyright (C) 2015-2023 Kabuki Starship <kabukistarship.com>;
All right reserved (R). This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
this file, You can obtain one at <https://mozilla.org/MPL/2.0/>. */
namespace iGeek {
/* A class that represents a this that can morph through a genetic algorithm with other shapes.
*/
class GeneticPolygon : public Polygon {
public:
static const FPD maxRandomPoints = 5.00, //< And this was for what again?
defaultAngle = 0.00, //< The default angle of orientation.
matingPercent = 0.10, //< The percent of the population that mates durring each generation.
minorMutationVector = 0.50, //< Note sure if I need this or what its for because I didn't document it right.
majorMutationVector = 1.00, //< The
minorScalar = 0.10, //< The scale of minor mutations.
majorScalar = 0.15, //< The scale of major mutations.
minorMutation = 0.10, //< The probability of a minor mutation.
majorMutation = 0.05, //< The probability of a major mutation.
angularMutation = 0.10; //< The angular mutation TArray.
/*< When a GP sprouts a new point, the system tries to even out
the points at equal angles. The angular mutation is the amount that
the point will move over time. */
static const ISC defaultNumPoints = 5, /< The default number of points for a VIrus.
defaultLifespan = 30000, /< The default life span in milliseconds.
defaultSize = 50, /< The default size in pixels.
minSize = defaultSize / 2,/< The minimum size in pixels.
maxSize = 2 * defaultSize;
// The maximum size of pixels.
ISC lifespan,
width, / < The width of this GP in pixels.
height;
//< The height of this GP in pixels. */
FPD age,
/ < This variable represents the age a GP in generations.
/*< Initially the age is set to the GP's life span, and is decremented. */
angle;
/ < The angle of this GP in radians.
Color color;
/ < The ARGB color of this GP.
long numPixels;
/ < The number of pixels in this image.
BufferedImage bitmap;
/ < The bitmap rendering of this object.
GeneticPolygon mother,
/ < The thisMother of this GP.father, / < The father of this GP.grandparents;
/ < The grandparents of this GP.
static Color
getDefaultColor(ISC numPoints);
GeneticPolygon();
GeneticPolygon(ISC point_count, ISC color);
GeneticPolygon(ISC point_count, ISC width, ISC height, ISC color, ISC lifespan, FPD angle);
GeneticPolygon(GeneticPolygon thisMother, GeneticPolygon thisFather);
void rebound();
void printGeometry();
void setupPoints(ISC numberOfPoints);
BOL age(ISC ageTime);
static Color mixColors(Color motherColor, Color fatherColor);
Color breedColor(Color motherColor, Color fatherColor, Color matGrandColor,
Color patGrandColor);
ISC mutateInt(ISC thisValue, ISC mutateDirection);
FPD mutateFloat(FPD thisValue, ISC mutateDirection);
ISC breedInt(ISC motherInt, ISC fatherInt, ISC matGrandInt, ISC patGrandInt);
BOL containsGeneticPolygon(GeneticPolygon that);
FPD breedFloat(FPD motherInt, FPD fatherInt, FPD matGrandInt, FPD patGrandInt);
/* @brief Function that returns the BufferedImage for this this. */
BufferedImage getBitmap();
ISC Width();
ISC Height();
FPD getAngle();
Color getColor();
long getNumPixels();
ISC getLifespan();
ISC getNumPoints();
// Function that prints out the this to a bitstream.
void PrintGenes(ISC[] stream, ISC currentIndex);
BOL Intersects(Polygon thatPolygon);
BOL Intersects(GeneticPolygon thatPolygon);
BOL Intersects(Polygon thatPolygon, FPD offsetX, FPD offsetY);
BOL Intersects(Polygon thatPolygon, ISC offsetX, ISC offsetY);
void EqualizePoints();
void RenderBitmap();
static FPD CrossOver(FPD dominant, FPD recessive);
void Rotate();
FPD BoundBetween0and1(FPD inputValue);
FPD RandomizeDouble(FPD inputValue);
ISC RandomizeInt(ISC inputValue);
};