File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
plugin/src/main/kotlin/sc/plugin2023 Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -65,15 +65,21 @@ class Board(fields: TwoDBoard<Field> = generateFields()): RectangularBoard<Field
65
65
companion object {
66
66
/* * Generiert ein neues Spielfeld mit zufällig auf dem Spielbrett verteilten Fischen. */
67
67
private fun generateFields (seed : Int = Random .nextInt()): TwoDBoard <Field > {
68
- var remainingFish = Constants .BOARD_SIZE * ( Constants .BOARD_SIZE + 1 )
68
+ var remainingFish = Constants .BOARD_SIZE * Constants .BOARD_SIZE
69
69
val random = Random (seed)
70
- println (" Board seed: $seed " )
70
+ println (" Board Seed: $seed " )
71
+ var maxholes = 5
72
+ // Pro Hälfte 32 Felder, mind. 27 Schollen
73
+ // Maximal (64-20)/2 = 22 2-Fisch-Schollen,
74
+ // also immer mindestens 5 1-Fisch-Schollen pro Seite
71
75
return List (Constants .BOARD_SIZE / 2 ) {
72
76
MutableList (Constants .BOARD_SIZE ) {
73
77
val rand = random.nextInt(remainingFish)
74
- if (rand < 5 )
78
+ if (rand < maxholes) {
79
+ maxholes--
75
80
return @MutableList Field ()
76
- val fish = rand / 20 + 1
81
+ }
82
+ val fish = (rand - maxholes) / 20 + 1
77
83
remainingFish - = fish
78
84
Field (fish)
79
85
}
@@ -85,4 +91,4 @@ class Board(fields: TwoDBoard<Field> = generateFields()): RectangularBoard<Field
85
91
}
86
92
87
93
}
88
- }
94
+ }
You can’t perform that action at this time.
0 commit comments