@@ -8,6 +8,8 @@ import sc.plugin2025.GameRuleLogic.calculateCarrots
8
8
import sc.plugin2025.GameRuleLogic.calculateMoveableFields
9
9
import sc.plugin2025.util.HuIConstants
10
10
import sc.shared.InvalidMoveException
11
+ import kotlin.math.pow
12
+ import kotlin.math.sqrt
11
13
12
14
/* *
13
15
* The GameState class represents the current state of the game.
@@ -42,6 +44,9 @@ data class GameState @JvmOverloads constructor(
42
44
fun isAhead (player : Hare = currentPlayer) =
43
45
player.position > player.opponent.position
44
46
47
+ fun isAhead (team : Team ) =
48
+ isAhead(getHare(team))
49
+
45
50
val currentField: Field ?
46
51
get() = currentPlayer.field
47
52
@@ -115,12 +120,14 @@ data class GameState @JvmOverloads constructor(
115
120
}
116
121
}
117
122
}
123
+
118
124
Field .MARKET -> {
119
125
if (player.carrots >= 10 )
120
126
Card .values().map { arrayOf(it) }
121
127
else
122
128
listOf ()
123
129
}
130
+
124
131
else -> null
125
132
}
126
133
@@ -146,18 +153,20 @@ data class GameState @JvmOverloads constructor(
146
153
}
147
154
}
148
155
149
- fun awardPositionFields () {
150
- when (currentField ) {
156
+ fun awardPositionFields (hare : Hare = currentPlayer ) {
157
+ when (hare.field ) {
151
158
Field .POSITION_1 -> {
152
- if (isAhead()) {
153
- currentPlayer .carrots + = 10
159
+ if (isAhead(hare )) {
160
+ hare .carrots + = 10
154
161
}
155
162
}
163
+
156
164
Field .POSITION_2 -> {
157
- if (! isAhead()) {
158
- currentPlayer .carrots + = 30
165
+ if (! isAhead(hare )) {
166
+ hare .carrots + = 30
159
167
}
160
168
}
169
+
161
170
else -> {}
162
171
}
163
172
}
@@ -180,7 +189,11 @@ data class GameState @JvmOverloads constructor(
180
189
181
190
/* * Basic validation whether a field may be entered via a jump that is not backward.
182
191
* Does not validate whether a card can be played on hare field. */
183
- fun validateTargetField (newPosition : Int , player : Hare = currentPlayer, carrots : Int = player.carrots): HuIMoveMistake ? {
192
+ fun validateTargetField (
193
+ newPosition : Int ,
194
+ player : Hare = currentPlayer,
195
+ carrots : Int = player.carrots,
196
+ ): HuIMoveMistake ? {
184
197
if (newPosition == 0 )
185
198
return HuIMoveMistake .CANNOT_ENTER_FIELD
186
199
val field = board.getField(newPosition)
@@ -250,7 +263,22 @@ data class GameState @JvmOverloads constructor(
250
263
getHare(team).let { intArrayOf(it.position, it.carrots) }
251
264
252
265
override fun getPointsForTeamExtended (team : ITeam ): IntArray =
253
- getHare(team).let { intArrayOf(if (it.inGoal) 100 else 0 , it.position, it.carrots, - it.salads * 2 , it.getCards().size * 5 ) }
266
+ getHare(team).copy().let { hare ->
267
+ awardPositionFields(hare)
268
+ // 1 at the beginning, 12 at the end
269
+ val positionFactor = 1.04 .pow(hare.position)
270
+ intArrayOf(
271
+ when {
272
+ hare.inGoal -> 100
273
+ hare.field == Field .SALAD -> 3
274
+ else -> 0
275
+ },
276
+ hare.position,
277
+ ((55 - hare.position.toDouble()).pow(0.3 ) / 2 * sqrt(hare.carrots.toDouble())).toInt(),
278
+ - (hare.salads * positionFactor).toInt(),
279
+ (hare.getCards().size * (10 - positionFactor) / 3 ).toInt(),
280
+ )
281
+ }
254
282
255
283
override fun teamStats (team : ITeam ) =
256
284
getHare(team).run {
0 commit comments