Skip to content

Commit e71009e

Browse files
committed
feat(plugin26): weighted piranhas sizing
1 parent f034ed6 commit e71009e

File tree

1 file changed

+12
-2
lines changed
  • plugin2026/src/main/kotlin/sc/plugin2026

1 file changed

+12
-2
lines changed

plugin2026/src/main/kotlin/sc/plugin2026/Board.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,23 @@ class Board(gameField: MutableTwoDBoard<FieldState> = randomFields()):
4747
Array(PiranhaConstants.BOARD_LENGTH) { FieldState.EMPTY }
4848
}
4949

50+
fun randomSize(): Int {
51+
// 4:3:2
52+
val int = random.nextInt(9)
53+
return when {
54+
int < 4 -> 1
55+
int < 7 -> 2
56+
else -> 3
57+
}
58+
}
59+
5060
// Place Piranhas
5161
for(index in 1 until PiranhaConstants.BOARD_LENGTH - 1) {
52-
val size1 = random.nextInt(2) + 1
62+
val size1 = randomSize()
5363
fields[0][index] = FieldState.from(Team.ONE, size1)
5464
fields[index][0] = FieldState.from(Team.TWO, size1)
5565

56-
val size2 = random.nextInt(2) + 1
66+
val size2 = randomSize()
5767
fields[PiranhaConstants.BOARD_LENGTH - 1][index] = FieldState.from(Team.ONE, size2)
5868
fields[index][PiranhaConstants.BOARD_LENGTH - 1] = FieldState.from(Team.TWO, size2)
5969
}

0 commit comments

Comments
 (0)