Skip to content
Merged

Node #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a38a218
Shoginet ts rewrite
WandererXII Oct 11, 2025
86fa44f
Same values in local config
WandererXII Oct 11, 2025
3a96b42
Copy default config on preinstall
WandererXII Oct 11, 2025
2aaf55d
Update readme
WandererXII Dec 7, 2025
321fa18
tsconfig - satisfy tsgo
WandererXII Dec 7, 2025
9735441
Add funding.yml
WandererXII Dec 7, 2025
a04e392
Fix build-engines script
WandererXII Dec 7, 2025
09633e0
Add workflow and remove format script
WandererXII Dec 7, 2025
fbf1aa6
Move systemd to scripts
WandererXII Dec 7, 2025
d05b89f
Prefix node fs
WandererXII Dec 7, 2025
cfecad9
Use user npm and node
WandererXII Dec 8, 2025
a506f67
Prevent local overriding test config
WandererXII Dec 8, 2025
66c553d
Decrease MAX_WORKERS
WandererXII Dec 8, 2025
45d8166
Minor tweaks
WandererXII Dec 8, 2025
41414db
Point default to lishogi
WandererXII Dec 8, 2025
b163b7f
Properly shutdown engines in test
WandererXII Dec 9, 2025
5ef75c8
Less logging
WandererXII Dec 14, 2025
aab3f2e
Rename flavor to engine
WandererXII Dec 14, 2025
6b3d617
Remove values we don't anymore need from json sent to server
WandererXII Dec 14, 2025
52175a0
Release worker on failure
WandererXII Dec 14, 2025
9585fed
Stop engine processes properly on test exit
WandererXII Dec 14, 2025
baf439d
Stop workers on available event
WandererXII Dec 14, 2025
591e303
Rewrite puzzle to generate solution and themes
WandererXII Dec 14, 2025
1f7cf24
More tests
WandererXII Dec 14, 2025
c5d1477
Fix tests
WandererXII Dec 14, 2025
d4e269a
Remove console logs
WandererXII Dec 14, 2025
b8443f1
Better shutdown
WandererXII Dec 14, 2025
ce1a4cd
Add lishogi.org badge
WandererXII Dec 15, 2025
2975b0b
Store copy of server config locally, so that shoginet can start when …
WandererXII Dec 22, 2025
cde4024
Update readme
WandererXII Dec 30, 2025
935e115
Fix check if we have puzzle
WandererXII Dec 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://lishogi.org/patron
11 changes: 11 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm run type-check
- run: npm run check
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.vscode/
*.ini
YaneuraOu/
Fairy-Stockfish/
__pycache__/
/YaneuraOu-by-gcc*
/fairy-stockfish-largeboard*
.vscode
node_modules
config/local.json
119 changes: 76 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,76 @@
# Shoginet - Distributed Network for [lishogi.org](lishogi.org)

