Comparing version 2.3.1 to 2.3.2
@@ -8,10 +8,10 @@ "use strict"; | ||
return [ | ||
utils_1.isVerticallyIncrementablePawnPosition(position) && | ||
utils_1.verticallyIncrementPawnPosition(position), | ||
utils_1.isHorizontallyIncrementablePawnPosition(position) && | ||
utils_1.horizontallyIncrementPawnPosition(position), | ||
utils_1.isVerticallyDecrementablePawnPosition(position) && | ||
utils_1.verticallyDecrementPawnPosition(position), | ||
utils_1.isHorizontallyDecrementablePawnPosition(position) && | ||
utils_1.horizontallyDecrementPawnPosition(position), | ||
(0, utils_1.isVerticallyIncrementablePawnPosition)(position) && | ||
(0, utils_1.verticallyIncrementPawnPosition)(position), | ||
(0, utils_1.isHorizontallyIncrementablePawnPosition)(position) && | ||
(0, utils_1.horizontallyIncrementPawnPosition)(position), | ||
(0, utils_1.isVerticallyDecrementablePawnPosition)(position) && | ||
(0, utils_1.verticallyDecrementPawnPosition)(position), | ||
(0, utils_1.isHorizontallyDecrementablePawnPosition)(position) && | ||
(0, utils_1.horizontallyDecrementPawnPosition)(position), | ||
].filter(function (newPosition) { | ||
@@ -21,3 +21,3 @@ return (newPosition && | ||
!relaxedPositions.has(newPosition) && | ||
utils_1.isValidAStarMove(game, position, newPosition)); | ||
(0, utils_1.isValidAStarMove)(game, position, newPosition)); | ||
}); | ||
@@ -28,4 +28,4 @@ }; | ||
return turn === 1 | ||
? 9 - utils_1.getVerticalCoordinate(position) | ||
: utils_1.getVerticalCoordinate(position) - 1; | ||
? 9 - (0, utils_1.getVerticalCoordinate)(position) | ||
: (0, utils_1.getVerticalCoordinate)(position) - 1; | ||
}; | ||
@@ -32,0 +32,0 @@ var hasReachedGoal = function (position, turn) { |
@@ -19,5 +19,5 @@ import { DecrementableHorizontalPiecePosition, DecrementableHorizontalWallCoordinate, DecrementableVerticalPiecePosition, DecrementableVerticalWallCoordinate, HorizontallyDecrementablePawnPosition, HorizontallyIncrementablePawnPosition, HorizontalPiecePosition, HorizontalWallCoordinate, IncrementableHorizontalPiecePosition, IncrementableHorizontalWallCoordinate, IncrementableVerticalPiecePosition, IncrementableVerticalWallCoordinate, PawnPosition, PlayerMatrix, VerticallyDecrementablePawnPosition, VerticallyIncrementablePawnPosition, VerticalPiecePosition, VerticalWallCoordinate, WallMatrix, WallPosition } from './types'; | ||
export declare const horizontallyIncrementableWallPositions: string[]; | ||
export declare const horizontallyDecrementableWallPositions: string[]; | ||
export declare const verticallyIncrementableWallPositions: string[]; | ||
export declare const verticallyDecrementableWallPositions: string[]; | ||
export declare const verticallyIncrementablePositions: Set<PawnPosition | WallPosition>; | ||
export declare const verticallyDecrementablePositions: Set<PawnPosition | WallPosition>; | ||
export declare const verticalPiecePositions: number[]; | ||
@@ -43,336 +43,6 @@ export declare const decrementedHorizontalWallCoordinates: Record<DecrementableHorizontalWallCoordinate, IncrementableHorizontalWallCoordinate>; | ||
export declare const verticallyIncrementedPawnPositions: Record<VerticallyIncrementablePawnPosition, PawnPosition>; | ||
export declare const isVerticallyIncrementablePawnPositionMap: { | ||
a1: boolean; | ||
a2: boolean; | ||
a3: boolean; | ||
a4: boolean; | ||
a5: boolean; | ||
a6: boolean; | ||
a7: boolean; | ||
a8: boolean; | ||
a9: boolean; | ||
b1: boolean; | ||
b2: boolean; | ||
b3: boolean; | ||
b4: boolean; | ||
b5: boolean; | ||
b6: boolean; | ||
b7: boolean; | ||
b8: boolean; | ||
b9: boolean; | ||
c1: boolean; | ||
c2: boolean; | ||
c3: boolean; | ||
c4: boolean; | ||
c5: boolean; | ||
c6: boolean; | ||
c7: boolean; | ||
c8: boolean; | ||
c9: boolean; | ||
d1: boolean; | ||
d2: boolean; | ||
d3: boolean; | ||
d4: boolean; | ||
d5: boolean; | ||
d6: boolean; | ||
d7: boolean; | ||
d8: boolean; | ||
d9: boolean; | ||
e1: boolean; | ||
e2: boolean; | ||
e3: boolean; | ||
e4: boolean; | ||
e5: boolean; | ||
e6: boolean; | ||
e7: boolean; | ||
e8: boolean; | ||
e9: boolean; | ||
f1: boolean; | ||
f2: boolean; | ||
f3: boolean; | ||
f4: boolean; | ||
f5: boolean; | ||
f6: boolean; | ||
f7: boolean; | ||
f8: boolean; | ||
f9: boolean; | ||
g1: boolean; | ||
g2: boolean; | ||
g3: boolean; | ||
g4: boolean; | ||
g5: boolean; | ||
g6: boolean; | ||
g7: boolean; | ||
g8: boolean; | ||
g9: boolean; | ||
h1: boolean; | ||
h2: boolean; | ||
h3: boolean; | ||
h4: boolean; | ||
h5: boolean; | ||
h6: boolean; | ||
h7: boolean; | ||
h8: boolean; | ||
h9: boolean; | ||
i1: boolean; | ||
i2: boolean; | ||
i3: boolean; | ||
i4: boolean; | ||
i5: boolean; | ||
i6: boolean; | ||
i7: boolean; | ||
i8: boolean; | ||
i9: boolean; | ||
}; | ||
export declare const verticallyDecrementedPawnPositions: Record<VerticallyDecrementablePawnPosition, PawnPosition>; | ||
export declare const isVerticallyDecrementablePawnPositionMap: { | ||
a1: boolean; | ||
a2: boolean; | ||
a3: boolean; | ||
a4: boolean; | ||
a5: boolean; | ||
a6: boolean; | ||
a7: boolean; | ||
a8: boolean; | ||
a9: boolean; | ||
b1: boolean; | ||
b2: boolean; | ||
b3: boolean; | ||
b4: boolean; | ||
b5: boolean; | ||
b6: boolean; | ||
b7: boolean; | ||
b8: boolean; | ||
b9: boolean; | ||
c1: boolean; | ||
c2: boolean; | ||
c3: boolean; | ||
c4: boolean; | ||
c5: boolean; | ||
c6: boolean; | ||
c7: boolean; | ||
c8: boolean; | ||
c9: boolean; | ||
d1: boolean; | ||
d2: boolean; | ||
d3: boolean; | ||
d4: boolean; | ||
d5: boolean; | ||
d6: boolean; | ||
d7: boolean; | ||
d8: boolean; | ||
d9: boolean; | ||
e1: boolean; | ||
e2: boolean; | ||
e3: boolean; | ||
e4: boolean; | ||
e5: boolean; | ||
e6: boolean; | ||
e7: boolean; | ||
e8: boolean; | ||
e9: boolean; | ||
f1: boolean; | ||
f2: boolean; | ||
f3: boolean; | ||
f4: boolean; | ||
f5: boolean; | ||
f6: boolean; | ||
f7: boolean; | ||
f8: boolean; | ||
f9: boolean; | ||
g1: boolean; | ||
g2: boolean; | ||
g3: boolean; | ||
g4: boolean; | ||
g5: boolean; | ||
g6: boolean; | ||
g7: boolean; | ||
g8: boolean; | ||
g9: boolean; | ||
h1: boolean; | ||
h2: boolean; | ||
h3: boolean; | ||
h4: boolean; | ||
h5: boolean; | ||
h6: boolean; | ||
h7: boolean; | ||
h8: boolean; | ||
h9: boolean; | ||
i1: boolean; | ||
i2: boolean; | ||
i3: boolean; | ||
i4: boolean; | ||
i5: boolean; | ||
i6: boolean; | ||
i7: boolean; | ||
i8: boolean; | ||
i9: boolean; | ||
}; | ||
export declare const horizontallyIncrementedPawnPositions: Record<HorizontallyIncrementablePawnPosition, PawnPosition>; | ||
export declare const isHorizontallyIncrementablePawnPositionMap: { | ||
a1: boolean; | ||
a2: boolean; | ||
a3: boolean; | ||
a4: boolean; | ||
a5: boolean; | ||
a6: boolean; | ||
a7: boolean; | ||
a8: boolean; | ||
a9: boolean; | ||
b1: boolean; | ||
b2: boolean; | ||
b3: boolean; | ||
b4: boolean; | ||
b5: boolean; | ||
b6: boolean; | ||
b7: boolean; | ||
b8: boolean; | ||
b9: boolean; | ||
c1: boolean; | ||
c2: boolean; | ||
c3: boolean; | ||
c4: boolean; | ||
c5: boolean; | ||
c6: boolean; | ||
c7: boolean; | ||
c8: boolean; | ||
c9: boolean; | ||
d1: boolean; | ||
d2: boolean; | ||
d3: boolean; | ||
d4: boolean; | ||
d5: boolean; | ||
d6: boolean; | ||
d7: boolean; | ||
d8: boolean; | ||
d9: boolean; | ||
e1: boolean; | ||
e2: boolean; | ||
e3: boolean; | ||
e4: boolean; | ||
e5: boolean; | ||
e6: boolean; | ||
e7: boolean; | ||
e8: boolean; | ||
e9: boolean; | ||
f1: boolean; | ||
f2: boolean; | ||
f3: boolean; | ||
f4: boolean; | ||
f5: boolean; | ||
f6: boolean; | ||
f7: boolean; | ||
f8: boolean; | ||
f9: boolean; | ||
g1: boolean; | ||
g2: boolean; | ||
g3: boolean; | ||
g4: boolean; | ||
g5: boolean; | ||
g6: boolean; | ||
g7: boolean; | ||
g8: boolean; | ||
g9: boolean; | ||
h1: boolean; | ||
h2: boolean; | ||
h3: boolean; | ||
h4: boolean; | ||
h5: boolean; | ||
h6: boolean; | ||
h7: boolean; | ||
h8: boolean; | ||
h9: boolean; | ||
i1: boolean; | ||
i2: boolean; | ||
i3: boolean; | ||
i4: boolean; | ||
i5: boolean; | ||
i6: boolean; | ||
i7: boolean; | ||
i8: boolean; | ||
i9: boolean; | ||
}; | ||
export declare const horizontallyIncrementablePositions: Set<PawnPosition | WallPosition>; | ||
export declare const horizontallyDecrementablePositions: Set<PawnPosition | WallPosition>; | ||
export declare const horizontallyDecrementedPawnPositions: Record<HorizontallyDecrementablePawnPosition, PawnPosition>; | ||
export declare const isHorizontallyDecrementablePawnPositionMap: { | ||
a1: boolean; | ||
a2: boolean; | ||
a3: boolean; | ||
a4: boolean; | ||
a5: boolean; | ||
a6: boolean; | ||
a7: boolean; | ||
a8: boolean; | ||
a9: boolean; | ||
b1: boolean; | ||
b2: boolean; | ||
b3: boolean; | ||
b4: boolean; | ||
b5: boolean; | ||
b6: boolean; | ||
b7: boolean; | ||
b8: boolean; | ||
b9: boolean; | ||
c1: boolean; | ||
c2: boolean; | ||
c3: boolean; | ||
c4: boolean; | ||
c5: boolean; | ||
c6: boolean; | ||
c7: boolean; | ||
c8: boolean; | ||
c9: boolean; | ||
d1: boolean; | ||
d2: boolean; | ||
d3: boolean; | ||
d4: boolean; | ||
d5: boolean; | ||
d6: boolean; | ||
d7: boolean; | ||
d8: boolean; | ||
d9: boolean; | ||
e1: boolean; | ||
e2: boolean; | ||
e3: boolean; | ||
e4: boolean; | ||
e5: boolean; | ||
e6: boolean; | ||
e7: boolean; | ||
e8: boolean; | ||
e9: boolean; | ||
f1: boolean; | ||
f2: boolean; | ||
f3: boolean; | ||
f4: boolean; | ||
f5: boolean; | ||
f6: boolean; | ||
f7: boolean; | ||
f8: boolean; | ||
f9: boolean; | ||
g1: boolean; | ||
g2: boolean; | ||
g3: boolean; | ||
g4: boolean; | ||
g5: boolean; | ||
g6: boolean; | ||
g7: boolean; | ||
g8: boolean; | ||
g9: boolean; | ||
h1: boolean; | ||
h2: boolean; | ||
h3: boolean; | ||
h4: boolean; | ||
h5: boolean; | ||
h6: boolean; | ||
h7: boolean; | ||
h8: boolean; | ||
h9: boolean; | ||
i1: boolean; | ||
i2: boolean; | ||
i3: boolean; | ||
i4: boolean; | ||
i5: boolean; | ||
i6: boolean; | ||
i7: boolean; | ||
i8: boolean; | ||
i9: boolean; | ||
}; |
@@ -13,9 +13,13 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isHorizontallyDecrementablePawnPositionMap = exports.horizontallyDecrementedPawnPositions = exports.isHorizontallyIncrementablePawnPositionMap = exports.horizontallyIncrementedPawnPositions = exports.isVerticallyDecrementablePawnPositionMap = exports.verticallyDecrementedPawnPositions = exports.isVerticallyIncrementablePawnPositionMap = exports.verticallyIncrementedPawnPositions = exports.isDecrementableVerticalPiecePositionMap = exports.isIncrementableVerticalPiecePositionMap = exports.isDecrementableHorizontalPiecePositionMap = exports.isIncrementableHorizontalPiecePositionMap = exports.isDecrementableVerticalWallCoordinateMap = exports.isIncrementableVerticalWallCoordinateMap = exports.isDecrementableHorizontalWallCoordinateMap = exports.isIncrementableHorizontalWallCoordinateMap = exports.isVerticalWallCoordinateMap = exports.isHorizontalWallCoordinateMap = exports.incrementedHorizontalPiecePositions = exports.incrementedVerticalPiecePositions = exports.decrementedVerticalPiecePositions = exports.decrementedHorizontalPiecePositions = exports.incrementedVerticalWallCoordinates = exports.decrementedVerticalWallCoordinates = exports.incrementedHorizontalWallCoordinates = exports.decrementedHorizontalWallCoordinates = exports.verticalPiecePositions = exports.verticallyDecrementableWallPositions = exports.verticallyIncrementableWallPositions = exports.horizontallyDecrementableWallPositions = exports.horizontallyIncrementableWallPositions = exports.possiblyTrappedPositions = exports.horizontalPawnCoordinates = exports.initialBoard = exports.pawnAndWallPositions = exports.isWallPositionMap = exports.horizontallyMirroredPositionsMap = exports.positions = exports.wallPositions = exports.pawnPositions = void 0; | ||
exports.horizontallyDecrementedPawnPositions = exports.horizontallyDecrementablePositions = exports.horizontallyIncrementablePositions = exports.horizontallyIncrementedPawnPositions = exports.verticallyDecrementedPawnPositions = exports.verticallyIncrementedPawnPositions = exports.isDecrementableVerticalPiecePositionMap = exports.isIncrementableVerticalPiecePositionMap = exports.isDecrementableHorizontalPiecePositionMap = exports.isIncrementableHorizontalPiecePositionMap = exports.isDecrementableVerticalWallCoordinateMap = exports.isIncrementableVerticalWallCoordinateMap = exports.isDecrementableHorizontalWallCoordinateMap = exports.isIncrementableHorizontalWallCoordinateMap = exports.isVerticalWallCoordinateMap = exports.isHorizontalWallCoordinateMap = exports.incrementedHorizontalPiecePositions = exports.incrementedVerticalPiecePositions = exports.decrementedVerticalPiecePositions = exports.decrementedHorizontalPiecePositions = exports.incrementedVerticalWallCoordinates = exports.decrementedVerticalWallCoordinates = exports.incrementedHorizontalWallCoordinates = exports.decrementedHorizontalWallCoordinates = exports.verticalPiecePositions = exports.verticallyDecrementablePositions = exports.verticallyIncrementablePositions = exports.verticallyIncrementableWallPositions = exports.horizontallyIncrementableWallPositions = exports.possiblyTrappedPositions = exports.horizontalPawnCoordinates = exports.initialBoard = exports.pawnAndWallPositions = exports.isWallPositionMap = exports.horizontallyMirroredPositionsMap = exports.positions = exports.wallPositions = exports.pawnPositions = void 0; | ||
exports.pawnPositions = [ | ||
@@ -234,3 +238,3 @@ 'a1', | ||
]; | ||
exports.positions = __spreadArray(__spreadArray([], exports.pawnPositions), exports.wallPositions); | ||
exports.positions = __spreadArray(__spreadArray([], exports.pawnPositions, true), exports.wallPositions, true); | ||
exports.horizontallyMirroredPositionsMap = { | ||
@@ -577,3 +581,3 @@ a1: 'i1', | ||
}; | ||
exports.pawnAndWallPositions = __spreadArray(__spreadArray([], exports.pawnPositions), exports.wallPositions); | ||
exports.pawnAndWallPositions = __spreadArray(__spreadArray([], exports.pawnPositions, true), exports.wallPositions, true); | ||
var initialPlayerMatrix = { | ||
@@ -1000,3 +1004,17 @@ a1: null, | ||
]; | ||
exports.horizontallyDecrementableWallPositions = [ | ||
exports.verticallyIncrementableWallPositions = [ | ||
'a1h', | ||
'a1v', | ||
'a2h', | ||
'a2v', | ||
'a3h', | ||
'a3v', | ||
'a4h', | ||
'a4v', | ||
'a5h', | ||
'a5v', | ||
'a6h', | ||
'a6v', | ||
'a7h', | ||
'a7v', | ||
'b1h', | ||
@@ -1016,4 +1034,2 @@ 'b1v', | ||
'b7v', | ||
'b8h', | ||
'b8v', | ||
'c1h', | ||
@@ -1033,4 +1049,2 @@ 'c1v', | ||
'c7v', | ||
'c8h', | ||
'c8v', | ||
'd1h', | ||
@@ -1050,4 +1064,2 @@ 'd1v', | ||
'd7v', | ||
'd8h', | ||
'd8v', | ||
'e1h', | ||
@@ -1067,4 +1079,2 @@ 'e1v', | ||
'e7v', | ||
'e8h', | ||
'e8v', | ||
'f1h', | ||
@@ -1084,4 +1094,2 @@ 'f1v', | ||
'f7v', | ||
'f8h', | ||
'f8v', | ||
'g1h', | ||
@@ -1101,4 +1109,2 @@ 'g1v', | ||
'g7v', | ||
'g8h', | ||
'g8v', | ||
'h1h', | ||
@@ -1118,6 +1124,76 @@ 'h1v', | ||
'h7v', | ||
'h8h', | ||
'h8v', | ||
]; | ||
exports.verticallyIncrementableWallPositions = [ | ||
exports.verticallyIncrementablePositions = new Set([ | ||
'a1', | ||
'a2', | ||
'a3', | ||
'a4', | ||
'a5', | ||
'a6', | ||
'a7', | ||
'a8', | ||
'b1', | ||
'b2', | ||
'b3', | ||
'b4', | ||
'b5', | ||
'b6', | ||
'b7', | ||
'b8', | ||
'c1', | ||
'c2', | ||
'c3', | ||
'c4', | ||
'c5', | ||
'c6', | ||
'c7', | ||
'c8', | ||
'd1', | ||
'd2', | ||
'd3', | ||
'd4', | ||
'd5', | ||
'd6', | ||
'd7', | ||
'd8', | ||
'e1', | ||
'e2', | ||
'e3', | ||
'e4', | ||
'e5', | ||
'e6', | ||
'e7', | ||
'e8', | ||
'f1', | ||
'f2', | ||
'f3', | ||
'f4', | ||
'f5', | ||
'f6', | ||
'f7', | ||
'f8', | ||
'g1', | ||
'g2', | ||
'g3', | ||
'g4', | ||
'g5', | ||
'g6', | ||
'g7', | ||
'g8', | ||
'h1', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'h7', | ||
'h8', | ||
'i1', | ||
'i2', | ||
'i3', | ||
'i4', | ||
'i5', | ||
'i6', | ||
'i7', | ||
'i8', | ||
'a1h', | ||
@@ -1235,4 +1311,76 @@ 'a1v', | ||
'h7v', | ||
]; | ||
exports.verticallyDecrementableWallPositions = [ | ||
]); | ||
exports.verticallyDecrementablePositions = new Set([ | ||
'a2', | ||
'a3', | ||
'a4', | ||
'a5', | ||
'a6', | ||
'a7', | ||
'a8', | ||
'a9', | ||
'b2', | ||
'b3', | ||
'b4', | ||
'b5', | ||
'b6', | ||
'b7', | ||
'b8', | ||
'b9', | ||
'c2', | ||
'c3', | ||
'c4', | ||
'c5', | ||
'c6', | ||
'c7', | ||
'c8', | ||
'c9', | ||
'd2', | ||
'd3', | ||
'd4', | ||
'd5', | ||
'd6', | ||
'd7', | ||
'd8', | ||
'd9', | ||
'e2', | ||
'e3', | ||
'e4', | ||
'e5', | ||
'e6', | ||
'e7', | ||
'e8', | ||
'e9', | ||
'f2', | ||
'f3', | ||
'f4', | ||
'f5', | ||
'f6', | ||
'f7', | ||
'f8', | ||
'f9', | ||
'g2', | ||
'g3', | ||
'g4', | ||
'g5', | ||
'g6', | ||
'g7', | ||
'g8', | ||
'g9', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'h7', | ||
'h8', | ||
'h9', | ||
'i2', | ||
'i3', | ||
'i4', | ||
'i5', | ||
'i6', | ||
'i7', | ||
'i8', | ||
'i9', | ||
'a2h', | ||
@@ -1350,3 +1498,3 @@ 'a2v', | ||
'h8v', | ||
]; | ||
]); | ||
exports.verticalPiecePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
@@ -1613,85 +1761,2 @@ exports.decrementedHorizontalWallCoordinates = { | ||
}; | ||
exports.isVerticallyIncrementablePawnPositionMap = { | ||
a1: true, | ||
a2: true, | ||
a3: true, | ||
a4: true, | ||
a5: true, | ||
a6: true, | ||
a7: true, | ||
a8: true, | ||
a9: false, | ||
b1: true, | ||
b2: true, | ||
b3: true, | ||
b4: true, | ||
b5: true, | ||
b6: true, | ||
b7: true, | ||
b8: true, | ||
b9: false, | ||
c1: true, | ||
c2: true, | ||
c3: true, | ||
c4: true, | ||
c5: true, | ||
c6: true, | ||
c7: true, | ||
c8: true, | ||
c9: false, | ||
d1: true, | ||
d2: true, | ||
d3: true, | ||
d4: true, | ||
d5: true, | ||
d6: true, | ||
d7: true, | ||
d8: true, | ||
d9: false, | ||
e1: true, | ||
e2: true, | ||
e3: true, | ||
e4: true, | ||
e5: true, | ||
e6: true, | ||
e7: true, | ||
e8: true, | ||
e9: false, | ||
f1: true, | ||
f2: true, | ||
f3: true, | ||
f4: true, | ||
f5: true, | ||
f6: true, | ||
f7: true, | ||
f8: true, | ||
f9: false, | ||
g1: true, | ||
g2: true, | ||
g3: true, | ||
g4: true, | ||
g5: true, | ||
g6: true, | ||
g7: true, | ||
g8: true, | ||
g9: false, | ||
h1: true, | ||
h2: true, | ||
h3: true, | ||
h4: true, | ||
h5: true, | ||
h6: true, | ||
h7: true, | ||
h8: true, | ||
h9: false, | ||
i1: true, | ||
i2: true, | ||
i3: true, | ||
i4: true, | ||
i5: true, | ||
i6: true, | ||
i7: true, | ||
i8: true, | ||
i9: false, | ||
}; | ||
exports.verticallyDecrementedPawnPositions = { | ||
@@ -1771,85 +1836,2 @@ a2: 'a1', | ||
}; | ||
exports.isVerticallyDecrementablePawnPositionMap = { | ||
a1: false, | ||
a2: true, | ||
a3: true, | ||
a4: true, | ||
a5: true, | ||
a6: true, | ||
a7: true, | ||
a8: true, | ||
a9: true, | ||
b1: false, | ||
b2: true, | ||
b3: true, | ||
b4: true, | ||
b5: true, | ||
b6: true, | ||
b7: true, | ||
b8: true, | ||
b9: true, | ||
c1: false, | ||
c2: true, | ||
c3: true, | ||
c4: true, | ||
c5: true, | ||
c6: true, | ||
c7: true, | ||
c8: true, | ||
c9: true, | ||
d1: false, | ||
d2: true, | ||
d3: true, | ||
d4: true, | ||
d5: true, | ||
d6: true, | ||
d7: true, | ||
d8: true, | ||
d9: true, | ||
e1: false, | ||
e2: true, | ||
e3: true, | ||
e4: true, | ||
e5: true, | ||
e6: true, | ||
e7: true, | ||
e8: true, | ||
e9: true, | ||
f1: false, | ||
f2: true, | ||
f3: true, | ||
f4: true, | ||
f5: true, | ||
f6: true, | ||
f7: true, | ||
f8: true, | ||
f9: true, | ||
g1: false, | ||
g2: true, | ||
g3: true, | ||
g4: true, | ||
g5: true, | ||
g6: true, | ||
g7: true, | ||
g8: true, | ||
g9: true, | ||
h1: false, | ||
h2: true, | ||
h3: true, | ||
h4: true, | ||
h5: true, | ||
h6: true, | ||
h7: true, | ||
h8: true, | ||
h9: true, | ||
i1: false, | ||
i2: true, | ||
i3: true, | ||
i4: true, | ||
i5: true, | ||
i6: true, | ||
i7: true, | ||
i8: true, | ||
i9: true, | ||
}; | ||
exports.horizontallyIncrementedPawnPositions = { | ||
@@ -1929,85 +1911,374 @@ a1: 'b1', | ||
}; | ||
exports.isHorizontallyIncrementablePawnPositionMap = { | ||
a1: true, | ||
a2: true, | ||
a3: true, | ||
a4: true, | ||
a5: true, | ||
a6: true, | ||
a7: true, | ||
a8: true, | ||
a9: true, | ||
b1: true, | ||
b2: true, | ||
b3: true, | ||
b4: true, | ||
b5: true, | ||
b6: true, | ||
b7: true, | ||
b8: true, | ||
b9: true, | ||
c1: true, | ||
c2: true, | ||
c3: true, | ||
c4: true, | ||
c5: true, | ||
c6: true, | ||
c7: true, | ||
c8: true, | ||
c9: true, | ||
d1: true, | ||
d2: true, | ||
d3: true, | ||
d4: true, | ||
d5: true, | ||
d6: true, | ||
d7: true, | ||
d8: true, | ||
d9: true, | ||
e1: true, | ||
e2: true, | ||
e3: true, | ||
e4: true, | ||
e5: true, | ||
e6: true, | ||
e7: true, | ||
e8: true, | ||
e9: true, | ||
f1: true, | ||
f2: true, | ||
f3: true, | ||
f4: true, | ||
f5: true, | ||
f6: true, | ||
f7: true, | ||
f8: true, | ||
f9: true, | ||
g1: true, | ||
g2: true, | ||
g3: true, | ||
g4: true, | ||
g5: true, | ||
g6: true, | ||
g7: true, | ||
g8: true, | ||
g9: true, | ||
h1: true, | ||
h2: true, | ||
h3: true, | ||
h4: true, | ||
h5: true, | ||
h6: true, | ||
h7: true, | ||
h8: true, | ||
h9: true, | ||
i1: false, | ||
i2: false, | ||
i3: false, | ||
i4: false, | ||
i5: false, | ||
i6: false, | ||
i7: false, | ||
i8: false, | ||
i9: false, | ||
}; | ||
exports.horizontallyIncrementablePositions = new Set([ | ||
'a1', | ||
'a2', | ||
'a3', | ||
'a4', | ||
'a5', | ||
'a6', | ||
'a7', | ||
'a8', | ||
'a9', | ||
'b1', | ||
'b2', | ||
'b3', | ||
'b4', | ||
'b5', | ||
'b6', | ||
'b7', | ||
'b8', | ||
'b9', | ||
'c1', | ||
'c2', | ||
'c3', | ||
'c4', | ||
'c5', | ||
'c6', | ||
'c7', | ||
'c8', | ||
'c9', | ||
'd1', | ||
'd2', | ||
'd3', | ||
'd4', | ||
'd5', | ||
'd6', | ||
'd7', | ||
'd8', | ||
'd9', | ||
'e1', | ||
'e2', | ||
'e3', | ||
'e4', | ||
'e5', | ||
'e6', | ||
'e7', | ||
'e8', | ||
'e9', | ||
'f1', | ||
'f2', | ||
'f3', | ||
'f4', | ||
'f5', | ||
'f6', | ||
'f7', | ||
'f8', | ||
'f9', | ||
'g1', | ||
'g2', | ||
'g3', | ||
'g4', | ||
'g5', | ||
'g6', | ||
'g7', | ||
'g8', | ||
'g9', | ||
'h1', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'h7', | ||
'h8', | ||
'h9', | ||
'a1h', | ||
'a1v', | ||
'a2h', | ||
'a2v', | ||
'a3h', | ||
'a3v', | ||
'a4h', | ||
'a4v', | ||
'a5h', | ||
'a5v', | ||
'a6h', | ||
'a6v', | ||
'a7h', | ||
'a7v', | ||
'a8h', | ||
'a8v', | ||
'b1h', | ||
'b1v', | ||
'b2h', | ||
'b2v', | ||
'b3h', | ||
'b3v', | ||
'b4h', | ||
'b4v', | ||
'b5h', | ||
'b5v', | ||
'b6h', | ||
'b6v', | ||
'b7h', | ||
'b7v', | ||
'b8h', | ||
'b8v', | ||
'c1h', | ||
'c1v', | ||
'c2h', | ||
'c2v', | ||
'c3h', | ||
'c3v', | ||
'c4h', | ||
'c4v', | ||
'c5h', | ||
'c5v', | ||
'c6h', | ||
'c6v', | ||
'c7h', | ||
'c7v', | ||
'c8h', | ||
'c8v', | ||
'd1h', | ||
'd1v', | ||
'd2h', | ||
'd2v', | ||
'd3h', | ||
'd3v', | ||
'd4h', | ||
'd4v', | ||
'd5h', | ||
'd5v', | ||
'd6h', | ||
'd6v', | ||
'd7h', | ||
'd7v', | ||
'd8h', | ||
'd8v', | ||
'e1h', | ||
'e1v', | ||
'e2h', | ||
'e2v', | ||
'e3h', | ||
'e3v', | ||
'e4h', | ||
'e4v', | ||
'e5h', | ||
'e5v', | ||
'e6h', | ||
'e6v', | ||
'e7h', | ||
'e7v', | ||
'e8h', | ||
'e8v', | ||
'f1h', | ||
'f1v', | ||
'f2h', | ||
'f2v', | ||
'f3h', | ||
'f3v', | ||
'f4h', | ||
'f4v', | ||
'f5h', | ||
'f5v', | ||
'f6h', | ||
'f6v', | ||
'f7h', | ||
'f7v', | ||
'f8h', | ||
'f8v', | ||
'g1h', | ||
'g1v', | ||
'g2h', | ||
'g2v', | ||
'g3h', | ||
'g3v', | ||
'g4h', | ||
'g4v', | ||
'g5h', | ||
'g5v', | ||
'g6h', | ||
'g6v', | ||
'g7h', | ||
'g7v', | ||
'g8h', | ||
'g8v', | ||
]); | ||
exports.horizontallyDecrementablePositions = new Set([ | ||
'b1', | ||
'b2', | ||
'b3', | ||
'b4', | ||
'b5', | ||
'b6', | ||
'b7', | ||
'b8', | ||
'b9', | ||
'c1', | ||
'c2', | ||
'c3', | ||
'c4', | ||
'c5', | ||
'c6', | ||
'c7', | ||
'c8', | ||
'c9', | ||
'd1', | ||
'd2', | ||
'd3', | ||
'd4', | ||
'd5', | ||
'd6', | ||
'd7', | ||
'd8', | ||
'd9', | ||
'e1', | ||
'e2', | ||
'e3', | ||
'e4', | ||
'e5', | ||
'e6', | ||
'e7', | ||
'e8', | ||
'e9', | ||
'f1', | ||
'f2', | ||
'f3', | ||
'f4', | ||
'f5', | ||
'f6', | ||
'f7', | ||
'f8', | ||
'f9', | ||
'g1', | ||
'g2', | ||
'g3', | ||
'g4', | ||
'g5', | ||
'g6', | ||
'g7', | ||
'g8', | ||
'g9', | ||
'h1', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'h7', | ||
'h8', | ||
'h9', | ||
'i1', | ||
'i2', | ||
'i3', | ||
'i4', | ||
'i5', | ||
'i6', | ||
'i7', | ||
'i8', | ||
'i9', | ||
'b1h', | ||
'b1v', | ||
'b2h', | ||
'b2v', | ||
'b3h', | ||
'b3v', | ||
'b4h', | ||
'b4v', | ||
'b5h', | ||
'b5v', | ||
'b6h', | ||
'b6v', | ||
'b7h', | ||
'b7v', | ||
'b8h', | ||
'b8v', | ||
'c1h', | ||
'c1v', | ||
'c2h', | ||
'c2v', | ||
'c3h', | ||
'c3v', | ||
'c4h', | ||
'c4v', | ||
'c5h', | ||
'c5v', | ||
'c6h', | ||
'c6v', | ||
'c7h', | ||
'c7v', | ||
'c8h', | ||
'c8v', | ||
'd1h', | ||
'd1v', | ||
'd2h', | ||
'd2v', | ||
'd3h', | ||
'd3v', | ||
'd4h', | ||
'd4v', | ||
'd5h', | ||
'd5v', | ||
'd6h', | ||
'd6v', | ||
'd7h', | ||
'd7v', | ||
'd8h', | ||
'd8v', | ||
'e1h', | ||
'e1v', | ||
'e2h', | ||
'e2v', | ||
'e3h', | ||
'e3v', | ||
'e4h', | ||
'e4v', | ||
'e5h', | ||
'e5v', | ||
'e6h', | ||
'e6v', | ||
'e7h', | ||
'e7v', | ||
'e8h', | ||
'e8v', | ||
'f1h', | ||
'f1v', | ||
'f2h', | ||
'f2v', | ||
'f3h', | ||
'f3v', | ||
'f4h', | ||
'f4v', | ||
'f5h', | ||
'f5v', | ||
'f6h', | ||
'f6v', | ||
'f7h', | ||
'f7v', | ||
'f8h', | ||
'f8v', | ||
'g1h', | ||
'g1v', | ||
'g2h', | ||
'g2v', | ||
'g3h', | ||
'g3v', | ||
'g4h', | ||
'g4v', | ||
'g5h', | ||
'g5v', | ||
'g6h', | ||
'g6v', | ||
'g7h', | ||
'g7v', | ||
'g8h', | ||
'g8v', | ||
'h1h', | ||
'h1v', | ||
'h2h', | ||
'h2v', | ||
'h3h', | ||
'h3v', | ||
'h4h', | ||
'h4v', | ||
'h5h', | ||
'h5v', | ||
'h6h', | ||
'h6v', | ||
'h7h', | ||
'h7v', | ||
'h8h', | ||
'h8v', | ||
]); | ||
exports.horizontallyDecrementedPawnPositions = { | ||
@@ -2087,84 +2358,1 @@ b1: 'a1', | ||
}; | ||
exports.isHorizontallyDecrementablePawnPositionMap = { | ||
a1: false, | ||
a2: false, | ||
a3: false, | ||
a4: false, | ||
a5: false, | ||
a6: false, | ||
a7: false, | ||
a8: false, | ||
a9: false, | ||
b1: true, | ||
b2: true, | ||
b3: true, | ||
b4: true, | ||
b5: true, | ||
b6: true, | ||
b7: true, | ||
b8: true, | ||
b9: true, | ||
c1: true, | ||
c2: true, | ||
c3: true, | ||
c4: true, | ||
c5: true, | ||
c6: true, | ||
c7: true, | ||
c8: true, | ||
c9: true, | ||
d1: true, | ||
d2: true, | ||
d3: true, | ||
d4: true, | ||
d5: true, | ||
d6: true, | ||
d7: true, | ||
d8: true, | ||
d9: true, | ||
e1: true, | ||
e2: true, | ||
e3: true, | ||
e4: true, | ||
e5: true, | ||
e6: true, | ||
e7: true, | ||
e8: true, | ||
e9: true, | ||
f1: true, | ||
f2: true, | ||
f3: true, | ||
f4: true, | ||
f5: true, | ||
f6: true, | ||
f7: true, | ||
f8: true, | ||
f9: true, | ||
g1: true, | ||
g2: true, | ||
g3: true, | ||
g4: true, | ||
g5: true, | ||
g6: true, | ||
g7: true, | ||
g8: true, | ||
g9: true, | ||
h1: true, | ||
h2: true, | ||
h3: true, | ||
h4: true, | ||
h5: true, | ||
h6: true, | ||
h7: true, | ||
h8: true, | ||
h9: true, | ||
i1: true, | ||
i2: true, | ||
i3: true, | ||
i4: true, | ||
i5: true, | ||
i6: true, | ||
i7: true, | ||
i8: true, | ||
i9: true, | ||
}; |
@@ -7,4 +7,4 @@ "use strict"; | ||
var createGameFromMoves = function (moves) { | ||
return moves.reduce(makeUnvalidatedMove_1.makeUnvalidatedMove, createNewGame_1.createNewGame()); | ||
return moves.reduce(makeUnvalidatedMove_1.makeUnvalidatedMove, (0, createNewGame_1.createNewGame)()); | ||
}; | ||
exports.createGameFromMoves = createGameFromMoves; |
@@ -15,4 +15,4 @@ "use strict"; | ||
var player2WallCount = game.playerWallCounts[2]; | ||
var player1WallCountString = player1WallCount === 10 ? player1WallCount : "0" + player1WallCount; | ||
var player2WallCountString = player2WallCount === 10 ? player2WallCount : "0" + player2WallCount; | ||
var player1WallCountString = player1WallCount === 10 ? player1WallCount : "0".concat(player1WallCount); | ||
var player2WallCountString = player2WallCount === 10 ? player2WallCount : "0".concat(player2WallCount); | ||
var wallPositionsString = ''; | ||
@@ -25,4 +25,4 @@ for (var _i = 0, wallPositions_1 = consts_1.wallPositions; _i < wallPositions_1.length; _i++) { | ||
} | ||
return "" + player1Position + player2Position + player1WallCountString + player2WallCountString + wallPositionsString; | ||
return "".concat(player1Position).concat(player2Position).concat(player1WallCountString).concat(player2WallCountString).concat(wallPositionsString); | ||
}; | ||
exports.getHash = getHash; |
@@ -9,10 +9,10 @@ "use strict"; | ||
if (placedHorizontalWalls.some(function (wall) { | ||
return utils_1.doesHorizontalWallBlockPlayer(game, player, wall); | ||
return (0, utils_1.doesHorizontalWallBlockPlayer)(game, player, wall); | ||
})) { | ||
return aStar_1.aStar(game, player); | ||
return (0, aStar_1.aStar)(game, player); | ||
} | ||
// The shortest path has no obstacles if no horizontal walls have been placed | ||
// between the player and the goal | ||
return utils_1.getShortestPathWithNoObstacles(game, player); | ||
return (0, utils_1.getShortestPathWithNoObstacles)(game, player); | ||
}; | ||
exports.getShortestPath = getShortestPath; |
@@ -44,7 +44,7 @@ "use strict"; | ||
for (var y = 9; y > 0; y--) { | ||
var row = "\u2502 " + y + " \u2502"; | ||
var row = "\u2502 ".concat(y, " \u2502"); | ||
for (var _i = 0, horizontalPawnCoordinates_1 = consts_1.horizontalPawnCoordinates; _i < horizontalPawnCoordinates_1.length; _i++) { | ||
var x = horizontalPawnCoordinates_1[_i]; | ||
var pawnPosition = "" + x + y; | ||
var verticalWallPosition = "" + x + y + "v"; | ||
var pawnPosition = "".concat(x).concat(y); | ||
var verticalWallPosition = "".concat(x).concat(y, "v"); | ||
if (game.board[pawnPosition] === null) { | ||
@@ -54,6 +54,6 @@ row += ' '; | ||
else { | ||
row += " " + game.board[pawnPosition] + " "; | ||
row += " ".concat(game.board[pawnPosition], " "); | ||
} | ||
if (utils_1.isWallPosition(verticalWallPosition) && | ||
utils_1.hasWallToTheRight(game, pawnPosition)) { | ||
if ((0, utils_1.isWallPosition)(verticalWallPosition) && | ||
(0, utils_1.hasWallToTheRight)(game, pawnPosition)) { | ||
row += '║'; | ||
@@ -65,3 +65,3 @@ } | ||
} | ||
board += row + " \u2502\n"; | ||
board += "".concat(row, " \u2502\n"); | ||
if (y > 1) { | ||
@@ -71,5 +71,5 @@ row = '│ ├'; | ||
var x = horizontalPawnCoordinates_2[_a]; | ||
var horizontalWallPosition = "" + x + y + "h"; | ||
var pawnPosition = "" + x + y; | ||
if (utils_1.hasWallBelow(game, pawnPosition)) { | ||
var horizontalWallPosition = "".concat(x).concat(y, "h"); | ||
var pawnPosition = "".concat(x).concat(y); | ||
if ((0, utils_1.hasWallBelow)(game, pawnPosition)) { | ||
row += '═══'; | ||
@@ -80,9 +80,9 @@ } | ||
} | ||
if (utils_1.isHorizontalWallCoordinate(x)) { | ||
if (utils_1.isWallPosition(horizontalWallPosition) && | ||
utils_1.isVerticallyDecrementableWallPosition(horizontalWallPosition) && | ||
game.board[utils_1.moveWallDown(horizontalWallPosition)]) { | ||
if ((0, utils_1.isHorizontalWallCoordinate)(x)) { | ||
if ((0, utils_1.isWallPosition)(horizontalWallPosition) && | ||
(0, utils_1.isVerticallyDecrementableWallPosition)(horizontalWallPosition) && | ||
game.board[(0, utils_1.moveWallDown)(horizontalWallPosition)]) { | ||
row += '╪'; | ||
} | ||
else if (utils_1.hasWallToTheRight(game, pawnPosition)) { | ||
else if ((0, utils_1.hasWallToTheRight)(game, pawnPosition)) { | ||
row += '╫'; | ||
@@ -98,3 +98,3 @@ // Here we don't need to check for horizontal specifically. The x | ||
row += '┤'; | ||
board += row + " \u2502\n"; | ||
board += "".concat(row, " \u2502\n"); | ||
} | ||
@@ -114,3 +114,3 @@ } | ||
else { | ||
board += " " + numberToLetter(wallIndex).toUpperCase() + " "; | ||
board += " ".concat(numberToLetter(wallIndex).toUpperCase(), " "); | ||
} | ||
@@ -117,0 +117,0 @@ } |
"use strict"; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -11,6 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var getValidMoveArray = function (game) { | ||
var validPawnMoveArray = utils_1.getValidPawnMoveArray(game); | ||
var validWallMoveArray = utils_1.getValidWallMoveArray(game); | ||
return __spreadArray(__spreadArray([], validPawnMoveArray), validWallMoveArray); | ||
var validPawnMoveArray = (0, utils_1.getValidPawnMoveArray)(game); | ||
var validWallMoveArray = (0, utils_1.getValidWallMoveArray)(game); | ||
return __spreadArray(__spreadArray([], validPawnMoveArray, true), validWallMoveArray, true); | ||
}; | ||
exports.getValidMoveArray = getValidMoveArray; |
@@ -6,5 +6,5 @@ "use strict"; | ||
var getWinner = function (game) { | ||
if (utils_1.getVerticalCoordinate(game.playerPositions[1].position) === 9) | ||
if ((0, utils_1.getVerticalCoordinate)(game.playerPositions[1].position) === 9) | ||
return 1; | ||
if (utils_1.getVerticalCoordinate(game.playerPositions[2].position) === 1) | ||
if ((0, utils_1.getVerticalCoordinate)(game.playerPositions[2].position) === 1) | ||
return 2; | ||
@@ -11,0 +11,0 @@ return null; |
@@ -37,3 +37,3 @@ export { createNewGame } from './createNewGame'; | ||
}>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10>; | ||
}; |
@@ -6,4 +6,4 @@ "use strict"; | ||
var isGameOver = function (game) { | ||
return getWinner_1.getWinner(game) !== null; | ||
return (0, getWinner_1.getWinner)(game) !== null; | ||
}; | ||
exports.isGameOver = isGameOver; |
@@ -14,17 +14,17 @@ "use strict"; | ||
var isMoveInteresting = function (game, move) { | ||
if (utils_1.isPawnMove(move)) | ||
if ((0, utils_1.isPawnMove)(move)) | ||
return true; | ||
if (utils_1.getNumberOfNeighborWalls(game, move) > 0) | ||
if ((0, utils_1.getNumberOfNeighborWalls)(game, move) > 0) | ||
return true; | ||
var player1ShortestPath = getShortestPath_1.getShortestPath(game, 1); | ||
var player1ShortestPath = (0, getShortestPath_1.getShortestPath)(game, 1); | ||
if (!player1ShortestPath) | ||
return false; | ||
if (utils_1.overlapsPath(player1ShortestPath, move)) | ||
if ((0, utils_1.overlapsPath)(player1ShortestPath, move)) | ||
return true; | ||
var player2ShortestPath = getShortestPath_1.getShortestPath(game, 2); | ||
var player2ShortestPath = (0, getShortestPath_1.getShortestPath)(game, 2); | ||
if (!player2ShortestPath) | ||
return false; | ||
if (utils_1.overlapsPath(player2ShortestPath, move)) | ||
if ((0, utils_1.overlapsPath)(player2ShortestPath, move)) | ||
return true; | ||
if (utils_1.isWallAdjacentToAtLeastOnePawn(game, move)) | ||
if ((0, utils_1.isWallAdjacentToAtLeastOnePawn)(game, move)) | ||
return true; | ||
@@ -31,0 +31,0 @@ return false; |
@@ -10,11 +10,11 @@ "use strict"; | ||
// Handle wall moves | ||
var currentPosition = game.playerPositions[getTurn_1.getTurn(game)].position; | ||
if (utils_1.isWallPosition(move)) { | ||
if (game.playerWallCounts[getTurn_1.getTurn(game)] < 1) | ||
var currentPosition = game.playerPositions[(0, getTurn_1.getTurn)(game)].position; | ||
if ((0, utils_1.isWallPosition)(move)) { | ||
if (game.playerWallCounts[(0, getTurn_1.getTurn)(game)] < 1) | ||
return false; // Check that player has enough walls | ||
if (utils_1.doesWallMoveOverlapExistingWall(game, move)) | ||
if ((0, utils_1.doesWallMoveOverlapExistingWall)(game, move)) | ||
return false; // Check that wall does not overlap other walls | ||
var gameWithUnvalidatedMove = makeUnvalidatedMove_1.makeUnvalidatedMove(game, move); | ||
if (getShortestPath_1.getShortestPath(gameWithUnvalidatedMove, getTurn_1.getTurn(game)) && | ||
getShortestPath_1.getShortestPath(gameWithUnvalidatedMove, utils_1.getOppositePlayer(getTurn_1.getTurn(game)))) { | ||
var gameWithUnvalidatedMove = (0, makeUnvalidatedMove_1.makeUnvalidatedMove)(game, move); | ||
if ((0, getShortestPath_1.getShortestPath)(gameWithUnvalidatedMove, (0, getTurn_1.getTurn)(game)) && | ||
(0, getShortestPath_1.getShortestPath)(gameWithUnvalidatedMove, (0, utils_1.getOppositePlayer)((0, getTurn_1.getTurn)(game)))) { | ||
return true; | ||
@@ -24,4 +24,4 @@ } | ||
} | ||
return utils_1.isValidNormalMove(game, currentPosition, move); | ||
return (0, utils_1.isValidNormalMove)(game, currentPosition, move); | ||
}; | ||
exports.isMoveValid = isMoveValid; |
@@ -7,6 +7,6 @@ "use strict"; | ||
var makeMove = function (game, move) { | ||
if (!isMoveValid_1.isMoveValid(game, move)) | ||
if (!(0, isMoveValid_1.isMoveValid)(game, move)) | ||
return game; | ||
return makeUnvalidatedMove_1.makeUnvalidatedMove(game, move); | ||
return (0, makeUnvalidatedMove_1.makeUnvalidatedMove)(game, move); | ||
}; | ||
exports.makeMove = makeMove; |
@@ -13,6 +13,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -25,5 +29,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _a, _b, _c, _d; | ||
if (utils_1.isWallPosition(move)) { | ||
if ((0, utils_1.isWallPosition)(move)) { | ||
// If wall move | ||
return __assign(__assign({}, game), { board: __assign(__assign({}, game.board), (_a = {}, _a[move] = true, _a)), playerWallCounts: __assign(__assign({}, game.playerWallCounts), (_b = {}, _b[getTurn_1.getTurn(game)] = game.playerWallCounts[getTurn_1.getTurn(game)] - 1, _b)), playerPositions: __assign(__assign({}, game.playerPositions), (_c = {}, _c[getTurn_1.getTurn(game)] = __assign(__assign({}, game.playerPositions[getTurn_1.getTurn(game)]), { previousPosition: game.playerPositions[getTurn_1.getTurn(game)] }), _c)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves), [move]), futureMoves: [] }); | ||
return __assign(__assign({}, game), { board: __assign(__assign({}, game.board), (_a = {}, _a[move] = true, _a)), playerWallCounts: __assign(__assign({}, game.playerWallCounts), (_b = {}, _b[(0, getTurn_1.getTurn)(game)] = game.playerWallCounts[(0, getTurn_1.getTurn)(game)] - 1, _b)), playerPositions: __assign(__assign({}, game.playerPositions), (_c = {}, _c[(0, getTurn_1.getTurn)(game)] = __assign(__assign({}, game.playerPositions[(0, getTurn_1.getTurn)(game)]), { previousPosition: game.playerPositions[(0, getTurn_1.getTurn)(game)] }), _c)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves, true), [move], false), futureMoves: [] }); | ||
} | ||
@@ -35,10 +39,10 @@ else { | ||
pos, | ||
pos === move ? getTurn_1.getTurn(game) : val === getTurn_1.getTurn(game) ? null : val, | ||
pos === move ? (0, getTurn_1.getTurn)(game) : val === (0, getTurn_1.getTurn)(game) ? null : val, | ||
]; | ||
})), playerPositions: __assign(__assign({}, game.playerPositions), (_d = {}, _d[getTurn_1.getTurn(game)] = { | ||
})), playerPositions: __assign(__assign({}, game.playerPositions), (_d = {}, _d[(0, getTurn_1.getTurn)(game)] = { | ||
position: move, | ||
previousPosition: game.playerPositions[getTurn_1.getTurn(game)], | ||
}, _d)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves), [move]), futureMoves: [] }); | ||
previousPosition: game.playerPositions[(0, getTurn_1.getTurn)(game)], | ||
}, _d)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves, true), [move], false), futureMoves: [] }); | ||
} | ||
}; | ||
exports.makeUnvalidatedMove = makeUnvalidatedMove; |
@@ -8,4 +8,4 @@ "use strict"; | ||
var _a; | ||
var mirroredPlayer1Position = utils_1.mirrorPositionHorizontally(hash.substring(0, 2)); | ||
var mirroredPlayer2Position = utils_1.mirrorPositionHorizontally(hash.substring(2, 4)); | ||
var mirroredPlayer1Position = (0, utils_1.mirrorPositionHorizontally)(hash.substring(0, 2)); | ||
var mirroredPlayer2Position = (0, utils_1.mirrorPositionHorizontally)(hash.substring(2, 4)); | ||
var wallCountStrings = hash.substring(4, 8); | ||
@@ -20,4 +20,4 @@ var mirroredFilledWallPositions = new Set(((_a = hash.substring(8).match(/.{1,3}/g)) !== null && _a !== void 0 ? _a : []).map(utils_1.mirrorPositionHorizontally)); | ||
} | ||
return "" + mirroredPlayer1Position + mirroredPlayer2Position + wallCountStrings + wallPositionsString; | ||
return "".concat(mirroredPlayer1Position).concat(mirroredPlayer2Position).concat(wallCountStrings).concat(wallPositionsString); | ||
}; | ||
exports.mirrorHashHorizontally = mirrorHashHorizontally; |
@@ -10,3 +10,3 @@ import { Game } from './types'; | ||
}>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10>; | ||
}; |
@@ -13,6 +13,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -24,4 +28,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var redo = function (game) { | ||
return __assign(__assign({}, createGameFromMoves_1.createGameFromMoves(__spreadArray(__spreadArray([], game.pastMoves), [utils_1.first(game.futureMoves)]).filter(Boolean))), { futureMoves: utils_1.rest(game.futureMoves) }); | ||
return __assign(__assign({}, (0, createGameFromMoves_1.createGameFromMoves)(__spreadArray(__spreadArray([], game.pastMoves, true), [(0, utils_1.first)(game.futureMoves)], false).filter(Boolean))), { futureMoves: (0, utils_1.rest)(game.futureMoves) }); | ||
}; | ||
exports.redo = redo; |
@@ -10,3 +10,3 @@ import { Game } from './types'; | ||
}>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3>; | ||
playerWallCounts: Record<import("./types").Player, 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10>; | ||
}; |
@@ -13,6 +13,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -24,4 +28,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var undo = function (game) { | ||
return __assign(__assign({}, createGameFromMoves_1.createGameFromMoves(utils_1.butlast(game.pastMoves))), { futureMoves: __spreadArray([utils_1.last(game.pastMoves)], game.futureMoves).filter(Boolean) }); | ||
return __assign(__assign({}, (0, createGameFromMoves_1.createGameFromMoves)((0, utils_1.butlast)(game.pastMoves))), { futureMoves: __spreadArray([(0, utils_1.last)(game.pastMoves)], game.futureMoves, true).filter(Boolean) }); | ||
}; | ||
exports.undo = undo; |
478
lib/utils.js
"use strict"; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -70,7 +74,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var doesWallMoveOverlapExistingWall = function (game, wallMove) { | ||
if (exports.isHorizontalWallMove(wallMove)) { | ||
if ((0, exports.isHorizontalWallMove)(wallMove)) { | ||
if (game.board[wallMove] || | ||
game.board[rotateWall(wallMove)] || | ||
(exports.isHorizontallyDecrementableWallPosition(wallMove) && | ||
game.board[exports.moveWallLeft(wallMove)]) || | ||
((0, exports.isHorizontallyDecrementableWallPosition)(wallMove) && | ||
game.board[(0, exports.moveWallLeft)(wallMove)]) || | ||
(isHorizontallyIncrementableWallPosition(wallMove) && | ||
@@ -84,4 +88,4 @@ game.board[moveWallRight(wallMove)])) { | ||
game.board[rotateWall(wallMove)] || | ||
(exports.isVerticallyDecrementableWallPosition(wallMove) && | ||
game.board[exports.moveWallDown(wallMove)]) || | ||
((0, exports.isVerticallyDecrementableWallPosition)(wallMove) && | ||
game.board[(0, exports.moveWallDown)(wallMove)]) || | ||
(isVerticallyIncrementableWallPosition(wallMove) && | ||
@@ -104,13 +108,13 @@ game.board[moveWallUp(wallMove)])) { | ||
var isSingleUpMove = function (currentPosition, move) { | ||
return (exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
exports.verticallyIncrementPawnPosition(currentPosition) === move); | ||
return ((0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.verticallyIncrementPawnPosition)(currentPosition) === move); | ||
}; | ||
var hasWallAbove = function (game, move) { | ||
var horizontalCoordinate = exports.getHorizontalCoordinate(move); | ||
var verticalCoordinate = exports.getVerticalCoordinate(move); | ||
if ((exports.isHorizontalWallCoordinate(horizontalCoordinate) && | ||
exports.isVerticalWallCoordinate(verticalCoordinate) && | ||
game.board["" + horizontalCoordinate + verticalCoordinate + "h"]) || | ||
(exports.isHorizontallyDecrementablePawnPosition(move) && | ||
game.board[exports.horizontallyDecrementPawnPosition(move) + "h"])) { | ||
var horizontalCoordinate = (0, exports.getHorizontalCoordinate)(move); | ||
var verticalCoordinate = (0, exports.getVerticalCoordinate)(move); | ||
if (((0, exports.isHorizontalWallCoordinate)(horizontalCoordinate) && | ||
(0, exports.isVerticalWallCoordinate)(verticalCoordinate) && | ||
game.board["".concat(horizontalCoordinate).concat(verticalCoordinate, "h")]) || | ||
((0, exports.isHorizontallyDecrementablePawnPosition)(move) && | ||
game.board["".concat((0, exports.horizontallyDecrementPawnPosition)(move), "h")])) { | ||
return true; | ||
@@ -128,5 +132,5 @@ } | ||
var hasOpponentAbove = function (game, position) { | ||
return (exports.isVerticallyIncrementablePawnPosition(position) && | ||
game.board[exports.verticallyIncrementPawnPosition(position)] === | ||
exports.getOppositePlayer(getTurn_1.getTurn(game))); | ||
return ((0, exports.isVerticallyIncrementablePawnPosition)(position) && | ||
game.board[(0, exports.verticallyIncrementPawnPosition)(position)] === | ||
(0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game))); | ||
}; | ||
@@ -141,6 +145,6 @@ var isUpLeftMove = function (currentPosition, move) { | ||
var hasWallToTheRight = function (game, move) { | ||
var maybeWallPosition = move + "v"; | ||
if ((exports.isWallPosition(maybeWallPosition) && game.board[maybeWallPosition]) || | ||
(exports.isVerticallyDecrementablePawnPosition(move) && | ||
game.board[exports.verticallyDecrementPawnPosition(move) + "v"])) { | ||
var maybeWallPosition = "".concat(move, "v"); | ||
if (((0, exports.isWallPosition)(maybeWallPosition) && game.board[maybeWallPosition]) || | ||
((0, exports.isVerticallyDecrementablePawnPosition)(move) && | ||
game.board["".concat((0, exports.verticallyDecrementPawnPosition)(move), "v")])) { | ||
return true; | ||
@@ -151,6 +155,6 @@ } | ||
var isUpRightMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
-1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-1) { | ||
@@ -163,6 +167,6 @@ return true; | ||
var isRightUpMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
-1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-1) { | ||
@@ -174,12 +178,12 @@ return true; | ||
var hasWallToTheLeft = function (game, move) { | ||
var horizontalCoordinate = exports.getHorizontalCoordinate(move); | ||
var verticalCoordinate = exports.getVerticalCoordinate(move); | ||
if ((exports.getVerticalCoordinate(move) < 9 && | ||
var horizontalCoordinate = (0, exports.getHorizontalCoordinate)(move); | ||
var verticalCoordinate = (0, exports.getVerticalCoordinate)(move); | ||
if (((0, exports.getVerticalCoordinate)(move) < 9 && | ||
isDecrementableHorizontalPiecePosition(horizontalCoordinate) && | ||
exports.isVerticalWallCoordinate(verticalCoordinate) && | ||
game.board["" + decrementHorizontalPiecePosition(horizontalCoordinate) + verticalCoordinate + "v"]) || | ||
(exports.getVerticalCoordinate(move) > 1 && | ||
(0, exports.isVerticalWallCoordinate)(verticalCoordinate) && | ||
game.board["".concat(decrementHorizontalPiecePosition(horizontalCoordinate)).concat(verticalCoordinate, "v")]) || | ||
((0, exports.getVerticalCoordinate)(move) > 1 && | ||
isDecrementableHorizontalPiecePosition(horizontalCoordinate) && | ||
isDecrementableVerticalPiecePosition(verticalCoordinate) && | ||
game.board["" + decrementHorizontalPiecePosition(horizontalCoordinate) + decrementVerticalPiecePosition(verticalCoordinate) + "v"])) { | ||
game.board["".concat(decrementHorizontalPiecePosition(horizontalCoordinate)).concat(decrementVerticalPiecePosition(verticalCoordinate), "v")])) { | ||
return true; | ||
@@ -190,6 +194,6 @@ } | ||
var isSingleRightMove = function (currentPosition, move) { | ||
if (letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
if (letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-1 && | ||
exports.getVerticalCoordinate(currentPosition) === exports.getVerticalCoordinate(move)) { | ||
(0, exports.getVerticalCoordinate)(currentPosition) === (0, exports.getVerticalCoordinate)(move)) { | ||
return true; | ||
@@ -200,6 +204,6 @@ } | ||
var isDoubleRightMove = function (currentPosition, move) { | ||
if (letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
if (letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-2 && | ||
exports.getVerticalCoordinate(currentPosition) === exports.getVerticalCoordinate(move)) { | ||
(0, exports.getVerticalCoordinate)(currentPosition) === (0, exports.getVerticalCoordinate)(move)) { | ||
return true; | ||
@@ -210,5 +214,5 @@ } | ||
var hasOpponentToTheRight = function (game, position) { | ||
if (exports.isHorizontallyIncrementablePawnPosition(position) && | ||
game.board[exports.horizontallyIncrementPawnPosition(position)] === | ||
exports.getOppositePlayer(getTurn_1.getTurn(game))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(position) && | ||
game.board[(0, exports.horizontallyIncrementPawnPosition)(position)] === | ||
(0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game))) { | ||
return true; | ||
@@ -219,6 +223,6 @@ } | ||
var isRightDownMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-1) { | ||
@@ -230,11 +234,11 @@ return true; | ||
var hasWallBelow = function (game, move) { | ||
var horizontalCoordinate = exports.getHorizontalCoordinate(move); | ||
var verticalCoordinate = exports.getVerticalCoordinate(move); | ||
if ((exports.isHorizontalWallCoordinate(horizontalCoordinate) && | ||
var horizontalCoordinate = (0, exports.getHorizontalCoordinate)(move); | ||
var verticalCoordinate = (0, exports.getVerticalCoordinate)(move); | ||
if (((0, exports.isHorizontalWallCoordinate)(horizontalCoordinate) && | ||
isDecrementableVerticalPiecePosition(verticalCoordinate) && | ||
game.board["" + horizontalCoordinate + decrementVerticalPiecePosition(verticalCoordinate) + "h"]) || | ||
(letterToNumber(exports.getHorizontalCoordinate(move)) > 1 && | ||
game.board["".concat(horizontalCoordinate).concat(decrementVerticalPiecePosition(verticalCoordinate), "h")]) || | ||
(letterToNumber((0, exports.getHorizontalCoordinate)(move)) > 1 && | ||
isDecrementableHorizontalPiecePosition(horizontalCoordinate) && | ||
isDecrementableVerticalPiecePosition(verticalCoordinate) && | ||
game.board["" + decrementHorizontalPiecePosition(horizontalCoordinate) + decrementVerticalPiecePosition(verticalCoordinate) + "h"])) { | ||
game.board["".concat(decrementHorizontalPiecePosition(horizontalCoordinate)).concat(decrementVerticalPiecePosition(verticalCoordinate), "h")])) { | ||
return true; | ||
@@ -246,5 +250,5 @@ } | ||
var isSingleDownMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
1 && | ||
exports.getHorizontalCoordinate(currentPosition) === exports.getHorizontalCoordinate(move)) { | ||
(0, exports.getHorizontalCoordinate)(currentPosition) === (0, exports.getHorizontalCoordinate)(move)) { | ||
return true; | ||
@@ -255,5 +259,5 @@ } | ||
var isDoubleDownMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
2 && | ||
exports.getHorizontalCoordinate(currentPosition) === exports.getHorizontalCoordinate(move)) { | ||
(0, exports.getHorizontalCoordinate)(currentPosition) === (0, exports.getHorizontalCoordinate)(move)) { | ||
return true; | ||
@@ -264,5 +268,5 @@ } | ||
var hasOpponentBelow = function (game, position) { | ||
if (exports.isVerticallyDecrementablePawnPosition(position) && | ||
game.board[exports.verticallyDecrementPawnPosition(position)] === | ||
exports.getOppositePlayer(getTurn_1.getTurn(game))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(position) && | ||
game.board[(0, exports.verticallyDecrementPawnPosition)(position)] === | ||
(0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game))) { | ||
return true; | ||
@@ -273,6 +277,6 @@ } | ||
var isDownRightMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
-1) { | ||
@@ -284,6 +288,6 @@ return true; | ||
var isDownLeftMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
1) { | ||
@@ -295,6 +299,6 @@ return true; | ||
var isSingleLeftMove = function (currentPosition, move) { | ||
if (letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
if (letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
1 && | ||
exports.getVerticalCoordinate(currentPosition) === exports.getVerticalCoordinate(move)) { | ||
(0, exports.getVerticalCoordinate)(currentPosition) === (0, exports.getVerticalCoordinate)(move)) { | ||
return true; | ||
@@ -305,6 +309,6 @@ } | ||
var isDoubleLeftMove = function (currentPosition, move) { | ||
if (letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
if (letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
2 && | ||
exports.getVerticalCoordinate(currentPosition) === exports.getVerticalCoordinate(move)) { | ||
(0, exports.getVerticalCoordinate)(currentPosition) === (0, exports.getVerticalCoordinate)(move)) { | ||
return true; | ||
@@ -315,5 +319,5 @@ } | ||
var hasOpponentToTheLeft = function (game, position) { | ||
if (exports.isHorizontallyDecrementablePawnPosition(position) && | ||
game.board[exports.horizontallyDecrementPawnPosition(position)] === | ||
exports.getOppositePlayer(getTurn_1.getTurn(game))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(position) && | ||
game.board[(0, exports.horizontallyDecrementPawnPosition)(position)] === | ||
(0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game))) { | ||
return true; | ||
@@ -324,6 +328,6 @@ } | ||
var isLeftDownMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
1) { | ||
@@ -336,6 +340,6 @@ return true; | ||
var isLeftUpMove = function (currentPosition, move) { | ||
if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) === | ||
if ((0, exports.getVerticalCoordinate)(currentPosition) - (0, exports.getVerticalCoordinate)(move) === | ||
-1 && | ||
letterToNumber(exports.getHorizontalCoordinate(currentPosition)) - | ||
letterToNumber(exports.getHorizontalCoordinate(move)) === | ||
letterToNumber((0, exports.getHorizontalCoordinate)(currentPosition)) - | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) === | ||
1) { | ||
@@ -347,12 +351,12 @@ return true; | ||
var isOnRightmostRow = function (move) { | ||
return exports.getHorizontalCoordinate(move) === 'i'; | ||
return (0, exports.getHorizontalCoordinate)(move) === 'i'; | ||
}; | ||
var isOnLeftmostRow = function (move) { | ||
return exports.getHorizontalCoordinate(move) === 'a'; | ||
return (0, exports.getHorizontalCoordinate)(move) === 'a'; | ||
}; | ||
var isOnTopRow = function (move) { | ||
return exports.getVerticalCoordinate(move) === 9; | ||
return (0, exports.getVerticalCoordinate)(move) === 9; | ||
}; | ||
var isOnBottomRow = function (move) { | ||
return exports.getVerticalCoordinate(move) === 1; | ||
return (0, exports.getVerticalCoordinate)(move) === 1; | ||
}; | ||
@@ -366,7 +370,7 @@ var isValidAStarMove = function (game, currentPosition, move) { | ||
if (isSingleRightMove(currentPosition, move)) { | ||
return !exports.hasWallToTheRight(game, currentPosition); | ||
return !(0, exports.hasWallToTheRight)(game, currentPosition); | ||
} | ||
// If down move | ||
if (isSingleDownMove(currentPosition, move)) { | ||
return !exports.hasWallBelow(game, currentPosition); | ||
return !(0, exports.hasWallBelow)(game, currentPosition); | ||
} | ||
@@ -384,11 +388,11 @@ // If left move | ||
// bit incorrectly typed. | ||
if (letterToNumber(exports.getHorizontalCoordinate(move)) < 1 || | ||
letterToNumber(exports.getHorizontalCoordinate(move)) > 9) { | ||
if (letterToNumber((0, exports.getHorizontalCoordinate)(move)) < 1 || | ||
letterToNumber((0, exports.getHorizontalCoordinate)(move)) > 9) { | ||
return false; | ||
} | ||
if (exports.getVerticalCoordinate(move) < 1 || exports.getVerticalCoordinate(move) > 9) { | ||
if ((0, exports.getVerticalCoordinate)(move) < 1 || (0, exports.getVerticalCoordinate)(move) > 9) { | ||
return false; | ||
} | ||
// If the move lands on top of the opponent | ||
if (game.board[move] === exports.getOppositePlayer(getTurn_1.getTurn(game))) { | ||
if (game.board[move] === (0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game))) { | ||
return false; | ||
@@ -406,4 +410,4 @@ } | ||
return false; | ||
if (exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
hasWallAbove(game, exports.verticallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
hasWallAbove(game, (0, exports.verticallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -415,5 +419,5 @@ } | ||
hasOpponentAbove(game, currentPosition)) { | ||
if (exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
!hasWallAbove(game, exports.verticallyIncrementPawnPosition(currentPosition)) && | ||
!isOnTopRow(exports.verticallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
!hasWallAbove(game, (0, exports.verticallyIncrementPawnPosition)(currentPosition)) && | ||
!isOnTopRow((0, exports.verticallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -423,4 +427,4 @@ } | ||
return false; | ||
if (exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
exports.hasWallToTheRight(game, exports.verticallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallToTheRight)(game, (0, exports.verticallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -432,5 +436,5 @@ } | ||
hasOpponentAbove(game, currentPosition)) { | ||
if (exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
!hasWallAbove(game, exports.verticallyIncrementPawnPosition(currentPosition)) && | ||
!isOnTopRow(exports.verticallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
!hasWallAbove(game, (0, exports.verticallyIncrementPawnPosition)(currentPosition)) && | ||
!isOnTopRow((0, exports.verticallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -440,4 +444,4 @@ } | ||
return false; | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
hasWallToTheLeft(game, exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
hasWallToTheLeft(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -449,3 +453,3 @@ } | ||
if (isSingleRightMove(currentPosition, move)) { | ||
if (exports.hasWallToTheRight(game, currentPosition)) | ||
if ((0, exports.hasWallToTheRight)(game, currentPosition)) | ||
return false; | ||
@@ -456,6 +460,6 @@ return true; | ||
hasOpponentToTheRight(game, currentPosition)) { | ||
if (exports.hasWallToTheRight(game, currentPosition)) | ||
if ((0, exports.hasWallToTheRight)(game, currentPosition)) | ||
return false; | ||
if (exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
exports.hasWallToTheRight(game, exports.horizontallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallToTheRight)(game, (0, exports.horizontallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -467,11 +471,11 @@ } | ||
hasOpponentToTheRight(game, currentPosition)) { | ||
if (exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
!exports.hasWallToTheRight(game, exports.horizontallyIncrementPawnPosition(currentPosition)) && | ||
!isOnRightmostRow(exports.horizontallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
!(0, exports.hasWallToTheRight)(game, (0, exports.horizontallyIncrementPawnPosition)(currentPosition)) && | ||
!isOnRightmostRow((0, exports.horizontallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
} | ||
if (exports.hasWallToTheRight(game, currentPosition)) | ||
if ((0, exports.hasWallToTheRight)(game, currentPosition)) | ||
return false; | ||
if (exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
hasWallAbove(game, exports.horizontallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
hasWallAbove(game, (0, exports.horizontallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -483,11 +487,11 @@ } | ||
hasOpponentToTheRight(game, currentPosition)) { | ||
if (exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
!exports.hasWallToTheRight(game, exports.horizontallyIncrementPawnPosition(currentPosition)) && | ||
!isOnRightmostRow(exports.horizontallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
!(0, exports.hasWallToTheRight)(game, (0, exports.horizontallyIncrementPawnPosition)(currentPosition)) && | ||
!isOnRightmostRow((0, exports.horizontallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
} | ||
if (exports.hasWallToTheRight(game, currentPosition)) | ||
if ((0, exports.hasWallToTheRight)(game, currentPosition)) | ||
return false; | ||
if (exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
exports.hasWallBelow(game, exports.horizontallyIncrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallBelow)(game, (0, exports.horizontallyIncrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -499,3 +503,3 @@ } | ||
if (isSingleDownMove(currentPosition, move)) { | ||
if (exports.hasWallBelow(game, currentPosition)) { | ||
if ((0, exports.hasWallBelow)(game, currentPosition)) { | ||
return false; | ||
@@ -507,6 +511,6 @@ } | ||
hasOpponentBelow(game, currentPosition)) { | ||
if (exports.hasWallBelow(game, currentPosition)) | ||
if ((0, exports.hasWallBelow)(game, currentPosition)) | ||
return false; | ||
if (exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
exports.hasWallBelow(game, exports.verticallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallBelow)(game, (0, exports.verticallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -518,12 +522,12 @@ } | ||
hasOpponentBelow(game, currentPosition)) { | ||
if (exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
!exports.hasWallBelow(game, exports.verticallyDecrementPawnPosition(currentPosition)) && | ||
!isOnBottomRow(exports.verticallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
!(0, exports.hasWallBelow)(game, (0, exports.verticallyDecrementPawnPosition)(currentPosition)) && | ||
!isOnBottomRow((0, exports.verticallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
} | ||
if (exports.hasWallBelow(game, currentPosition)) | ||
if ((0, exports.hasWallBelow)(game, currentPosition)) | ||
return false; | ||
if (exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
exports.hasWallToTheRight(game, exports.verticallyDecrementPawnPosition(currentPosition)) && | ||
!isOnBottomRow(exports.verticallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallToTheRight)(game, (0, exports.verticallyDecrementPawnPosition)(currentPosition)) && | ||
!isOnBottomRow((0, exports.verticallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -535,11 +539,11 @@ } | ||
hasOpponentBelow(game, currentPosition)) { | ||
if (exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
!exports.hasWallBelow(game, exports.verticallyDecrementPawnPosition(currentPosition)) && | ||
!isOnBottomRow(exports.verticallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
!(0, exports.hasWallBelow)(game, (0, exports.verticallyDecrementPawnPosition)(currentPosition)) && | ||
!isOnBottomRow((0, exports.verticallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
} | ||
if (exports.hasWallBelow(game, currentPosition)) | ||
if ((0, exports.hasWallBelow)(game, currentPosition)) | ||
return false; | ||
if (exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
hasWallToTheLeft(game, exports.verticallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
hasWallToTheLeft(game, (0, exports.verticallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -559,4 +563,4 @@ } | ||
return false; | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
hasWallToTheLeft(game, exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
hasWallToTheLeft(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -568,5 +572,5 @@ } | ||
hasOpponentToTheLeft(game, currentPosition)) { | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
!hasWallToTheLeft(game, exports.horizontallyDecrementPawnPosition(currentPosition)) && | ||
!isOnLeftmostRow(exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
!hasWallToTheLeft(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition)) && | ||
!isOnLeftmostRow((0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -576,4 +580,4 @@ } | ||
return false; | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
exports.hasWallBelow(game, exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
(0, exports.hasWallBelow)(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -585,5 +589,5 @@ } | ||
hasOpponentToTheLeft(game, currentPosition)) { | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
!hasWallToTheLeft(game, exports.horizontallyDecrementPawnPosition(currentPosition)) && | ||
!isOnLeftmostRow(exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
!hasWallToTheLeft(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition)) && | ||
!isOnLeftmostRow((0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -593,4 +597,4 @@ } | ||
return false; | ||
if (exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
hasWallAbove(game, exports.horizontallyDecrementPawnPosition(currentPosition))) { | ||
if ((0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
hasWallAbove(game, (0, exports.horizontallyDecrementPawnPosition)(currentPosition))) { | ||
return false; | ||
@@ -606,13 +610,13 @@ } | ||
var shortestPathVerticalCoordinates = player === 1 | ||
? consts_1.verticalPiecePositions.slice(exports.getVerticalCoordinate(playerPosition) - 1) | ||
: __spreadArray([], consts_1.verticalPiecePositions).reverse() | ||
.slice(9 - exports.getVerticalCoordinate(playerPosition)); | ||
return shortestPathVerticalCoordinates.map(function (y) { return "" + exports.getHorizontalCoordinate(playerPosition) + y; }); | ||
? consts_1.verticalPiecePositions.slice((0, exports.getVerticalCoordinate)(playerPosition) - 1) | ||
: __spreadArray([], consts_1.verticalPiecePositions, true).reverse() | ||
.slice(9 - (0, exports.getVerticalCoordinate)(playerPosition)); | ||
return shortestPathVerticalCoordinates.map(function (y) { return "".concat((0, exports.getHorizontalCoordinate)(playerPosition)).concat(y); }); | ||
}; | ||
exports.getShortestPathWithNoObstacles = getShortestPathWithNoObstacles; | ||
var doesHorizontalWallBlockPlayer = function (game, player, horizontalWall) { | ||
var playerX = exports.getHorizontalCoordinate(game.playerPositions[player].position); | ||
var playerY = exports.getVerticalCoordinate(game.playerPositions[player].position); | ||
var wallX = exports.getHorizontalCoordinate(horizontalWall); | ||
var wallY = exports.getVerticalCoordinate(horizontalWall); | ||
var playerX = (0, exports.getHorizontalCoordinate)(game.playerPositions[player].position); | ||
var playerY = (0, exports.getVerticalCoordinate)(game.playerPositions[player].position); | ||
var wallX = (0, exports.getHorizontalCoordinate)(horizontalWall); | ||
var wallY = (0, exports.getVerticalCoordinate)(horizontalWall); | ||
var wallOverlapsWithPlayerColumn = playerX === wallX || | ||
@@ -643,3 +647,3 @@ (isIncrementableHorizontalWallCoordinate(wallX) && | ||
var isVerticallyIncrementablePawnPosition = function (position) { | ||
return consts_1.isVerticallyIncrementablePawnPositionMap[position]; | ||
return consts_1.verticallyIncrementablePositions.has(position); | ||
}; | ||
@@ -652,3 +656,3 @@ exports.isVerticallyIncrementablePawnPosition = isVerticallyIncrementablePawnPosition; | ||
var isVerticallyDecrementablePawnPosition = function (position) { | ||
return consts_1.isVerticallyDecrementablePawnPositionMap[position]; | ||
return consts_1.verticallyDecrementablePositions.has(position); | ||
}; | ||
@@ -661,3 +665,3 @@ exports.isVerticallyDecrementablePawnPosition = isVerticallyDecrementablePawnPosition; | ||
var isHorizontallyIncrementablePawnPosition = function (position) { | ||
return consts_1.isHorizontallyIncrementablePawnPositionMap[position]; | ||
return consts_1.horizontallyIncrementablePositions.has(position); | ||
}; | ||
@@ -670,3 +674,3 @@ exports.isHorizontallyIncrementablePawnPosition = isHorizontallyIncrementablePawnPosition; | ||
var isHorizontallyDecrementablePawnPosition = function (position) { | ||
return consts_1.isHorizontallyDecrementablePawnPositionMap[position]; | ||
return consts_1.horizontallyDecrementablePositions.has(position); | ||
}; | ||
@@ -731,22 +735,22 @@ exports.isHorizontallyDecrementablePawnPosition = isHorizontallyDecrementablePawnPosition; | ||
var getValidPawnMoveArray = function (game) { | ||
var currentPosition = game.playerPositions[getTurn_1.getTurn(game)].position; | ||
var currentPosition = game.playerPositions[(0, getTurn_1.getTurn)(game)].position; | ||
var validPawnMoveArray = [ | ||
exports.isVerticallyIncrementablePawnPosition(currentPosition) && | ||
exports.verticallyIncrementPawnPosition(currentPosition), | ||
(0, exports.isVerticallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.verticallyIncrementPawnPosition)(currentPosition), | ||
getPositionFromNorthNorthMove(currentPosition), | ||
getPositionFromNorthEastMove(currentPosition), | ||
exports.isHorizontallyIncrementablePawnPosition(currentPosition) && | ||
exports.horizontallyIncrementPawnPosition(currentPosition), | ||
(0, exports.isHorizontallyIncrementablePawnPosition)(currentPosition) && | ||
(0, exports.horizontallyIncrementPawnPosition)(currentPosition), | ||
getPositionFromEastEastMove(currentPosition), | ||
getPositionFromSouthEastMove(currentPosition), | ||
exports.isVerticallyDecrementablePawnPosition(currentPosition) && | ||
exports.verticallyDecrementPawnPosition(currentPosition), | ||
(0, exports.isVerticallyDecrementablePawnPosition)(currentPosition) && | ||
(0, exports.verticallyDecrementPawnPosition)(currentPosition), | ||
getPositionFromSouthSouthMove(currentPosition), | ||
getPositionFromSouthWestMove(currentPosition), | ||
exports.isHorizontallyDecrementablePawnPosition(currentPosition) && | ||
exports.horizontallyDecrementPawnPosition(currentPosition), | ||
(0, exports.isHorizontallyDecrementablePawnPosition)(currentPosition) && | ||
(0, exports.horizontallyDecrementPawnPosition)(currentPosition), | ||
getPositionFromWestWestMove(currentPosition), | ||
getPositionFromNorthWestMove(currentPosition), | ||
].filter(function (newPosition) { | ||
return newPosition && exports.isValidNormalMove(game, currentPosition, newPosition); | ||
return newPosition && (0, exports.isValidNormalMove)(game, currentPosition, newPosition); | ||
}); | ||
@@ -760,10 +764,10 @@ return validPawnMoveArray; | ||
return false; | ||
var x = exports.getHorizontalCoordinate(wallMove); | ||
var y = exports.getVerticalCoordinate(wallMove); | ||
if (exports.isHorizontalWallMove(wallMove)) { | ||
var x = (0, exports.getHorizontalCoordinate)(wallMove); | ||
var y = (0, exports.getVerticalCoordinate)(wallMove); | ||
if ((0, exports.isHorizontalWallMove)(wallMove)) { | ||
// A horizontal wall | ||
if (game.board[wallMove] || | ||
game.board[rotateWall(wallMove)] || | ||
(exports.isHorizontallyDecrementableWallPosition(wallMove) && | ||
game.board[exports.moveWallLeft(wallMove)]) || | ||
((0, exports.isHorizontallyDecrementableWallPosition)(wallMove) && | ||
game.board[(0, exports.moveWallLeft)(wallMove)]) || | ||
(isHorizontallyIncrementableWallPosition(wallMove) && | ||
@@ -777,4 +781,4 @@ game.board[moveWallRight(wallMove)])) { | ||
game.board[wallMove] || | ||
(exports.isVerticallyDecrementableWallPosition(wallMove) && | ||
game.board[exports.moveWallDown(wallMove)]) || | ||
((0, exports.isVerticallyDecrementableWallPosition)(wallMove) && | ||
game.board[(0, exports.moveWallDown)(wallMove)]) || | ||
(isVerticallyIncrementableWallPosition(wallMove) && | ||
@@ -790,8 +794,8 @@ game.board[moveWallUp(wallMove)])) { | ||
var newX = incrementHorizontalWallCoordinate(x); | ||
return "" + newX + wall.substring(1); | ||
return "".concat(newX).concat(wall.substring(1)); | ||
}; | ||
var moveWallLeft = function (wall) { | ||
var x = wall.charAt(0); | ||
var newX = exports.decrementHorizontalWallCoordinate(x); | ||
return "" + newX + wall.substring(1); | ||
var newX = (0, exports.decrementHorizontalWallCoordinate)(x); | ||
return "".concat(newX).concat(wall.substring(1)); | ||
}; | ||
@@ -802,12 +806,12 @@ exports.moveWallLeft = moveWallLeft; | ||
var newY = incrementVerticalWallCoordinate(y); | ||
return "" + wall.charAt(0) + newY + wall.charAt(2); | ||
return "".concat(wall.charAt(0)).concat(newY).concat(wall.charAt(2)); | ||
}; | ||
var moveWallDown = function (wall) { | ||
var y = Number(wall.charAt(1)); | ||
var newY = exports.decrementVerticalWallCoordinate(y); | ||
return "" + wall.charAt(0) + newY + wall.charAt(2); | ||
var newY = (0, exports.decrementVerticalWallCoordinate)(y); | ||
return "".concat(wall.charAt(0)).concat(newY).concat(wall.charAt(2)); | ||
}; | ||
exports.moveWallDown = moveWallDown; | ||
var rotateWall = function (wall) { | ||
return "" + wall.substring(0, 2) + (wall.charAt(2) === 'v' ? 'h' : 'v'); | ||
return "".concat(wall.substring(0, 2)).concat(wall.charAt(2) === 'v' ? 'h' : 'v'); | ||
}; | ||
@@ -823,3 +827,3 @@ var doesHorizontalWallHaveVerticalWallAboveRight = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallAboveRight) + exports.getVerticalCoordinate(verticalWallAboveRight) + exports.getWallOrientation(verticalWallAboveRight)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallAboveRight)).concat((0, exports.getVerticalCoordinate)(verticalWallAboveRight)).concat((0, exports.getWallOrientation)(verticalWallAboveRight))]; | ||
}; | ||
@@ -835,3 +839,3 @@ var doesHorizontalWallHaveVerticalWallAboveLeft = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallAboveLeft) + exports.getVerticalCoordinate(verticalWallAboveLeft) + exports.getWallOrientation(verticalWallAboveLeft)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallAboveLeft)).concat((0, exports.getVerticalCoordinate)(verticalWallAboveLeft)).concat((0, exports.getWallOrientation)(verticalWallAboveLeft))]; | ||
}; | ||
@@ -847,3 +851,3 @@ var doesHorizontalWallHaveVerticalWallBelowRight = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallBelowRight) + exports.getVerticalCoordinate(verticalWallBelowRight) + exports.getWallOrientation(verticalWallBelowRight)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallBelowRight)).concat((0, exports.getVerticalCoordinate)(verticalWallBelowRight)).concat((0, exports.getWallOrientation)(verticalWallBelowRight))]; | ||
}; | ||
@@ -859,3 +863,3 @@ var doesHorizontalWallHaveVerticalWallBelowLeft = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallBelowLeft) + exports.getVerticalCoordinate(verticalWallBelowLeft) + exports.getWallOrientation(verticalWallBelowLeft)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallBelowLeft)).concat((0, exports.getVerticalCoordinate)(verticalWallBelowLeft)).concat((0, exports.getWallOrientation)(verticalWallBelowLeft))]; | ||
}; | ||
@@ -870,3 +874,3 @@ var doesHorizontalWallHaveHorizontalWallRight = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallRight) + exports.getVerticalCoordinate(horizontalWallRight) + exports.getWallOrientation(horizontalWallRight)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallRight)).concat((0, exports.getVerticalCoordinate)(horizontalWallRight)).concat((0, exports.getWallOrientation)(horizontalWallRight))]; | ||
}; | ||
@@ -881,3 +885,3 @@ var doesHorizontalWallHaveHorizontalWallLeft = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallLeft) + exports.getVerticalCoordinate(horizontalWallLeft) + exports.getWallOrientation(horizontalWallLeft)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallLeft)).concat((0, exports.getVerticalCoordinate)(horizontalWallLeft)).concat((0, exports.getWallOrientation)(horizontalWallLeft))]; | ||
}; | ||
@@ -891,3 +895,3 @@ var doesHorizontalWallHaveVerticalWallAbove = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallAbove) + exports.getVerticalCoordinate(verticalWallAbove) + exports.getWallOrientation(verticalWallAbove)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallAbove)).concat((0, exports.getVerticalCoordinate)(verticalWallAbove)).concat((0, exports.getWallOrientation)(verticalWallAbove))]; | ||
}; | ||
@@ -901,3 +905,3 @@ var doesHorizontalWallHaveVerticalWallBelow = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallBelow) + exports.getVerticalCoordinate(verticalWallBelow) + exports.getWallOrientation(verticalWallBelow)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallBelow)).concat((0, exports.getVerticalCoordinate)(verticalWallBelow)).concat((0, exports.getWallOrientation)(verticalWallBelow))]; | ||
}; | ||
@@ -913,3 +917,3 @@ var doesVerticalWallHaveHorizontalWallAboveRight = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallAboveRight) + exports.getVerticalCoordinate(horizontalWallAboveRight) + exports.getWallOrientation(horizontalWallAboveRight)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallAboveRight)).concat((0, exports.getVerticalCoordinate)(horizontalWallAboveRight)).concat((0, exports.getWallOrientation)(horizontalWallAboveRight))]; | ||
}; | ||
@@ -925,3 +929,3 @@ var doesVerticalWallHaveHorizontalWallAboveLeft = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallAboveLeft) + exports.getVerticalCoordinate(horizontalWallAboveLeft) + exports.getWallOrientation(horizontalWallAboveLeft)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallAboveLeft)).concat((0, exports.getVerticalCoordinate)(horizontalWallAboveLeft)).concat((0, exports.getWallOrientation)(horizontalWallAboveLeft))]; | ||
}; | ||
@@ -937,3 +941,3 @@ var doesVerticalWallHaveHorizontalWallBelowRight = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallBelowRight) + exports.getVerticalCoordinate(horizontalWallBelowRight) + exports.getWallOrientation(horizontalWallBelowRight)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallBelowRight)).concat((0, exports.getVerticalCoordinate)(horizontalWallBelowRight)).concat((0, exports.getWallOrientation)(horizontalWallBelowRight))]; | ||
}; | ||
@@ -949,3 +953,3 @@ var doesVerticalWallHaveHorizontalWallBelowLeft = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallBelowLeft) + exports.getVerticalCoordinate(horizontalWallBelowLeft) + exports.getWallOrientation(horizontalWallBelowLeft)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallBelowLeft)).concat((0, exports.getVerticalCoordinate)(horizontalWallBelowLeft)).concat((0, exports.getWallOrientation)(horizontalWallBelowLeft))]; | ||
}; | ||
@@ -960,3 +964,3 @@ var doesVerticalWallHaveVerticalWallAbove = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallAbove) + exports.getVerticalCoordinate(verticalWallAbove) + exports.getWallOrientation(verticalWallAbove)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallAbove)).concat((0, exports.getVerticalCoordinate)(verticalWallAbove)).concat((0, exports.getWallOrientation)(verticalWallAbove))]; | ||
}; | ||
@@ -971,3 +975,3 @@ var doesVerticalWallHaveVerticalWallBelow = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(verticalWallBelow) + exports.getVerticalCoordinate(verticalWallBelow) + exports.getWallOrientation(verticalWallBelow)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(verticalWallBelow)).concat((0, exports.getVerticalCoordinate)(verticalWallBelow)).concat((0, exports.getWallOrientation)(verticalWallBelow))]; | ||
}; | ||
@@ -981,3 +985,3 @@ var doesVerticalWallHaveHorizontalWallAbove = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallAbove) + exports.getVerticalCoordinate(horizontalWallAbove) + exports.getWallOrientation(horizontalWallAbove)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallAbove)).concat((0, exports.getVerticalCoordinate)(horizontalWallAbove)).concat((0, exports.getWallOrientation)(horizontalWallAbove))]; | ||
}; | ||
@@ -991,18 +995,18 @@ var doesVerticalWallHaveHorizontalWallBelow = function (game, wallMove) { | ||
return false; | ||
return game.board["" + exports.getHorizontalCoordinate(horizontalWallBelow) + exports.getVerticalCoordinate(horizontalWallBelow) + exports.getWallOrientation(horizontalWallBelow)]; | ||
return game.board["".concat((0, exports.getHorizontalCoordinate)(horizontalWallBelow)).concat((0, exports.getVerticalCoordinate)(horizontalWallBelow)).concat((0, exports.getWallOrientation)(horizontalWallBelow))]; | ||
}; | ||
var doesHorizontalWallHaveBoardEdgeRight = function (wallMove) { | ||
return exports.getHorizontalCoordinate(wallMove) === 'h'; | ||
return (0, exports.getHorizontalCoordinate)(wallMove) === 'h'; | ||
}; | ||
var doesHorizontalWallHaveBoardEdgeLeft = function (wallMove) { | ||
return exports.getHorizontalCoordinate(wallMove) === 'a'; | ||
return (0, exports.getHorizontalCoordinate)(wallMove) === 'a'; | ||
}; | ||
var doesVerticalWallHaveBoardEdgeAbove = function (wallMove) { | ||
return exports.getVerticalCoordinate(wallMove) === 8; | ||
return (0, exports.getVerticalCoordinate)(wallMove) === 8; | ||
}; | ||
var doesVerticalWallHaveBoardEdgeBelow = function (wallMove) { | ||
return exports.getVerticalCoordinate(wallMove) === 1; | ||
return (0, exports.getVerticalCoordinate)(wallMove) === 1; | ||
}; | ||
var getNumberOfNeighborWalls = function (game, wallMove) { | ||
if (exports.isHorizontalWallMove(wallMove)) { | ||
if ((0, exports.isHorizontalWallMove)(wallMove)) { | ||
return [ | ||
@@ -1037,7 +1041,7 @@ doesHorizontalWallHaveVerticalWallAboveRight(game, wallMove), | ||
var isWallAdjacentToPosition = function (wall, pawn) { | ||
var wallX = exports.getHorizontalCoordinate(wall); | ||
var wallY = exports.getVerticalCoordinate(wall); | ||
var wallOrientation = exports.getWallOrientation(wall); | ||
var pawnX = exports.getHorizontalCoordinate(pawn); | ||
var pawnY = exports.getVerticalCoordinate(pawn); | ||
var wallX = (0, exports.getHorizontalCoordinate)(wall); | ||
var wallY = (0, exports.getVerticalCoordinate)(wall); | ||
var wallOrientation = (0, exports.getWallOrientation)(wall); | ||
var pawnX = (0, exports.getHorizontalCoordinate)(pawn); | ||
var pawnY = (0, exports.getVerticalCoordinate)(pawn); | ||
// –– | ||
@@ -1212,3 +1216,3 @@ // x | ||
var pastWallMoves = game.pastMoves.filter(exports.isWallPosition); | ||
var orientation = exports.getWallOrientation(wallMove); | ||
var orientation = (0, exports.getWallOrientation)(wallMove); | ||
return orientation === 'h' | ||
@@ -1244,10 +1248,10 @@ ? pastWallMoves.every(exports.isHorizontalWallMove) | ||
var isHorizontallyDecrementableWallPosition = function (wallPosition) { | ||
return consts_1.horizontallyDecrementableWallPositions.includes(wallPosition); | ||
return consts_1.horizontallyDecrementablePositions.has(wallPosition); | ||
}; | ||
exports.isHorizontallyDecrementableWallPosition = isHorizontallyDecrementableWallPosition; | ||
var isVerticallyIncrementableWallPosition = function (wallPosition) { | ||
return consts_1.verticallyIncrementableWallPositions.includes(wallPosition); | ||
return consts_1.verticallyIncrementablePositions.has(wallPosition); | ||
}; | ||
var isVerticallyDecrementableWallPosition = function (wallPosition) { | ||
return consts_1.verticallyDecrementableWallPositions.includes(wallPosition); | ||
return consts_1.verticallyDecrementablePositions.has(wallPosition); | ||
}; | ||
@@ -1269,6 +1273,6 @@ exports.isVerticallyDecrementableWallPosition = isVerticallyDecrementableWallPosition; | ||
var overlapsPath = function (path, wallMove) { | ||
var wallMoveX = exports.getHorizontalCoordinate(wallMove); | ||
var wallMoveY = exports.getVerticalCoordinate(wallMove); | ||
var wallMoveX = (0, exports.getHorizontalCoordinate)(wallMove); | ||
var wallMoveY = (0, exports.getVerticalCoordinate)(wallMove); | ||
// If is horizontal wall | ||
if (exports.isHorizontalWallMove(wallMove)) { | ||
if ((0, exports.isHorizontalWallMove)(wallMove)) { | ||
return path.some(function (currentPosition, index) { | ||
@@ -1278,4 +1282,4 @@ var previousPosition = path[index - 1]; | ||
return false; | ||
var currentPositionX = exports.getHorizontalCoordinate(currentPosition); | ||
var currentPositionY = exports.getVerticalCoordinate(currentPosition); | ||
var currentPositionX = (0, exports.getHorizontalCoordinate)(currentPosition); | ||
var currentPositionY = (0, exports.getVerticalCoordinate)(currentPosition); | ||
// If there is a path position where the position is above the wall and the previous position is below the wall | ||
@@ -1309,4 +1313,4 @@ if (isSingleUpMove(previousPosition, currentPosition) && | ||
return false; | ||
var currentPositionX = exports.getHorizontalCoordinate(currentPosition); | ||
var currentPositionY = exports.getVerticalCoordinate(currentPosition); | ||
var currentPositionX = (0, exports.getHorizontalCoordinate)(currentPosition); | ||
var currentPositionY = (0, exports.getVerticalCoordinate)(currentPosition); | ||
// If there is a path position where the position is right of the wall and the previous position is left of the wall | ||
@@ -1333,7 +1337,7 @@ if (isSingleRightMove(previousPosition, currentPosition) && | ||
var getValidWallMoveArray = function (game) { | ||
if (game.playerWallCounts[getTurn_1.getTurn(game)] < 1) { | ||
if (game.playerWallCounts[(0, getTurn_1.getTurn)(game)] < 1) { | ||
return []; | ||
} | ||
var thisTurn = getTurn_1.getTurn(game); | ||
var thatTurn = exports.getOppositePlayer(getTurn_1.getTurn(game)); | ||
var thisTurn = (0, getTurn_1.getTurn)(game); | ||
var thatTurn = (0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game)); | ||
var numberOfPlacedWalls = getNumberOfPlacedWalls(game); | ||
@@ -1346,4 +1350,4 @@ if (numberOfPlacedWalls <= 2) { | ||
} | ||
var thisPlayersShortestPath = getShortestPath_1.getShortestPath(game, thisTurn); | ||
var thatPlayersShortestPath = getShortestPath_1.getShortestPath(game, thatTurn); | ||
var thisPlayersShortestPath = (0, getShortestPath_1.getShortestPath)(game, thisTurn); | ||
var thatPlayersShortestPath = (0, getShortestPath_1.getShortestPath)(game, thatTurn); | ||
if (thisPlayersShortestPath === null || thatPlayersShortestPath === null) { | ||
@@ -1355,4 +1359,4 @@ return []; | ||
return false; | ||
if (!exports.overlapsPath(thisPlayersShortestPath, wallMove) && | ||
!exports.overlapsPath(thatPlayersShortestPath, wallMove)) { | ||
if (!(0, exports.overlapsPath)(thisPlayersShortestPath, wallMove) && | ||
!(0, exports.overlapsPath)(thatPlayersShortestPath, wallMove)) { | ||
return true; | ||
@@ -1363,10 +1367,10 @@ } | ||
} | ||
if (exports.getNumberOfNeighborWalls(game, wallMove) < 2) { | ||
if ((0, exports.getNumberOfNeighborWalls)(game, wallMove) < 2) { | ||
return true; | ||
} | ||
var gameWithUnvalidatedMove = makeUnvalidatedMove_1.makeUnvalidatedMove(game, wallMove); | ||
var thisTurnAfterMove = getTurn_1.getTurn(game); | ||
var thatTurnAfterMove = exports.getOppositePlayer(getTurn_1.getTurn(game)); | ||
var thisShortestPath = getShortestPath_1.getShortestPath(gameWithUnvalidatedMove, thisTurnAfterMove); | ||
var thatShortestPath = getShortestPath_1.getShortestPath(gameWithUnvalidatedMove, thatTurnAfterMove); | ||
var gameWithUnvalidatedMove = (0, makeUnvalidatedMove_1.makeUnvalidatedMove)(game, wallMove); | ||
var thisTurnAfterMove = (0, getTurn_1.getTurn)(game); | ||
var thatTurnAfterMove = (0, exports.getOppositePlayer)((0, getTurn_1.getTurn)(game)); | ||
var thisShortestPath = (0, getShortestPath_1.getShortestPath)(gameWithUnvalidatedMove, thisTurnAfterMove); | ||
var thatShortestPath = (0, getShortestPath_1.getShortestPath)(gameWithUnvalidatedMove, thatTurnAfterMove); | ||
return Boolean(thisShortestPath && thatShortestPath); | ||
@@ -1373,0 +1377,0 @@ }); |
{ | ||
"name": "quoridor", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "A JavaScipt Quoridor library for move validation etc.", | ||
@@ -41,3 +41,3 @@ "main": "lib/index.js", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.0.3" | ||
"typescript": "^4.7.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
205211
5455