|
@@ -42,6 +42,7 @@ class Board { |
|
|
*/ |
|
|
*/ |
|
|
Board(int N, int S) { |
|
|
Board(int N, int S) { |
|
|
assert (N%2 != 0) : "Board's size has to be an odd number."; |
|
|
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.N = Session.boardSize = N; |
|
|
this.S = S; |
|
|
this.S = S; |
|
|
this.W = 0; |
|
|
this.W = 0; |
|
@@ -394,7 +395,7 @@ class Board { |
|
|
if (tiles[tileId].hasWalls() >= Const.maxTileWalls) |
|
|
if (tiles[tileId].hasWalls() >= Const.maxTileWalls) |
|
|
return false; |
|
|
return false; |
|
|
Range dirs = new Range(DirRange.Begin, DirRange.End, DirRange.Step); |
|
|
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)) |
|
|
if (isWallableDir(tileId, dir)) |
|
|
return true; |
|
|
return true; |
|
|
return false; |
|
|
return false; |
|
@@ -457,7 +458,7 @@ class Board { |
|
|
for (int tileId, i =0, walls =0, shuffleMark =0 ; true ; ) { |
|
|
for (int tileId, i =0, walls =0, shuffleMark =0 ; true ; ) { |
|
|
// randomly pick a wallable tile. |
|
|
// randomly pick a wallable tile. |
|
|
do { |
|
|
do { |
|
|
if ((tileId = randTiles.get())== Const.noTileId) { |
|
|
|
|
|
|
|
|
if ((tileId = randTiles.get())== Const.EOR) { |
|
|
if (i == shuffleMark) // Wallable tiles exhausted. |
|
|
if (i == shuffleMark) // Wallable tiles exhausted. |
|
|
return walls; |
|
|
return walls; |
|
|
else { // Re-shuffle and continue. |
|
|
else { // Re-shuffle and continue. |
|
|