https://github.com/samualtnorman/binmat
binmat simulator for game hackmud
https://github.com/samualtnorman/binmat
binmat hackmud javascript nodejs
Last synced: 9 months ago
JSON representation
binmat simulator for game hackmud
- Host: GitHub
- URL: https://github.com/samualtnorman/binmat
- Owner: samualtnorman
- License: mit
- Created: 2021-02-20T20:48:19.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T08:59:43.000Z (12 months ago)
- Last Synced: 2025-05-02T23:48:00.184Z (10 months ago)
- Topics: binmat, hackmud, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 1010 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Binmat
Simulator and utility functions for the card game [binmat](https://github.com/DrizzlyBear/binmat_rules) from the video game
[hackmud](https://hackmud.com/).
If you need any help, you can DM or `@samualn` in the [hackmud discord server](https://discord.gg/gxpEdwU8CC) or
[open an issue](https://github.com/samualtnorman/binmat/issues/new).
Supports Node.js 18, 20, and above.
## Using Binmat Simulator To Test Your Binmat Bot
0. Install [Node.js](https://nodejs.org/en/) and [Git](https://git-scm.com/downloads), make a new folder, and open a
command window in that folder
1. Run `npx tiged samualtnorman/binmat/examples/test-binmat-brain`
1. Run `npm install`
1. Edit `index.js`
```js
import { 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: "--" })
}
```
1. Run `node index.js`
## Building Yourself
### Setup
Follow this first.
1. Install [Node.js](https://nodejs.org/en/), [PNPM](https://pnpm.io/installation), and
[Git](https://git-scm.com/downloads)
2. [Clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) this
[repository](https://github.com/samualtnorman/binmat)
3. Open a command prompt `cd`'d into the cloned repository folder
4. 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).
### Building the package
Run `scripts/package.sh`. The `dist` folder is what gets published to [NPM](https://www.npmjs.com/package/binmat).
### Compiling the hackmud Scripts
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.
## Running the Tests
Run `scripts/test.sh`.