1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00
Stockfish modified to play the worst move
Find a file
Linmiao Xu 5d81071953 Update default main net to nn-1111cefa1111.nnue
Created from 2 distinct spsa tunes of the latest main net (nn-31337bea577c.nnue)
and applying the params to the prior main net (nn-e8bac1c07a5a.nnue). This
effectively reverts the modifications to output weights and biases in
https://github.com/official-stockfish/Stockfish/pull/5509

SPSA:
A: 6000, alpha: 0.602, gamma: 0.101

1st - 437 feature transformer biases where values are < 25
54k / 120k games at 180+1.8
https://tests.stockfishchess.org/tests/view/66af98ac4ff211be9d4edad0
nn-808259761cca.nnue

2nd - 208 L2 weights where values are zero
112k / 120k games at 180+1.8
https://tests.stockfishchess.org/tests/view/66b0c3074ff211be9d4edbe5
nn-a56cb8c3d477.nnue

When creating the above 2 nets (nn-808259761cca.nnue, nn-a56cb8c3d477.nnue),
spsa params were unintentionally applied to nn-e8bac1c07a5a.nnue rather
than nn-31337bea577c.nnue due to an issue in a script that creates nets
by applying spsa results to base nets.

Since they both passed STC and were neutral or slightly positive at LTC,
they were combined to see if the elo from each set of params was additive.

The 2 nets can be merged on top of nn-e8bac1c07a5a.nnue with:
https://github.com/linrock/nnue-tools/blob/90942d3/spsa/combine_nnue.py
```
python3 combine_nnue.py \
  nn-e8bac1c07a5a.nnue \
  nn-808259761cca.nnue \
  nn-a56cb8c3d477.nnue
```

Merging yields nn-87caa003fc6a.nnue which was renamed to nn-1111cefa1111.nnue
with an updated nnue-namer around 10x faster than before by:
- using a prefix trie for efficient prefix matches
- modifying 4 non-functional bytes near the end of the file instead of 2
https://github.com/linrock/nnue-namer

Thanks to @MinetaS for pointing out in #nnue-dev what the non-functional bytes are:
  L3 is 32, 4 bytes for biases, 32 bytes for weights. (fc_2)
  So -38 and -37 are technically -2 and -1 of fc_1 (type AffineTransform<30, 32>)
  And since InputDimension is padded to 32 there are total 32 of 2 adjacent bytes padding.
  So yes, it's non-functional whatever values are there.
  It's possible to tweak bytes at -38 - 32 * N and -37 - 32 * N given N = 0 ... 31

The net renamed with the new method passed non-regression STC vs. the original net:
https://tests.stockfishchess.org/tests/view/66c0f0a821503a509c13b332

To print the spsa params with nnue-pytorch:
```
import features
from serialize import NNUEReader

feature_set = features.get_feature_set_from_name("HalfKAv2_hm")

with open("nn-31337bea577c.nnue", "rb") as f:
    model = NNUEReader(f, feature_set).model

c_end = 16
for i,ft_bias in enumerate(model.input.bias.data[:3072]):
    value = int(ft_bias * 254)
    if abs(value) < 25:
        print(f"ftB[{i}],{value},-1024,1024,{c_end},0.0020")

c_end = 6
for i in range(8):
    for j in range(32):
        for k in range(30):
            value = int(model.layer_stacks.l2.weight.data[32 * i + j, k] * 64)
            if value == 0:
                print(f"twoW[{i}][{j}][{k}],{value},-127,127,{c_end},0.0020")
```

New params found with the same method as:
https://github.com/official-stockfish/Stockfish/pull/5459

Passed STC:
https://tests.stockfishchess.org/tests/view/66b4d4464ff211be9d4edf6e
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 136416 W: 35753 L: 35283 D: 65380
Ptnml(0-2): 510, 16159, 34416, 16597, 526

Passed LTC:
https://tests.stockfishchess.org/tests/view/66b76e814ff211be9d4ee1cc
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 159336 W: 40753 L: 40178 D: 78405
Ptnml(0-2): 126, 17497, 43864, 18038, 143

