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
6565 companion object {
6666 /* * Generiert ein neues Spielfeld mit zufällig auf dem Spielbrett verteilten Fischen. */
6767 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
6969 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
7175 return List (Constants .BOARD_SIZE / 2 ) {
7276 MutableList (Constants .BOARD_SIZE ) {
7377 val rand = random.nextInt(remainingFish)
74- if (rand < 5 )
78+ if (rand < maxholes) {
79+ maxholes--
7580 return @MutableList Field ()
76- val fish = rand / 20 + 1
81+ }
82+ val fish = (rand - maxholes) / 20 + 1
7783 remainingFish - = fish
7884 Field (fish)
7985 }
@@ -85,4 +91,4 @@ class Board(fields: TwoDBoard<Field> = generateFields()): RectangularBoard<Field
8591 }
8692
8793 }
88- }
94+ }
You can’t perform that action at this time.
0 commit comments