Based on [fairyfishnet](https://github.com/gbtami/fairyfishnet).

## How to setup

### Linux

You need to have both engines:

- YaneuraOu NNUE
- Fairy-Stockfish

To achieve this you can use the provided scripts - `build-yaneuraou.sh` for YaneuraOu and `build-fairy.sh` to build Fairy-Stockfish.
The scripts first clone [YaneuraOu github](https://github.com/yaneurao/YaneuraOu) or [Fairy-Stockfish](https://github.com/fairy-stockfish/Fairy-Stockfish) and then run the `make`.

You can also try downloading YaneuraOu from https://github.com/yaneurao/YaneuraOu/actions using GitHub Actions artifacts.

You can also download Fairy-Stockfish from [https://fairy-stockfish.github.io/download/](https://fairy-stockfish.github.io/download/), make sure to pick 'all-variants'

To test that the engines work on you machine just run the engine `./YaneuraOu-by-gcc`(adjust command if necessary). and then enter the following commands:

```
usi
isready
position sfen lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1 moves 7g7f
go
```

If the engine didn't crash and you got some response, it looks like ti works. Yeah! Now test `./fairy-stockfish-largeboard_x86-64` in the same way.

If you have YaneuraOu and Fairy-Stockfish ready and python3 installed just run `python3 ./shoginet.py`, it will ask you about what working directory you want to use, path to the engine and similar things, leaving everything default should be fine.

Currently no key is required.
If you want to go over this setup step again, just delete shoginet.ini.

### Windows

Windows is not supported right now. Although almost everything should be fine. You will obviously have to compile YaneuraOu for windows and provide the correct path, when shoginet.py asks you the first time.

## How it works

Every once in a while shoginet running on your computer asks lishogi.org for some work. If someone requested analysis of their game on lishogi.org, you may receive this work. The work is a simple json containing mainly the initial position and sequence of moves. You then run engine analysis on these data and send the results back to lishogi.org.
# Shoginet

[![lishogi.org](https://img.shields.io/badge/☗_lishogi.org-Play_shogi-black)](https://lishogi.org)

**Distributed network for [Lishogi.org](https://lishogi.org)**

## Installation

```console
git clone https://github.com/WandererXII/shoginet.git
cd shoginet
npm install
```

**Note:** You must obtain and install engines **before** running Shoginet:

* **Linux - from source:** Use `./scripts/yaneuraou.sh` and `./scripts/fairy.sh` to download and build engines yourself. Make sure you have a C/C++ compiler and build tools installed. It will take a few minutes per engine.
* **Ready to use binary:** Make sure to download the correct version for your OS and CPU.
- YaneuraOu - [YaneuraOu repo releases](https://github.com/yaneurao/YaneuraOu/releases)
- Fairy Stockfish - [Fairy Stockfish website](https://fairy-stockfish.github.io/download/), download largeboard (all variants) version

Do not forget to check if path to engines is correct set (next step)

## Configuration

Configuration is stored in `config` directory. Write your own overrides to `local.json`.

Most importantly you want to make sure that engine path is correctly set. By default we look into `engines` directory. _Yaneuraou_ engine default name is `YaneuraOu-by-gcc` and _Fairy Stockfish_ default name is `fairy-stockfish`

## Usage

**Run tests first** to make sure everything works, especially the engines:

```console
npm run test
```

If tests pass successfully, you can start Shoginet directly by running:

```console
npm run start
```

You will probably want to run Shoginet with a process manager. For systemd (Linux) integration:

```console
node ./scripts/systemd.js | sudo tee /etc/systemd/system/shoginet.service > /dev/null
sudo systemctl daemon-reload
sudo systemctl start shoginet
```

## Shoginet workflow

1. **Start!**
- Shoginet is initiated and fetches config from the server. The config sets parameters for move generation, analysis and puzzle verification.

2. **Request work**
- Shoginet -> Lishogi: "Give me work!"

3. **Receive work**
- Lishogi -> Shoginet: "Here's a game to analyse"
- The work could be _analysis_, _move generation_ or _puzle verification_. Or nothing, if the queue is empty.

4. **Process work**
- Shoginet is analyzing the game...
- This consumes CPU

5. **Submit Results**
- Shoginet -> Lishogi: "Here are the analysis result"

6. **Repeat**
- Lishogi -> Shoginet: "Thanks, here's more work :)"
- Rinse & repeat

7. **Stop**
- Stop Shoginet when you need CPU power. Shoginet will try to finish the work in progress and only then exit, if you wish to abort immediately press CTRL^C again.
41 changes: 41 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
"files": {
"includes": ["**/src/**/*.ts", "**/test/**/*.ts"]
},
"formatter": {
"enabled": true,
"lineWidth": 80,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noPrototypeBuiltins": "off",
"noUnsafeDeclarationMerging": "off"
},
"complexity": {
"useOptionalChain": "off"
},
"correctness": {},
"performance": {}
}
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
Loading