closes https://github.com/official-stockfish/Stockfish/pull/5534

bench 1613043
2024-08-20 20:59:36 +02:00
.github Fix failing CI for MacOS 13 GCC 11 2024-08-20 20:44:55 +02:00
scripts Fix dotprod detection 2024-01-17 18:32:20 +01:00
src Update default main net to nn-1111cefa1111.nnue 2024-08-20 20:59:36 +02:00
tests Limit depth after extensions to avoid asserts. 2024-06-15 12:02:56 +02:00
.clang-format add clang-format 2023-10-22 16:06:27 +02:00
.git-blame-ignore-revs Add .git-blame-ignore-revs 2024-01-07 13:38:55 +01:00
.gitignore Add .gitignore 2021-01-30 13:19:20 +01:00
AUTHORS Fixed non UCI compliance 2024-07-15 13:14:57 +02:00
CITATION.cff Add CITATION.cff file 2023-03-05 16:16:16 +01:00
CONTRIBUTING.md Update clang-format to version 18 2024-06-05 21:41:43 +02:00
Copying.txt Update links in license 2023-10-08 07:38:13 +02:00
README.md Simplify README 2023-09-03 08:40:08 +02:00
Top CPU Contributors.txt Update Top CPU Contributors 2024-02-24 17:58:44 +01:00

Stockfish

Stockfish

A free and strong UCI chess engine.
Explore Stockfish docs »

Report bug · Open a discussion · Discord · Blog

Build License
Release Commits
Website Fishtest Discord

Overview

Stockfish is a free and strong UCI chess engine derived from Glaurung 2.1 that analyzes chess positions and computes the optimal moves.

Stockfish does not include a graphical user interface (GUI) that is required to display a chessboard and to make it easy to input moves. These GUIs are developed independently from Stockfish and are available online. Read the documentation for your GUI of choice for information about how to use Stockfish with it.

See also the Stockfish documentation for further usage help.

Files

This distribution of Stockfish consists of the following files:

  • README.md, the file you are currently reading.

  • Copying.txt, a text file containing the GNU General Public License version 3.

  • AUTHORS, a text file with the list of authors for the project.

  • src, a subdirectory containing the full source code, including a Makefile that can be used to compile Stockfish on Unix-like systems.

  • a file with the .nnue extension, storing the neural network for the NNUE evaluation. Binary distributions will have this file embedded.

Contributing

See Contributing Guide.

Donating hardware

Improving Stockfish requires a massive amount of testing. You can donate your hardware resources by installing the Fishtest Worker and viewing the current tests on Fishtest.

Improving the code

In the chessprogramming wiki, many techniques used in Stockfish are explained with a lot of background information. The section on Stockfish describes many features and techniques used by Stockfish. However, it is generic rather than focused on Stockfish's precise implementation.

The engine testing is done on Fishtest. If you want to help improve Stockfish, please read this guideline first, where the basics of Stockfish development are explained.

Discussions about Stockfish take place these days mainly in the Stockfish Discord server. This is also the best place to ask questions about the codebase and how to improve it.

Compiling Stockfish

Stockfish has support for 32 or 64-bit CPUs, certain hardware instructions, big-endian machines such as Power PC, and other platforms.

On Unix-like systems, it should be easy to compile Stockfish directly from the source code with the included Makefile in the folder src. In general, it is recommended to run make help to see a list of make targets with corresponding descriptions. An example suitable for most Intel and AMD chips:

cd src
make -j profile-build ARCH=x86-64-avx2

Detailed compilation instructions for all platforms can be found in our documentation. Our wiki also has information about the UCI commands supported by Stockfish.

Terms of use

Stockfish is free and distributed under the GNU General Public License version 3 (GPL v3). Essentially, this means you are free to do almost exactly what you want with the program, including distributing it among your friends, making it available for download from your website, selling it (either by itself or as part of some bigger software package), or using it as the starting point for a software project of your own.

The only real limitation is that whenever you distribute Stockfish in some way, you MUST always include the license and the full source code (or a pointer to where the source code can be found) to generate the exact binary you are distributing. If you make any changes to the source code, these changes must also be made available under GPL v3.