Simulator and utility functions for the card game binmat from the video game
hackmud.
If you need any help, you can DM or @samualn in the hackmud discord server or
open an issue.
Supports Node.js 18, 20, and above.
- Install Node.js and Git, make a new folder, and open a command window in that folder
- Run
npx tiged samualtnorman/binmat/examples/test-binmat-brain - Run
npm install - Edit
index.jsimport { simulateGame, Role } from "binmat" // the first argument is the defender's brain // and the second is the attacker's brain // in this case we are using the same brain for both const winner = simulateGame(brain, brain, { timeLimit: 5000, // in milliseconds // console.log() prints its arguments, here we are printing the binlog onMove: (state, binlog) => console.log(binlog.join("\n")) }) if (winner == Role.Defender) console.log("The defender won!") else console.log("The attacker won!") /** @type {import("binmat/simulateGame").BrainScript} */ function brain(context, args, xform) { // you should fill this function with your brain code // xform() is the equivalent of #fs.binmat.x() xform({ op: "--" }) }
- Run
node index.js
Follow this first.
- Install Node.js, PNPM, and Git
- Clone this repository
- Open a command prompt
cd'd into the cloned repository folder - Run
pnpm install
If you are on Windows, you will need to run the following commands inside Git Bash (or any other Unix compatible shell).
Run scripts/package.sh. The dist folder is what gets published to NPM.
Make sure you have built the package first by following the instructions above.
You can run pnpm hsm push game-scripts and the scripts will be pushed straight to your users'
scripts folders. Or you can run pnpm hsm golf game-scripts/binmat.ts and pnpm hsm golf game-scripts/binmat_lib.ts,
this will generate hackmud script files next to those source files.
Run scripts/test.sh.