
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@brajkowski/connect4-logic
Advanced tools
This library provides APIs for manipulating and querying a standard (7x6) game of connect 4.
This library provides APIs for manipulating and querying a standard (7x6) game of connect 4.
Using npm:
$ npm i --save @brajkowski/connect4-logic
The main class that should be used to manipulate and query the underlying game state is Logic
.
To begin, instantiate an implementation of Logic
(currently BitboardLogic
is the only implementation):
const logic: Logic = new BitboardLogic();
From there, you may perform queries on the game state such as:
let column = 0;
let result: boolean = logic.canPlaceChip(column);
and place chips that belong to a player:
let landedOnRow = logic.placeChip(Player.One, column); // returns 0.
landedOnRow = logic.placeChip(Player.Two, column); // returns 1.
These operations prevent placing chips in non-existent columns (ie: out-of-bounds columns) as well as overflowing a column (ie: a column can only hold 6 chips).
A basic game loop may look like:
const logic: Logic = new BitboardLogic();
let activePlayer: Player = Player.One;
function gameLoop() {
while (true) {
let column = promptActivePlayerForMove();
if (!logic.canPlaceChip(column)) {
continue;
}
logic.placeChip(activePlayer, column);
if (logic.didWin(activePlayer)) {
break;
}
swapActivePlayer();
}
}
The Logic
class provides default connect 4 behavior (ie: chips fall to the bottom of a column and stack), but custom behavior can also be achieved by using the PlayerState
class:
let row = 2;
let column = 3;
logic.getPlayerState(Player.One).occupyPosition(row, column);
The PlayerState
operations allow for any chip placement, but are bounds-checked for valid row and column values and prevent duplicate chip placement (ie: trying to place another chip in a position that is already occupied).
Using npm:
$ npm run build
will produce the compiled library under /dist
.
The test suite may also be executed with npm:
$ npm test
FAQs
This library provides APIs for manipulating and querying a standard (7x6) game of connect 4.
The npm package @brajkowski/connect4-logic receives a total of 0 weekly downloads. As such, @brajkowski/connect4-logic popularity was classified as not popular.
We found that @brajkowski/connect4-logic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.