Small code changes to match the current report state
This commit is contained in:
parent
960dd89f4e
commit
5d8d06c793
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user