From 5d8d06c793803c10cc8ad71b405b67f5a0f4d653 Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Wed, 28 Oct 2020 00:23:55 +0200 Subject: [PATCH] Small code changes to match the current report state --- src/host/labyrinth/Board.java | 5 +++-- src/host/labyrinth/Common.java | 1 + src/host/labyrinth/Game.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/host/labyrinth/Board.java b/src/host/labyrinth/Board.java index 0702a00..4f08c9f 100644 --- a/src/host/labyrinth/Board.java +++ b/src/host/labyrinth/Board.java @@ -42,6 +42,7 @@ class Board { */ Board(int N, int S) { assert (N%2 != 0) : "Board's size has to be an odd number."; + assert (S <= (N*N-2)) : "At least 2 tiles has to be without supplies."; this.N = Session.boardSize = N; this.S = S; this.W = 0; @@ -394,7 +395,7 @@ class Board { if (tiles[tileId].hasWalls() >= Const.maxTileWalls) return false; Range dirs = new Range(DirRange.Begin, DirRange.End, DirRange.Step); - for (int dir ; (dir = dirs.get()) != Const.noTileId ; ) + for (int dir = dirs.get() ; dir != Const.EOR ; dir = dirs.get()) if (isWallableDir(tileId, dir)) return true; return false; @@ -457,7 +458,7 @@ class Board { for (int tileId, i =0, walls =0, shuffleMark =0 ; true ; ) { // randomly pick a wallable tile. do { - if ((tileId = randTiles.get())== Const.noTileId) { + if ((tileId = randTiles.get())== Const.EOR) { if (i == shuffleMark) // Wallable tiles exhausted. return walls; else { // Re-shuffle and continue. diff --git a/src/host/labyrinth/Common.java b/src/host/labyrinth/Common.java index 5b71c2e..5f2022e 100644 --- a/src/host/labyrinth/Common.java +++ b/src/host/labyrinth/Common.java @@ -18,6 +18,7 @@ class Const { static final int maxTileWalls = 2; /**< Number of maximum walls for each tile on the board */ static final int noSupply =-1; /**< Number to indicate the absent of supply */ static final int noTileId =-1; /**< Number to indicate wrong tileId */ + static final int EOR =-1; /**< Number to indicate the End Of Range */ } /** * Application wide object to hold settings like values for the session. diff --git a/src/host/labyrinth/Game.java b/src/host/labyrinth/Game.java index 3910ac5..db7a0d3 100644 --- a/src/host/labyrinth/Game.java +++ b/src/host/labyrinth/Game.java @@ -80,7 +80,7 @@ public class Game { break; case "-s": - case "--suplies": + case "--supplies": if (i+1 < args.length) Session.supplySize = Integer.parseInt(args[++i]); break;