1
1
import 'package:sj_manager/models/simulation/flow/dynamic_params/jumper_dynamic_params.dart' ;
2
2
import 'package:sj_manager/models/simulation/flow/training/jumper_training_config.dart' ;
3
3
import 'package:sj_manager/models/user_db/jumper/jumper.dart' ;
4
+ import 'package:sj_manager/models/user_db/psyche/level_of_consciousness_labels.dart' ;
4
5
import 'package:sj_manager/training_engine/jumper_training_result.dart' ;
5
6
import 'package:sj_manager/utils/random/random.dart' ;
6
7
@@ -24,6 +25,8 @@ class JumperTrainingEngine {
24
25
late double _formStability;
25
26
late double _jumpsConsistency;
26
27
late double _fatigue;
28
+ late double _efficiencyFactor;
29
+ late double _subjectiveEfficiencyFactor;
27
30
28
31
JumperTrainingResult doTraining () {
29
32
_setUp ();
@@ -35,6 +38,8 @@ class JumperTrainingEngine {
35
38
_simulateJumpsConsistencyTraining ();
36
39
_simulateFatigue ();
37
40
_simulateInjuries ();
41
+ _simulateEfficiencyFactorChange ();
42
+ _setSubjectiveEfficiencyFactorChange ();
38
43
39
44
final newSkills = jumper.skills.copyWith (
40
45
takeoffQuality: _takeoffQuality,
@@ -47,6 +52,7 @@ class JumperTrainingEngine {
47
52
formStability: _formStability,
48
53
jumpsConsistency: _jumpsConsistency,
49
54
fatigue: _fatigue,
55
+ efficiencyFactor: _efficiencyFactor,
50
56
);
51
57
}
52
58
@@ -76,14 +82,13 @@ class JumperTrainingEngine {
76
82
77
83
const potentialRandomForOnePoint = 0.15 ;
78
84
79
- final negativeRandom = linearRandomDouble ( 0 , potentialRandomForOnePoint * 5 ) ;
85
+ const negativeRandomMax = potentialRandomForOnePoint * 5 ;
80
86
final positiveRandomMax =
81
87
(_developmentPotentialFactor * developmentPotentialMultiplier) *
82
88
(dynamicParams.trainingEfficiencyFactor * trainingEfficiencyMultiplier) *
83
89
(potentialRandomForOnePoint * points);
84
90
85
- final positiveRandom = linearRandomDouble (0 , positiveRandomMax);
86
- final random = (negativeRandom + positiveRandom) * scaleFactor;
91
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax) * scaleFactor;
87
92
88
93
_takeoffQuality += random;
89
94
}
@@ -98,14 +103,13 @@ class JumperTrainingEngine {
98
103
99
104
const potentialRandomForOnePoint = 0.15 ;
100
105
101
- final negativeRandom = linearRandomDouble ( 0 , potentialRandomForOnePoint * 5 ) ;
106
+ const negativeRandomMax = potentialRandomForOnePoint * 5 ;
102
107
final positiveRandomMax =
103
108
(_developmentPotentialFactor * developmentPotentialMultiplier) *
104
109
(dynamicParams.trainingEfficiencyFactor * trainingEfficiencyMultiplier) *
105
110
(potentialRandomForOnePoint * points);
106
111
107
- final positiveRandom = linearRandomDouble (0 , positiveRandomMax);
108
- final random = (negativeRandom + positiveRandom) * scaleFactor;
112
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax) * scaleFactor;
109
113
110
114
_flightQuality += random;
111
115
}
@@ -120,14 +124,13 @@ class JumperTrainingEngine {
120
124
121
125
const potentialRandomForOnePoint = 0.15 ;
122
126
123
- final negativeRandom = linearRandomDouble ( 0 , potentialRandomForOnePoint * 5 ) ;
127
+ const negativeRandomMax = potentialRandomForOnePoint * 5 ;
124
128
final positiveRandomMax =
125
129
(_developmentPotentialFactor * developmentPotentialMultiplier) *
126
130
(dynamicParams.trainingEfficiencyFactor * trainingEfficiencyMultiplier) *
127
131
(potentialRandomForOnePoint * points);
128
132
129
- final positiveRandom = linearRandomDouble (0 , positiveRandomMax);
130
- final random = (negativeRandom + positiveRandom) * scaleFactor;
133
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax) * scaleFactor;
131
134
132
135
_landingQuality += random;
133
136
}
@@ -143,16 +146,13 @@ class JumperTrainingEngine {
143
146
const potentialRandomForOnePoint = 0.15 ;
144
147
145
148
const negativeRandomMax = potentialRandomForOnePoint * 5 ;
146
- final negativeRandom = linearRandomDouble (0 , negativeRandomMax);
147
149
148
150
final positiveRandomMax =
149
151
(_developmentPotentialFactor * developmentPotentialMultiplier) *
150
152
(dynamicParams.trainingEfficiencyFactor * trainingEfficiencyMultiplier) *
151
153
(potentialRandomForOnePoint * formPoints) *
152
154
(1.0 / _form);
153
-
154
- final positiveRandom = linearRandomDouble (0 , positiveRandomMax);
155
- final random = (negativeRandom + positiveRandom) * scaleFactor;
155
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax) * scaleFactor;
156
156
157
157
_form += random;
158
158
}
@@ -167,15 +167,13 @@ class JumperTrainingEngine {
167
167
const potentialRandomForMaxChange = 0.1 ;
168
168
169
169
final negativeRandomMax = (_trainingConfig.balance * 0.5 );
170
- final negativeRandom = linearRandomDouble (0 , negativeRandomMax);
171
170
172
171
final positiveRandomMax =
173
172
(_developmentPotentialFactor * developmentPotentialMultiplier) *
174
173
(dynamicParams.trainingEfficiencyFactor * trainingEfficiencyMultiplier) *
175
174
(potentialRandomForMaxChange * _trainingConfig.balance);
176
- final positiveRandom = linearRandomDouble (0 , positiveRandomMax);
177
175
178
- final random = (negativeRandom + positiveRandom ) * scaleFactor;
176
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax ) * scaleFactor;
179
177
180
178
_jumpsConsistency += random;
181
179
}
@@ -208,4 +206,56 @@ class JumperTrainingEngine {
208
206
void _simulateInjuries () {
209
207
// TODO
210
208
}
209
+
210
+ void _simulateEfficiencyFactorChange () {
211
+ _efficiencyFactor = dynamicParams.trainingEfficiencyFactor;
212
+ final negativeRandomMax = 0.1 + (_trainingConfig.balance / 10 );
213
+ final positiveRandomMax = 0.1 + (_trainingConfig.balance / 10 );
214
+ final random = linearRandomDouble (negativeRandomMax, positiveRandomMax);
215
+ final delta = random;
216
+ _efficiencyFactor += delta;
217
+ }
218
+
219
+ void _setSubjectiveEfficiencyFactorChange () {
220
+ var percentsDeviation = switch (dynamicParams.levelOfConsciousness.label) {
221
+ LevelOfConsciousnessLabels .shame => 23 ,
222
+ LevelOfConsciousnessLabels .guilt => 22 ,
223
+ LevelOfConsciousnessLabels .apathy => 21 ,
224
+ LevelOfConsciousnessLabels .grief => 20 ,
225
+ LevelOfConsciousnessLabels .fear => 18 ,
226
+ LevelOfConsciousnessLabels .desire => 17 ,
227
+ LevelOfConsciousnessLabels .anger => 16 ,
228
+ LevelOfConsciousnessLabels .pride => 14 ,
229
+ LevelOfConsciousnessLabels .courage => 12 ,
230
+ LevelOfConsciousnessLabels .neutrality => 11 ,
231
+ LevelOfConsciousnessLabels .willingness => 9.5 ,
232
+ LevelOfConsciousnessLabels .acceptance => 8 ,
233
+ LevelOfConsciousnessLabels .reason => 6 ,
234
+ LevelOfConsciousnessLabels .love => 4 ,
235
+ LevelOfConsciousnessLabels .joy => 2 ,
236
+ LevelOfConsciousnessLabels .peace => 1 ,
237
+ LevelOfConsciousnessLabels .enlightenment => 0 ,
238
+ };
239
+
240
+ var randomMin = percentsDeviation * (1 + (_efficiencyFactor / 6 ));
241
+ var randomMax = percentsDeviation * (1 + (_efficiencyFactor / 6 ));
242
+
243
+ /*
244
+ Np. subjective 0.45, real 0.6
245
+ difference: 0.15
246
+ scale = 1 - (0.15 / 0.60) = 0.75
247
+ randomMax *= 0.75
248
+ */
249
+ var difference = (_subjectiveEfficiencyFactor - _efficiencyFactor).abs ();
250
+ var scale = 0.8 - (difference / _efficiencyFactor);
251
+ if (_subjectiveEfficiencyFactor > _efficiencyFactor) {
252
+ randomMax *= (scale.clamp (0 , 1 )); // Ensure scale does not reduce below 0
253
+ } else if (_subjectiveEfficiencyFactor < _efficiencyFactor) {
254
+ randomMin *= (scale.clamp (0 , 1 ));
255
+ }
256
+
257
+ final random = linearRandomDouble (randomMin, randomMax) / 100 ; // from percents
258
+
259
+ _subjectiveEfficiencyFactor = _efficiencyFactor + random;
260
+ }
211
261
}
0 commit comments