-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.ts
163 lines (154 loc) · 4.24 KB
/
Configuration.ts
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// cSpell:ignoreRegExp /import '.*'/;
import { BoundSpecification } from './BoundSpecification';
import { CoordinateConfiguration } from './Coordinate';
// Re-export ConfigurationHandler as it is tightly coupled to this
// interfaces
export { ConfigurationHandler } from './ConfigurationHandler';
/**
* Actual configuration interface defining
* all configuration options for the game.
*/
export interface Configuration {
gameSettings: GameSettingsConfiguration,
geneticAlgorithm: GeneticAlgorithmConfiguration,
levels: LevelConfiguration[]
}
/**
* Specifies the current settings of the game.
*/
export interface GameSettingsConfiguration {
/**
* Specifies whether the human mode is active (`true`) or
* the genetic algorithm operates the marbles (`false`).
*/
humanMode: boolean,
/**
* Specifies if the verbose mode is active.
* If active, verbose output will be generated.
*/
verboseMode: boolean
}
/**
* Specifies a level present in the game.
*/
export interface LevelConfiguration {
/**
* Display name of the level.
*/
name: string,
/**
* Specifies the configuration of a marble
* in the current level.
*/
marble: {
/**
* Specifies the diameter of a marble.
*
* @note Should be an **even number**.
*/
diameter: number,
/**
* Specifies the start point of a marble.
*/
position: CoordinateConfiguration
},
/**
* Specification of the goal.
*/
goal: {
/**
* Specifies the diameter of the goal.
*
* @note Should be an **even number**.
*/
diameter: number,
/**
* Specifies the position of the goal.
*/
position: CoordinateConfiguration
},
/**
* Specification of the obstacles.
*/
obstacles: ObstacleConfiguration[]
}
/**
* Specifies a obstacle present in the game/level.
*/
export interface ObstacleConfiguration {
/**
* Position of the obstacle.
*/
position: CoordinateConfiguration,
/**
* Size of the obstacle in pixels.
*/
size: {
width: number,
height: number
}
}
/**
* Specifies the settings for the genetic algorithm.
*
* @note **Important**: All **percentages/probabilities** must be in the range **[0, 1]**.
*/
export interface GeneticAlgorithmConfiguration {
/**
* With how many individuals should the simulation be performed.
*/
individualCount: number,
/**
* Specifies the probability that during reproduction the
* property from the father will be chosen.
*/
fatherGenesProbability : {
power: number,
angle: number
},
/**
* Specifies all mutation probabilities used in the algorithm.
*/
mutationProbability: {
/**
* Specifies the probability that a child mutates.
*/
general: number,
/**
* Specifies the probability that the power property of the
* DNA mutates.
*
* @note This means, if the children mutates, there is for example
* a 50% chance that the power property will mutate.
* That means, in total the power property has a mutation chance
* of general * power = (for example) 0.18 * 0.5 = 0.09 = 9%.
*/
power: number,
/**
* Specifies the probability that the angle property of the
* DNA mutates.
*
* @note This means, if the children mutates, there is for example
* a 50% chance that the angle property will mutate.
* That means, in total the angle property has a mutation chance
* of general * angle = (for example) 0.18 * 0.5 = 0.09 = 9%.
*/
angle: number
},
/**
* Specifies all mutation ranges.
* A range of lowerBound = -3, upperBound = 3
* means that the new property is in the range
* `[old property - 3, old property + 3]`
*/
mutationRange: {
/**
* Range for the power property of the dna.
*/
power: BoundSpecification,
/**
* Range for the angle property of the dna.
*/
angle: BoundSpecification
}
}