Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quoridor

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quoridor - npm Package Compare versions

Comparing version 1.7.2 to 1.7.3

1

lib/consts.d.ts

@@ -14,1 +14,2 @@ import { PawnPosition } from './types';

export declare const verticallyDecrementableWallPositions: string[];
export declare const verticalPiecePositions: number[];

3

lib/consts.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.verticallyDecrementableWallPositions = exports.verticallyIncrementableWallPositions = exports.horizontallyDecrementableWallPositions = exports.horizontallyIncrementableWallPositions = exports.possiblyTrappedPositions = void 0;
exports.verticalPiecePositions = exports.verticallyDecrementableWallPositions = exports.verticallyIncrementableWallPositions = exports.horizontallyDecrementableWallPositions = exports.horizontallyIncrementableWallPositions = exports.possiblyTrappedPositions = void 0;
/**

@@ -542,1 +542,2 @@ * These are the only piece positions where a player risks not having a path to the goal if a specific number of walls are placed

];
exports.verticalPiecePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9];

@@ -187,7 +187,7 @@ "use strict";

};
var isHorizontalWallMove = function (wallMove) {
return wallMove.charAt(2) === 'h';
var isHorizontalWallMove = function (move) {
return move.charAt(2) === 'h';
};
var isVerticalWallMove = function (wallMove) {
return wallMove.charAt(2) === 'v';
var isVerticalWallMove = function (move) {
return move.charAt(2) === 'v';
};

@@ -761,4 +761,36 @@ var doesWallMoveOverlapExistingWall = function (game, wallMove) {

exports.isValidNormalMove = isValidNormalMove;
var getShortestPathWithNoObstacles = function (game, player) {
var playerPosition = game.playerPositions[player];
var shortestPathVerticalCoordinates = player === 1
? consts_1.verticalPiecePositions.slice(playerPosition.y)
: consts_1.verticalPiecePositions.slice(0, -playerPosition.y);
return shortestPathVerticalCoordinates.map(function (y) { return ({
x: playerPosition.x,
y: y,
}); });
};
var doesHorizontalWallBlockPlayer = function (game, player, horizontalWall) {
var _a = game.playerPositions[player], playerX = _a.x, playerY = _a.y;
var wallX = exports.getHorizontalCoordinate(horizontalWall);
var wallY = exports.getVerticalCoordinate(horizontalWall);
var wallOverlapsWithPlayerColumn = playerX === wallX ||
(isIncrementableHorizontalWallPosition(wallX) &&
playerX === incrementHorizontalWallPosition(wallX));
if (!wallOverlapsWithPlayerColumn)
return false;
if (player === 1) {
return wallY >= playerY;
}
return wallY < playerY;
};
var shortestPath = function (game, player) {
return aStar_1.aStar(game.pieceMatrix, game.wallMatrix, player);
var placedHorizontalWalls = game.pastMoves.filter(isHorizontalWallMove);
if (placedHorizontalWalls.some(function (wall) {
return doesHorizontalWallBlockPlayer(game, player, wall);
})) {
return aStar_1.aStar(game.pieceMatrix, game.wallMatrix, player);
}
// The shortest path has no obstacles if no horizontal walls have been placed
// between the player and the goal
return getShortestPathWithNoObstacles(game, player);
};

@@ -765,0 +797,0 @@ exports.shortestPath = shortestPath;

{
"name": "quoridor",
"version": "1.7.2",
"version": "1.7.3",
"description": "A JavaScipt Quoridor library for move validation etc.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc