4
4
using ARKBreedingStats . Library ;
5
5
using ARKBreedingStats . Properties ;
6
6
using ARKBreedingStats . species ;
7
- using ARKBreedingStats . values ;
8
7
9
8
namespace ARKBreedingStats . BreedingPlanning
10
9
{
@@ -21,7 +20,7 @@ public static class BreedingScore
21
20
/// <param name="species"></param>
22
21
/// <param name="bestPossLevels"></param>
23
22
/// <param name="statWeights"></param>
24
- /// <param name="bestLevels"> </param>
23
+ /// <param name="bestLevelsOfSpecies">If the according stat weight is negative, the lowest level is contained. </param>
25
24
/// <param name="breedingMode"></param>
26
25
/// <param name="considerChosenCreature"></param>
27
26
/// <param name="considerMutationLimit"></param>
@@ -32,7 +31,7 @@ public static class BreedingScore
32
31
/// <param name="onlyBestSuggestionForFemale">Only the pairing with the highest score is kept for each female. Is not used if species has no sex or sex is ignored in breeding planner.</param>
33
32
/// <returns></returns>
34
33
public static List < BreedingPair > CalculateBreedingScores ( Creature [ ] females , Creature [ ] males , Species species ,
35
- short [ ] bestPossLevels , double [ ] statWeights , int [ ] bestLevels , BreedingPlan . BreedingMode breedingMode ,
34
+ short [ ] bestPossLevels , double [ ] statWeights , int [ ] bestLevelsOfSpecies , BreedingPlan . BreedingMode breedingMode ,
36
35
bool considerChosenCreature , bool considerMutationLimit , int mutationLimit ,
37
36
ref bool creaturesMutationsFilteredOut , int offspringLevelLimit = 0 , bool downGradeOffspringWithLevelHigherThanLimit = false ,
38
37
bool onlyBestSuggestionForFemale = false )
@@ -65,11 +64,11 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
65
64
}
66
65
67
66
double t = 0 ;
68
- int nrTS = 0 ;
69
- double eTS = 0 ;
67
+ int offspringPotentialTopStatCount = 0 ;
68
+ double offspringExpectedTopStatCount = 0 ; // a guaranteed top stat counts 1, otherwise the inheritance probability of the top stat is counted
70
69
71
- int topFemale = 0 ;
72
- int topMale = 0 ;
70
+ int topStatsMother = 0 ;
71
+ int topStatsFather = 0 ;
73
72
74
73
int maxPossibleOffspringLevel = 1 ;
75
74
@@ -87,45 +86,44 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
87
86
&& higherLevel % 2 != 0
88
87
&& statWeights [ s ] > 0 ;
89
88
90
- bool higherIsBetter = statWeights [ s ] >= 0 ;
91
-
92
- double tt = statWeights [ s ] * ( Ark . ProbabilityHigherLevel * higherLevel + Ark . ProbabilityLowerLevel * lowerLevel ) / 40 ;
93
- if ( tt != 0 )
89
+ double weightedExpectedStatLevel = statWeights [ s ] * ( Ark . ProbabilityInheritHigherLevel * higherLevel + Ark . ProbabilityInheritLowerLevel * lowerLevel ) / 40 ;
90
+ if ( weightedExpectedStatLevel != 0 )
94
91
{
95
92
if ( breedingMode == BreedingPlan . BreedingMode . TopStatsLucky )
96
93
{
97
- if ( ! ignoreTopStats && ( female . levelsWild [ s ] == bestLevels [ s ] || male . levelsWild [ s ] == bestLevels [ s ] ) )
94
+ if ( ! ignoreTopStats && ( female . levelsWild [ s ] == bestLevelsOfSpecies [ s ] || male . levelsWild [ s ] == bestLevelsOfSpecies [ s ] ) )
98
95
{
99
- if ( female . levelsWild [ s ] == bestLevels [ s ] && male . levelsWild [ s ] == bestLevels [ s ] )
100
- tt *= 1.142 ;
96
+ if ( female . levelsWild [ s ] == bestLevelsOfSpecies [ s ] && male . levelsWild [ s ] == bestLevelsOfSpecies [ s ] )
97
+ weightedExpectedStatLevel *= 1.142 ;
101
98
}
102
- else if ( bestLevels [ s ] > 0 )
103
- tt *= .01 ;
99
+ else if ( bestLevelsOfSpecies [ s ] > 0 )
100
+ weightedExpectedStatLevel *= .01 ;
104
101
}
105
- else if ( breedingMode == BreedingPlan . BreedingMode . TopStatsConservative && bestLevels [ s ] > 0 )
102
+ else if ( breedingMode == BreedingPlan . BreedingMode . TopStatsConservative && bestLevelsOfSpecies [ s ] > 0 )
106
103
{
104
+ bool higherIsBetter = statWeights [ s ] >= 0 ;
107
105
bestPossLevels [ s ] = ( short ) ( higherIsBetter ? Math . Max ( female . levelsWild [ s ] , male . levelsWild [ s ] ) : Math . Min ( female . levelsWild [ s ] , male . levelsWild [ s ] ) ) ;
108
- tt *= .01 ;
109
- if ( ! ignoreTopStats && ( female . levelsWild [ s ] == bestLevels [ s ] || male . levelsWild [ s ] == bestLevels [ s ] ) )
106
+ weightedExpectedStatLevel *= .01 ;
107
+ if ( ! ignoreTopStats && ( female . levelsWild [ s ] == bestLevelsOfSpecies [ s ] || male . levelsWild [ s ] == bestLevelsOfSpecies [ s ] ) )
110
108
{
111
- nrTS ++ ;
112
- eTS += female . levelsWild [ s ] == bestLevels [ s ] && male . levelsWild [ s ] == bestLevels [ s ] ? 1 : Ark . ProbabilityHigherLevel ;
113
- if ( female . levelsWild [ s ] == bestLevels [ s ] )
114
- topFemale ++ ;
115
- if ( male . levelsWild [ s ] == bestLevels [ s ] )
116
- topMale ++ ;
109
+ offspringPotentialTopStatCount ++ ;
110
+ offspringExpectedTopStatCount += female . levelsWild [ s ] == bestLevelsOfSpecies [ s ] && male . levelsWild [ s ] == bestLevelsOfSpecies [ s ] ? 1 : Ark . ProbabilityInheritHigherLevel ;
111
+ if ( female . levelsWild [ s ] == bestLevelsOfSpecies [ s ] )
112
+ topStatsMother ++ ;
113
+ if ( male . levelsWild [ s ] == bestLevelsOfSpecies [ s ] )
114
+ topStatsFather ++ ;
117
115
}
118
116
}
117
+ t += weightedExpectedStatLevel ;
119
118
}
120
- t += tt ;
121
119
}
122
120
123
121
if ( breedingMode == BreedingPlan . BreedingMode . TopStatsConservative )
124
122
{
125
- if ( topFemale < nrTS && topMale < nrTS )
126
- t += eTS ;
123
+ if ( topStatsMother < offspringPotentialTopStatCount && topStatsFather < offspringPotentialTopStatCount )
124
+ t += offspringExpectedTopStatCount ;
127
125
else
128
- t += .1 * eTS ;
126
+ t += .1 * offspringExpectedTopStatCount ;
129
127
// check if the best possible stat outcome regarding topLevels already exists in a male
130
128
bool maleExists = false ;
131
129
@@ -137,7 +135,7 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
137
135
if ( s == Stats . Torpidity
138
136
|| ! cr . Species . UsesStat ( s )
139
137
|| cr . levelsWild [ s ] == bestPossLevels [ s ]
140
- || bestPossLevels [ s ] != bestLevels [ s ] )
138
+ || bestPossLevels [ s ] != bestLevelsOfSpecies [ s ] )
141
139
continue ;
142
140
143
141
maleExists = false ;
@@ -160,7 +158,7 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
160
158
if ( s == Stats . Torpidity
161
159
|| ! cr . Species . UsesStat ( s )
162
160
|| cr . levelsWild [ s ] == bestPossLevels [ s ]
163
- || bestPossLevels [ s ] != bestLevels [ s ] )
161
+ || bestPossLevels [ s ] != bestLevelsOfSpecies [ s ] )
164
162
continue ;
165
163
166
164
femaleExists = false ;
@@ -184,7 +182,7 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
184
182
: female . Mutations < Ark . MutationPossibleWithLessThan || male . Mutations < Ark . MutationPossibleWithLessThan ? 1 : 0 ;
185
183
186
184
breedingPairs . Add ( new BreedingPair ( female , male ,
187
- t * 1.25 ,
185
+ new Score ( t * 1.25 ) ,
188
186
( mutationPossibleFrom == 2 ? Ark . ProbabilityOfOneMutation : mutationPossibleFrom == 1 ? Ark . ProbabilityOfOneMutationFromOneParent : 0 ) ,
189
187
highestOffspringOverLevelLimit ) ) ;
190
188
}
0 commit comments