Full Code of official-stockfish/Stockfish for AI

master d173a0655d04 cached
100 files
1017.5 KB
278.3k tokens
511 symbols
1 requests
Download .txt
Showing preview only (1,057K chars total). Download the full file or copy to clipboard to get everything.
Repository: official-stockfish/Stockfish
Branch: master
Commit: d173a0655d04
Files: 100
Total size: 1017.5 KB

Directory structure:
gitextract_iuycd67k/

├── .clang-format
├── .git-blame-ignore-revs
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── BUG-REPORT.yml
│   │   └── config.yml
│   ├── ci/
│   │   ├── arm_matrix.json
│   │   ├── libcxx17.imp
│   │   └── matrix.json
│   └── workflows/
│       ├── arm_compilation.yml
│       ├── avx2_compilers.yml
│       ├── clang-format.yml
│       ├── codeql.yml
│       ├── compilation.yml
│       ├── games.yml
│       ├── iwyu.yml
│       ├── matetrack.yml
│       ├── sanitizers.yml
│       ├── stockfish.yml
│       ├── tests.yml
│       └── upload_binaries.yml
├── .gitignore
├── AUTHORS
├── CITATION.cff
├── CONTRIBUTING.md
├── Copying.txt
├── README.md
├── Top CPU Contributors.txt
├── scripts/
│   ├── .gitattributes
│   ├── get_native_properties.sh
│   └── net.sh
├── src/
│   ├── Makefile
│   ├── benchmark.cpp
│   ├── benchmark.h
│   ├── bitboard.cpp
│   ├── bitboard.h
│   ├── engine.cpp
│   ├── engine.h
│   ├── evaluate.cpp
│   ├── evaluate.h
│   ├── history.h
│   ├── incbin/
│   │   ├── UNLICENCE
│   │   └── incbin.h
│   ├── main.cpp
│   ├── memory.cpp
│   ├── memory.h
│   ├── misc.cpp
│   ├── misc.h
│   ├── movegen.cpp
│   ├── movegen.h
│   ├── movepick.cpp
│   ├── movepick.h
│   ├── nnue/
│   │   ├── features/
│   │   │   ├── full_threats.cpp
│   │   │   ├── full_threats.h
│   │   │   ├── half_ka_v2_hm.cpp
│   │   │   └── half_ka_v2_hm.h
│   │   ├── layers/
│   │   │   ├── affine_transform.h
│   │   │   ├── affine_transform_sparse_input.h
│   │   │   ├── clipped_relu.h
│   │   │   └── sqr_clipped_relu.h
│   │   ├── network.cpp
│   │   ├── network.h
│   │   ├── nnue_accumulator.cpp
│   │   ├── nnue_accumulator.h
│   │   ├── nnue_architecture.h
│   │   ├── nnue_common.h
│   │   ├── nnue_feature_transformer.h
│   │   ├── nnue_misc.cpp
│   │   ├── nnue_misc.h
│   │   └── simd.h
│   ├── numa.h
│   ├── perft.h
│   ├── position.cpp
│   ├── position.h
│   ├── score.cpp
│   ├── score.h
│   ├── search.cpp
│   ├── search.h
│   ├── shm.h
│   ├── shm_linux.h
│   ├── syzygy/
│   │   ├── tbprobe.cpp
│   │   └── tbprobe.h
│   ├── thread.cpp
│   ├── thread.h
│   ├── thread_win32_osx.h
│   ├── timeman.cpp
│   ├── timeman.h
│   ├── tt.cpp
│   ├── tt.h
│   ├── tune.cpp
│   ├── tune.h
│   ├── types.h
│   ├── uci.cpp
│   ├── uci.h
│   ├── ucioption.cpp
│   └── ucioption.h
└── tests/
    ├── .gitattributes
    ├── instrumented.py
    ├── perft.sh
    ├── reprosearch.sh
    ├── signature.sh
    └── testing.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .clang-format
================================================
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignEscapedNewlines: DontAlign
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
BreakTemplateDeclarations: Yes
BasedOnStyle: WebKit
BitFieldColonSpacing: After
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction: false
  AfterClass: false
  AfterControlStatement: true
  BeforeElse: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 100
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PackConstructorInitializers: Never
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeCaseColon: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeInheritanceColon: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2


================================================
FILE: .git-blame-ignore-revs
================================================
# .git-blame-ignore-revs
# Ignore commit which added clang-format
2d0237db3f0e596fb06e3ffbadba84dcc4e018f6

# Post commit formatting fixes
0fca5605fa2e5e7240fde5e1aae50952b2612231
08ed4c90db31959521b7ef3186c026edd1e90307

================================================
FILE: .github/ISSUE_TEMPLATE/BUG-REPORT.yml
================================================
name: Report issue
description: Create a report to help us fix issues with the engine
body:
- type: textarea
  attributes:
    label: Describe the issue
    description: A clear and concise description of what you're experiencing.
  validations:
    required: true

- type: textarea
  attributes:
    label: Expected behavior
    description: A clear and concise description of what you expected to happen.
  validations:
    required: true

- type: textarea
  attributes:
    label: Steps to reproduce
    description: |
      Steps to reproduce the behavior.
      You can also use this section to paste the command line output.
    placeholder: |
      ```
      position startpos moves g2g4 e7e5 f2f3
      go mate 1
      info string NNUE evaluation using nn-6877cd24400e.nnue enabled
      info depth 1 seldepth 1 multipv 1 score mate 1 nodes 33 nps 11000 tbhits 0 time 3 pv d8h4
      bestmove d8h4
      ```
  validations:
    required: true

- type: textarea
  attributes:
    label: Anything else?
    description: |
      Anything that will give us more context about the issue you are encountering.
      You can also use this section to propose ideas on how to solve the issue. 
  validations:
    required: false

- type: dropdown
  attributes:
    label: Operating system
    options:
      - All
      - Windows
      - Linux
      - MacOS
      - Android
      - Other or N/A
  validations:
    required: true

- type: input
  attributes:
    label: Stockfish version
    description: |
      This can be found by running the engine.
      You can also use the commit ID.
    placeholder: Stockfish 15 / e6e324e
  validations:
    required: true


================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
  - name: Discord server
    url: https://discord.gg/GWDRS3kU6R
    about: Feel free to ask for support or have a chat with us on our Discord server!
  - name: Discussions, Q&A, ideas, show us something...
    url: https://github.com/official-stockfish/Stockfish/discussions/new
    about: Do you have an idea for Stockfish? Do you want to show something that you made? Please open a discussion about it!


================================================
FILE: .github/ci/arm_matrix.json
================================================
{
  "config": [
    {
      "name": "Android NDK aarch64",
      "os": "ubuntu-22.04",
      "simple_name": "android",
      "compiler": "aarch64-linux-android29-clang++",
      "emu": "qemu-aarch64",
      "comp": "ndk",
      "shell": "bash",
      "archive_ext": "tar"
    },
    {
      "name": "Android NDK arm",
      "os": "ubuntu-22.04",
      "simple_name": "android",
      "compiler": "armv7a-linux-androideabi29-clang++",
      "emu": "qemu-arm",
      "comp": "ndk",
      "shell": "bash",
      "archive_ext": "tar"
    }
  ],
  "binaries": ["armv8-dotprod", "armv8", "armv7", "armv7-neon"],
  "exclude": [
    {
      "binaries": "armv8-dotprod",
      "config": {
        "compiler": "armv7a-linux-androideabi29-clang++"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "compiler": "armv7a-linux-androideabi29-clang++"
      }
    },
    {
      "binaries": "armv7",
      "config": {
        "compiler": "aarch64-linux-android29-clang++"
      }
    },
    {
      "binaries": "armv7-neon",
      "config": {
        "compiler": "aarch64-linux-android29-clang++"
      }
    }
  ]
}


================================================
FILE: .github/ci/libcxx17.imp
================================================
[
    # Mappings for libcxx's internal headers
    { include: [ "<__fwd/fstream.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/ios.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/istream.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/ostream.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/sstream.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/streambuf.h>", private, "<iosfwd>", public ] },
    { include: [ "<__fwd/string_view.h>", private, "<string_view>", public ] },
    { include: [ "<__system_error/errc.h>", private, "<system_error>", public ] },

    # Mappings for includes between public headers
    { include: [ "<ios>", public, "<iostream>", public ] },
    { include: [ "<streambuf>", public, "<iostream>", public ] },
    { include: [ "<istream>", public, "<iostream>", public ] },
    { include: [ "<ostream>", public, "<iostream>", public ] },
    { include: [ "<iosfwd>", public, "<iostream>", public ] },

    # Missing mappings in include-what-you-use's libcxx.imp
    { include: ["@<__condition_variable/.*>", private, "<condition_variable>", public ] },
    { include: ["@<__mutex/.*>", private, "<mutex>", public ] },
]


================================================
FILE: .github/ci/matrix.json
================================================
{
  "config": [
    {
      "name": "Ubuntu 22.04 GCC",
      "os": "ubuntu-22.04",
      "simple_name": "ubuntu",
      "compiler": "g++",
      "comp": "gcc",
      "shell": "bash",
      "archive_ext": "tar",
      "sde": "/home/runner/work/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.33.0-2024-01-07-lin/sde -future --"
    },
    {
      "name": "macOS 15 Apple Clang",
      "os": "macos-15-intel",
      "simple_name": "macos",
      "compiler": "clang++",
      "comp": "clang",
      "shell": "bash",
      "archive_ext": "tar"
    },
    {
      "name": "macOS 15 Apple Clang M1",
      "os": "macos-15",
      "simple_name": "macos-m1",
      "compiler": "clang++",
      "comp": "clang",
      "shell": "bash",
      "archive_ext": "tar"
    },
    {
      "name": "Windows 2022 Mingw-w64 GCC x86_64",
      "os": "windows-2022",
      "simple_name": "windows",
      "compiler": "g++",
      "comp": "mingw",
      "msys_sys": "mingw64",
      "msys_env": "x86_64-gcc",
      "shell": "msys2 {0}",
      "ext": ".exe",
      "sde": "/d/a/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.33.0-2024-01-07-win/sde.exe -future --",
      "archive_ext": "zip"
    },
    {
      "name": "Windows 11 Mingw-w64 Clang arm64",
      "os": "windows-11-arm",
      "simple_name": "windows",
      "compiler": "clang++",
      "comp": "clang",
      "msys_sys": "clangarm64",
      "msys_env": "clang-aarch64-clang",
      "shell": "msys2 {0}",
      "ext": ".exe",
      "archive_ext": "zip"
    }
  ],
  "binaries": [
    "x86-64",
    "x86-64-sse41-popcnt",
    "x86-64-avx2",
    "x86-64-bmi2",
    "x86-64-avxvnni",
    "x86-64-avx512",
    "x86-64-vnni512",
    "x86-64-avx512icl",
    "apple-silicon",
    "armv8",
    "armv8-dotprod"
  ],
  "exclude": [
    {
      "binaries": "x86-64",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-sse41-popcnt",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-avx2",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-bmi2",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-avxvnni",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-avx512",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-vnni512",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-avx512icl",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "x86-64-avxvnni",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "x86-64-avx512",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "x86-64-vnni512",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "x86-64-avx512icl",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "x86-64",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-sse41-popcnt",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-avx2",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-bmi2",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-avxvnni",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-avx512",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-vnni512",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "x86-64-avx512icl",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "apple-silicon",
      "config": {
        "os": "windows-2022"
      }
    },
    {
      "binaries": "apple-silicon",
      "config": {
        "os": "windows-11-arm"
      }
    },
    {
      "binaries": "apple-silicon",
      "config": {
        "os": "ubuntu-20.04"
      }
    },
    {
      "binaries": "apple-silicon",
      "config": {
        "os": "ubuntu-22.04"
      }
    },
    {
      "binaries": "apple-silicon",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "os": "windows-2022"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "os": "ubuntu-20.04"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "os": "ubuntu-22.04"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "armv8",
      "config": {
        "os": "macos-15"
      }
    },
    {
      "binaries": "armv8-dotprod",
      "config": {
        "os": "windows-2022"
      }
    },
    {
      "binaries": "armv8-dotprod",
      "config": {
        "os": "ubuntu-20.04"
      }
    },
    {
      "binaries": "armv8-dotprod",
      "config": {
        "os": "ubuntu-22.04"
      }
    },
    {
      "binaries": "armv8-dotprod",
      "config": {
        "os": "macos-15-intel"
      }
    },
    {
      "binaries": "armv8-dotprod",
      "config": {
        "os": "macos-15"
      }
    }
  ]
}


================================================
FILE: .github/workflows/arm_compilation.yml
================================================
name: Compilation
on:
  workflow_call:
    inputs:
      matrix:
        type: string
        required: true
jobs:
  Compilation:
    name: ${{ matrix.config.name }} ${{ matrix.binaries }}
    runs-on: ${{ matrix.config.os }}
    env:
      COMPCXX: ${{ matrix.config.compiler }}
      COMP: ${{ matrix.config.comp }}
      EMU: ${{ matrix.config.emu }}
      EXT: ${{ matrix.config.ext }}
      BINARY: ${{ matrix.binaries }}
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(inputs.matrix) }}
    defaults:
      run:
        working-directory: src
        shell: ${{ matrix.config.shell }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Download required linux packages
        if: runner.os == 'Linux'
        run: |
          sudo apt update
          sudo apt install qemu-user

      - name: Install NDK
        if: runner.os == 'Linux'
        run: |
          if [ $COMP == ndk ]; then
            NDKV="27.2.12479018"
            ANDROID_ROOT=/usr/local/lib/android
            ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
            SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
            echo "y" | $SDKMANAGER "ndk;$NDKV"
            ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDKV
            ANDROID_NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
            echo "ANDROID_NDK_BIN=$ANDROID_NDK_BIN" >> $GITHUB_ENV
          fi

      - name: Extract the bench number from the commit history
        run: |
          for hash in $(git rev-list -100 HEAD); do
            benchref=$(git show -s $hash | tac | grep -m 1 -o -x '[[:space:]]*\b[Bb]ench[ :]\+[1-9][0-9]\{5,7\}\b[[:space:]]*' | sed 's/[^0-9]//g') && break || true
          done
          [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $hash" && echo "Reference bench: $benchref" || echo "No bench found"

      - name: Download the used network from the fishtest framework
        run: make net

      - name: Check compiler
        run: |
          if [ $COMP == ndk ]; then
            export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
          fi
          $COMPCXX -v

      - name: Test help target
        run: make help

      - name: Check git
        run: git --version

      # Compile profile guided builds

      - name: Compile ${{ matrix.binaries }} build
        run: |
          if [ $COMP == ndk ]; then
            export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
            export LDFLAGS="-static -Wno-unused-command-line-argument"
          fi
          make clean
          make -j4 profile-build ARCH=$BINARY COMP=$COMP RUN_PREFIX=$EMU
          make strip ARCH=$BINARY COMP=$COMP
          RUN_PREFIX=$EMU ../tests/signature.sh $benchref
          mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT

      - name: Remove non src files
        run: git clean -fx

      - name: Upload artifact for (pre)-release
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}
          path: |
            .
            !.git
            !.output


================================================
FILE: .github/workflows/avx2_compilers.yml
================================================
name: AVX2 Compiler Matrix

on:
  workflow_call:

jobs:
  avx2-compiler-matrix:
    name: avx2 (${{ matrix.name }})
    runs-on: ubuntu-latest
    container:
      image: ${{ matrix.image }}

    strategy:
      fail-fast: false
      matrix:
        include:
          - { name: gcc-10, comp: gcc, cxx: g++, image: "gcc:10" }
          - { name: gcc-11, comp: gcc, cxx: g++, image: "gcc:11" }
          - { name: gcc-12, comp: gcc, cxx: g++, image: "gcc:12" }
          - { name: gcc-13, comp: gcc, cxx: g++, image: "gcc:13" }
          - { name: gcc-14, comp: gcc, cxx: g++, image: "gcc:14" }
          - { name: gcc-15, comp: gcc, cxx: g++, image: "gcc:15" }

          # Using silkeh/clang for older versions
          - { name: clang-10, comp: clang, cxx: clang++, image: "silkeh/clang:10", is_clang: true, ver: "10" }
          - { name: clang-11, comp: clang, cxx: clang++, image: "silkeh/clang:11", is_clang: true, ver: "11" }
          - { name: clang-12, comp: clang, cxx: clang++, image: "silkeh/clang:12", is_clang: true, ver: "12" }
          - { name: clang-13, comp: clang, cxx: clang++, image: "silkeh/clang:13", is_clang: true, ver: "13" }
          - { name: clang-14, comp: clang, cxx: clang++, image: "silkeh/clang:14", is_clang: true, ver: "14" }
          - { name: clang-15, comp: clang, cxx: clang++, image: "silkeh/clang:15", is_clang: true, ver: "15" }
          - { name: clang-16, comp: clang, cxx: clang++, image: "silkeh/clang:16", is_clang: true, ver: "16" }
          - { name: clang-17, comp: clang, cxx: clang++, image: "silkeh/clang:17", is_clang: true, ver: "17" }

          - { name: clang-18, comp: clang, cxx: clang++-18, image: "ubuntu:rolling", is_clang: true, ver: "18" }
          - { name: clang-19, comp: clang, cxx: clang++-19, image: "ubuntu:rolling", is_clang: true, ver: "19" }
          - { name: clang-20, comp: clang, cxx: clang++-20, image: "ubuntu:rolling", is_clang: true, ver: "20" }
          - { name: clang-21, comp: clang, cxx: clang++-21, image: "ubuntu:rolling", is_clang: true, ver: "21" }

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          if grep -q "buster" /etc/os-release; then
            echo "Debian Buster detected. Switching to archive repositories..."
            echo "deb http://archive.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list
            echo "deb http://archive.debian.org/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list
            echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99-ignore-valid-until
          fi

          apt-get update
          apt-get install -y curl git make

      - name: Set up Clang
        if: ${{ matrix.is_clang && matrix.image == 'ubuntu:rolling' }}
        run: |
          if [ "${{ matrix.ver }}" -le 20 ]; then
            apt-get install -y clang-${{ matrix.ver }}
          else
            apt-get install -y \
              clang-${{ matrix.ver }} \
              llvm-${{ matrix.ver }}-dev \
              llvm-${{ matrix.ver }}-linker-tools \
              lld-${{ matrix.ver }}
          fi

      - name: Download network
        working-directory: src
        run: make net

      - name: Build avx2 binary
        working-directory: src
        run: |
          export CXXFLAGS="-Werror"
          if [ "${{ matrix.ver }}" -ge 20 ]; then
            apt install -y lld
          fi
          make clean
          make -j build ARCH=x86-64-avx2 COMP=${{ matrix.comp }} COMPCXX=${{ matrix.cxx }}

      - name: Smoke test
        working-directory: src
        run: ./stockfish bench 16 1 6

================================================
FILE: .github/workflows/clang-format.yml
================================================
# This workflow will run clang-format and comment on the PR.
# Because of security reasons, it is crucial that this workflow
# executes no shell script nor runs make.
# Read this before editing: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

name: Clang-Format
on:
  pull_request_target:
    branches:
      - "master"
    paths:
      - "**.cpp"
      - "**.h"

permissions:
  pull-requests: write

jobs:
  Clang-Format:
    name: Clang-Format
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Run clang-format style check
        uses: jidicula/clang-format-action@4726374d1aa3c6aecf132e5197e498979588ebc8 # @v4.15.0
        id: clang-format
        continue-on-error: true
        with:
          clang-format-version: "20"
          exclude-regex: "incbin"

      - name: Comment on PR
        if: steps.clang-format.outcome == 'failure'
        uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # @v2.5.0
        with:
          message: |
            clang-format 20 needs to be run on this PR.
            If you do not have clang-format installed, the maintainer will run it when merging.
            For the exact version please see https://packages.ubuntu.com/plucky/clang-format-20.

            _(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
          comment_tag: execution
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Comment on PR
        if: steps.clang-format.outcome != 'failure'
        uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # @v2.5.0
        with:
          message: |
            _(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
          create_if_not_exists: false
          comment_tag: execution
          mode: delete
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


================================================
FILE: .github/workflows/codeql.yml
================================================
name: "CodeQL"

on:
  push:
    branches: ["master"]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: ["master"]
  schedule:
    - cron: "17 18 * * 1"

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: ["cpp"]
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
        # Use only 'java' to analyze code written in Java, Kotlin, or both
        # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          persist-credentials: false

      # Initializes the CodeQL tools for scanning.
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: ${{ matrix.language }}
          # If you wish to specify custom queries, you can do so here or in a config file.
          # By default, queries listed here will override any specified in a config file.
          # Prefix the list here with "+" to use these queries and those in the config file.

          # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
          # queries: security-extended,security-and-quality

      - name: Build
        working-directory: src
        run: make -j build

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3
        with:
          category: "/language:${{matrix.language}}"


================================================
FILE: .github/workflows/compilation.yml
================================================
name: Compilation
on:
  workflow_call:
    inputs:
      matrix:
        type: string
        required: true
jobs:
  Compilation:
    name: ${{ matrix.config.name }} ${{ matrix.binaries }}
    runs-on: ${{ matrix.config.os }}
    env:
      COMPCXX: ${{ matrix.config.compiler }}
      COMP: ${{ matrix.config.comp }}
      EXT: ${{ matrix.config.ext }}
      NAME: ${{ matrix.config.simple_name }}
      BINARY: ${{ matrix.binaries }}
      SDE: ${{ matrix.config.sde }}
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(inputs.matrix) }}
    defaults:
      run:
        working-directory: src
        shell: ${{ matrix.config.shell }}
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Install fixed GCC on Linux
        if: runner.os == 'Linux'
        uses: egor-tensin/setup-gcc@eaa888eb19115a521fa72b65cd94fe1f25bbcaac # @v1.3
        with:
          version: 11

      - name: Setup msys and install required packages
        if: runner.os == 'Windows'
        uses: msys2/setup-msys2@v2
        with:
          msystem: ${{ matrix.config.msys_sys }}
          install: mingw-w64-${{ matrix.config.msys_env }} make git zip

      - name: Download SDE package
        if: runner.os == 'Linux' || runner.os == 'Windows'
        uses: petarpetrovt/setup-sde@f0fa5971dc275704531e94264dd23250c442aa41 # @v2.4
        with:
          environmentVariableName: SDE_DIR
          sdeVersion: 9.33.0

      - name: Download the used network from the fishtest framework
        run: make net

      - name: Check compiler
        run: $COMPCXX -v

      - name: Test help target
        run: make help

      - name: Check git
        run: git --version

      - name: Check compiler
        run: $COMPCXX -v

      - name: Show compiler cpu info
        run: |
          if [[ "$COMPCXX" == clang* ]]; then
             $COMPCXX -E - -march=native -###
          else
            $COMPCXX -Q -march=native --help=target
          fi

      # x86-64 with newer extensions tests

      - name: Compile ${{ matrix.config.binaries }} build
        run: |
          make clean
          make -j4 profile-build ARCH=$BINARY COMP=$COMP RUN_PREFIX="$SDE"
          make strip ARCH=$BINARY COMP=$COMP
          RUN_PREFIX="$SDE" ../tests/signature.sh $benchref
          mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT

      - name: Remove non src files
        run: git clean -fx

      - name: Upload artifact for (pre)-release
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}
          path: |
             .
             !.git
             !.output


================================================
FILE: .github/workflows/games.yml
================================================
# This workflow will play games with a debug enabled SF using the PR

name: Games
on:
  workflow_call:
jobs:
  Matetrack:
    name: Games
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout SF repo 
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          path: Stockfish
          persist-credentials: false

      - name: build debug enabled version of SF
        working-directory: Stockfish/src
        run: make -j build debug=yes

      - name: Checkout fastchess repo
        uses: actions/checkout@v4
        with:
          repository: Disservin/fastchess
          path: fastchess
          ref: 894616028492ae6114835195f14a899f6fa237d3
          persist-credentials: false

      - name: fastchess build
        working-directory: fastchess
        run: make -j

      - name: Run games
        working-directory: fastchess
        run: |
          ./fastchess -rounds 4 -games 2 -repeat -concurrency 4 -openings file=app/tests/data/openings.epd format=epd order=random -srand $RANDOM\
               -engine name=sf1 cmd=/home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish\
               -engine name=sf2 cmd=/home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish\
               -ratinginterval 1 -report penta=true -each proto=uci tc=4+0.04 -log file=fast.log | tee fast.out
          cat fast.log
          ! grep "Assertion" fast.log > /dev/null
          ! grep "disconnect" fast.out > /dev/null


================================================
FILE: .github/workflows/iwyu.yml
================================================
name: IWYU
on:
  workflow_call:
jobs:
  Analyzers:
    name: Check includes
    runs-on: ubuntu-22.04
    defaults:
      run:
        working-directory: Stockfish/src
        shell: bash
    steps:
      - name: Checkout Stockfish
        uses: actions/checkout@v4
        with:
          path: Stockfish
          persist-credentials: false

      - name: Checkout include-what-you-use
        uses: actions/checkout@v4
        with:
          repository: include-what-you-use/include-what-you-use
          ref: f25caa280dc3277c4086ec345ad279a2463fea0f
          path: include-what-you-use
          persist-credentials: false

      - name: Download required linux packages
        run: |
          sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main'
          wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libclang-17-dev clang-17 libc++-17-dev

      - name: Set up include-what-you-use
        run: |
          mkdir build && cd build
          cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH="/usr/lib/llvm-17" ..
          sudo make install
        working-directory: include-what-you-use

      - name: Check include-what-you-use
        run: include-what-you-use --version

      - name: Check includes
        run: >
          make analyze
          COMP=clang
          CXX=include-what-you-use
          CXXFLAGS="-stdlib=libc++ -Xiwyu --comment_style=long -Xiwyu --mapping='${{ github.workspace }}/Stockfish/.github/ci/libcxx17.imp' -Xiwyu --error"


================================================
FILE: .github/workflows/matetrack.yml
================================================
# This workflow will run matetrack on the PR

name: Matetrack
on:
  workflow_call:
jobs:
  Matetrack:
    name: Matetrack
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout SF repo 
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          path: Stockfish
          persist-credentials: false

      - name: build SF
        working-directory: Stockfish/src
        run: make -j profile-build

      - name: Checkout matetrack repo
        uses: actions/checkout@v4
        with:
          repository: vondele/matetrack
          path: matetrack
          ref: 6c8405fac9028ca66a077f5c96c918fec0ef8d1d
          persist-credentials: false

      - name: matetrack install deps
        working-directory: matetrack
        run: pip install -r requirements.txt

      - name: cache syzygy
        id: cache-syzygy
        uses: actions/cache@v4
        with:
           path: |
              matetrack/3-4-5-wdl/
              matetrack/3-4-5-dtz/
           key: key-syzygy

      - name: download syzygy 3-4-5 if needed
        working-directory: matetrack
        if: steps.cache-syzygy.outputs.cache-hit != 'true'
        run: |
          wget --no-verbose -r -nH --cut-dirs=2 --no-parent --reject="index.html*" -e robots=off https://tablebase.lichess.ovh/tables/standard/3-4-5-wdl/
          wget --no-verbose -r -nH --cut-dirs=2 --no-parent --reject="index.html*" -e robots=off https://tablebase.lichess.ovh/tables/standard/3-4-5-dtz/

      - name: Run matetrack th1
        working-directory: matetrack
        run: |
          python matecheck.py --syzygyPath 3-4-5-wdl/:3-4-5-dtz/ --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 | tee matecheck1.out
          ! grep "issues were detected" matecheck1.out > /dev/null

      - name: Run matetrack th4
        working-directory: matetrack
        run: |
          python matecheck.py --syzygyPath 3-4-5-wdl/:3-4-5-dtz/ --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 --threads 4 | tee matecheck4.out
          ! grep "issues were detected" matecheck4.out > /dev/null

      - name: Run matetrack th4 gameplay
        working-directory: matetrack
        run: |
          python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --time 3 --timeinc 0.01 --threads 4 | tee matecheck4g.out
          ! grep "issues were detected" matecheck4g.out > /dev/null

      - name: Run matetrack th4 go-mate
        working-directory: matetrack
        run: |
          head -n 21 matetrack.epd > gomates.epd
          head -n 44 matedtrack.epd >> gomates.epd
          head -n 18 mates2000.epd >> gomates.epd
          python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile gomates.epd --mate 0 --threads 4 | tee matecheck4gm.out
          ! grep "issues were detected" matecheck4gm.out > /dev/null
          total=$(grep "Total FENs:" matecheck4gm.out | awk '{print $3}')
          bmates=$(grep "Best mates:" matecheck4gm.out | awk '{print $3}')
          if [ $bmates -ne $total ]; then
            echo "At least one go-mate search did not yield expected mate, see matecheck4gm.out" >&2
            exit 1
          fi

      - name: Run matetrack th1 with --syzygy50MoveRule false
        working-directory: matetrack
        run: |
          grep 5men cursed.epd > cursed5.epd
          python matecheck.py --syzygyPath 3-4-5-wdl/:3-4-5-dtz/ --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile cursed5.epd --nodes 100000 --syzygy50MoveRule false | tee matecheckcursed1.out
          ! grep "issues were detected" matecheckcursed1.out > /dev/null

      - name: Run matetrack th4 with --syzygy50MoveRule false
        working-directory: matetrack
        run: |
          grep 5men cursed.epd > cursed5.epd
          python matecheck.py --syzygyPath 3-4-5-wdl/:3-4-5-dtz/ --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile cursed5.epd --nodes 100000 --threads 4 --syzygy50MoveRule false | tee matecheckcursed4.out
          ! grep "issues were detected" matecheckcursed4.out > /dev/null

      - name: Verify mate and TB win count for matecheckcursed[14].out
        working-directory: matetrack
        run: |
          mates=$(grep "Found mates:" matecheckcursed1.out | awk '{print $3}')
          tbwins=$(grep "Found TB wins:" matecheckcursed1.out | awk '{print $4}')
          if [ $(($mates + $tbwins)) -ne 32 ]; then
            echo "Sum of mates and TB wins is not 32 in matecheckcursed1.out" >&2
            exit 1
          fi
          mates=$(grep "Found mates:" matecheckcursed4.out | awk '{print $3}')
          tbwins=$(grep "Found TB wins:" matecheckcursed4.out | awk '{print $4}')
          if [ $(($mates + $tbwins)) -ne 32 ]; then
            echo "Sum of mates and TB wins is not 32 in matecheckcursed4.out" >&2
            exit 1
          fi


================================================
FILE: .github/workflows/sanitizers.yml
================================================
name: Sanitizers
on:
  workflow_call:
jobs:
  Test-under-sanitizers:
    name: ${{ matrix.sanitizers.name }}
    runs-on: ${{ matrix.config.os }}
    env:
      COMPCXX: ${{ matrix.config.compiler }}
      COMP: ${{ matrix.config.comp }}
      CXXFLAGS: "-Werror"
    strategy:
      fail-fast: false
      matrix:
        config:
          - name: Ubuntu 22.04 GCC
            os: ubuntu-22.04
            compiler: g++
            comp: gcc
            shell: bash
        sanitizers:
          - name: Run with thread sanitizer
            make_option: sanitize=thread
            cxx_extra_flags: ""
            instrumented_option: sanitizer-thread
          - name: Run with UB sanitizer
            make_option: sanitize=undefined
            cxx_extra_flags: ""
            instrumented_option: sanitizer-undefined
          - name: Run under valgrind
            make_option: ""
            cxx_extra_flags: ""
            instrumented_option: valgrind
          - name: Run under valgrind-thread
            make_option: ""
            cxx_extra_flags: ""
            instrumented_option: valgrind-thread
          - name: Run non-instrumented
            make_option: ""
            cxx_extra_flags: ""
            instrumented_option: none
          - name: Run with glibcxx assertions
            make_option: ""
            cxx_extra_flags: -D_GLIBCXX_ASSERTIONS
            instrumented_option: none
    defaults:
      run:
        working-directory: src
        shell: ${{ matrix.config.shell }}
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Download required linux packages
        run: |
          sudo apt update
          sudo apt install expect valgrind g++-multilib

      - name: Download the used network from the fishtest framework
        run: make net

      - name: Check compiler
        run: $COMPCXX -v

      - name: Test help target
        run: make help

      - name: Check git
        run: git --version

      # Since Linux Kernel 6.5 we are getting false positives from the ci,
      # lower the ALSR entropy to disable ALSR, which works as a temporary workaround.
      # https://github.com/google/sanitizers/issues/1716
      # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2056762

      - name: Lower ALSR entropy
        run: sudo sysctl -w vm.mmap_rnd_bits=28

      # Sanitizers

      - name: ${{ matrix.sanitizers.name }}
        run: |
          export CXXFLAGS="-O1 -fno-inline ${{ matrix.sanitizers.cxx_extra_flags }}"
          make clean
          make -j4 ARCH=x86-64-sse41-popcnt ${{ matrix.sanitizers.make_option }} debug=yes optimize=no build > /dev/null
          python3 ../tests/instrumented.py --${{ matrix.sanitizers.instrumented_option }} ./stockfish


================================================
FILE: .github/workflows/stockfish.yml
================================================
name: Stockfish
on:
  push:
    tags:
      - "*"
    branches:
      - master
      - tools
      - github_ci
  pull_request:
    branches:
      - master
      - tools
jobs:
  Prerelease:
    if: github.repository == 'official-stockfish/Stockfish' && (github.ref == 'refs/heads/master' || (startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'))
    runs-on: ubuntu-latest
    needs: [Matrix]
    permissions:
      contents: write # For deleting/creating a prerelease
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      # returns null if no pre-release exists
      - name: Get Commit SHA of Latest Pre-release
        run: |
          # Install required packages
          sudo apt-get update
          sudo apt-get install -y curl jq

          echo "COMMIT_SHA_TAG=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< $(curl -s https://api.github.com/repos/${{ github.repository_owner }}/Stockfish/releases))" >> $GITHUB_ENV

      # delete old previous pre-release and tag
      - run: gh release delete ${{ env.COMMIT_SHA_TAG }} --cleanup-tag
        if: env.COMMIT_SHA_TAG != 'null'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # Make sure that an old ci that still runs on master doesn't recreate a prerelease
      - name: Check Pullable Commits
        id: check_commits
        run: |
          git fetch
          CHANGES=$(git rev-list HEAD..origin/master --count)
          echo "CHANGES=$CHANGES" >> $GITHUB_ENV

      - name: Get last commit SHA
        id: last_commit
        run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV

      - name: Get commit date
        id: commit_date
        run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV

      - name: Official Release?
        id: official_release
        # Check for "Official release version of Stockfish" in the commit message
        run: |
          if git log -1 --pretty=%B | grep -q "Official release version of Stockfish"; then
            echo "OFFICIAL_RELEASE=true" >> $GITHUB_ENV
          else
            echo "OFFICIAL_RELEASE=false" >> $GITHUB_ENV
          fi

      # Create a new pre-release, the other upload_binaries.yml will upload the binaries
      # to this pre-release.
      - name: Create Prerelease
        if: github.ref_name == 'master' && env.CHANGES == '0' && env.OFFICIAL_RELEASE == 'false'
        uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
        with:
          name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
          tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
          prerelease: true
  Matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
      arm_matrix: ${{ steps.set-arm-matrix.outputs.arm_matrix }}
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - id: set-matrix
        run: |
          TASKS=$(echo $(cat .github/ci/matrix.json) )
          echo "MATRIX=$TASKS" >> $GITHUB_OUTPUT
      - id: set-arm-matrix
        run: |
          TASKS_ARM=$(echo $(cat .github/ci/arm_matrix.json) )
          echo "ARM_MATRIX=$TASKS_ARM" >> $GITHUB_OUTPUT
  # Testing Jobs
  IWYU:
    uses: ./.github/workflows/iwyu.yml
  Sanitizers:
    if: ${{ always() }}
    uses: ./.github/workflows/sanitizers.yml
  Tests:
    if: ${{ always() }}
    uses: ./.github/workflows/tests.yml
  Matetrack:
    if: ${{ always() }}
    uses: ./.github/workflows/matetrack.yml
  Games:
    if: ${{ always() }}
    uses: ./.github/workflows/games.yml
  CompilerCheck:
    if: ${{ always() }}
    uses: ./.github/workflows/avx2_compilers.yml
  # Release Jobs
  Compilation:
    needs: [Matrix, Sanitizers, Tests, Matetrack, Games, CompilerCheck]
    uses: ./.github/workflows/compilation.yml
    with:
      matrix: ${{ needs.Matrix.outputs.matrix }}
  ARMCompilation:
    needs: [Matrix, Sanitizers, Tests, Matetrack, Games, CompilerCheck]
    uses: ./.github/workflows/arm_compilation.yml
    with:
      matrix: ${{ needs.Matrix.outputs.arm_matrix }}
  Binaries:
    if: github.repository == 'official-stockfish/Stockfish'
    needs: [Prerelease, Matrix, Compilation]
    uses: ./.github/workflows/upload_binaries.yml
    with:
      matrix: ${{ needs.Matrix.outputs.matrix }}
    permissions:
      contents: write # For deleting/creating a (pre)release
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}
  ARM_Binaries:
    if: github.repository == 'official-stockfish/Stockfish'
    needs: [Prerelease, Matrix, ARMCompilation]
    uses: ./.github/workflows/upload_binaries.yml
    with:
      matrix: ${{ needs.Matrix.outputs.arm_matrix }}
    permissions:
      contents: write # For deleting/creating a (pre)release
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}


================================================
FILE: .github/workflows/tests.yml
================================================
name: Tests
on:
  workflow_call:
jobs:
  Test-Targets:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    env:
      COMPCXX: ${{ matrix.config.compiler }}
      COMP: ${{ matrix.config.comp }}
      CXXFLAGS: "-Werror"
    strategy:
      fail-fast: false
      matrix:
        config:
          - name: Ubuntu 22.04 GCC
            os: ubuntu-22.04
            compiler: g++
            comp: gcc
            run_32bit_tests: true
            run_64bit_tests: true
            shell: bash
          - name: Ubuntu 22.04 Clang
            os: ubuntu-22.04
            compiler: clang++
            comp: clang
            run_32bit_tests: true
            run_64bit_tests: true
            shell: bash
          - name: Android NDK aarch64
            os: ubuntu-22.04
            compiler: aarch64-linux-android29-clang++
            comp: ndk
            run_armv8_tests: true
            shell: bash
          - name: Android NDK arm
            os: ubuntu-22.04
            compiler: armv7a-linux-androideabi29-clang++
            comp: ndk
            run_armv7_tests: true
            shell: bash
          # Currently segfaults in the CI unrelated to a Stockfish change.
          # - name: Linux GCC riscv64
          #   os: ubuntu-22.04
          #   compiler: g++
          #   comp: gcc
          #   run_riscv64_tests: true
          #   base_image: "riscv64/alpine:edge"
          #   platform: linux/riscv64
          #   shell: bash
          - name: Linux GCC ppc64
            os: ubuntu-22.04
            compiler: g++
            comp: gcc
            run_ppc64_tests: true
            base_image: "ppc64le/alpine:latest"
            platform: linux/ppc64le
            shell: bash
          - name: macOS 15 Apple Clang
            os: macos-15-intel
            compiler: clang++
            comp: clang
            run_64bit_tests: true
            shell: bash
          - name: macOS 15 Apple Clang M1
            os: macos-15
            compiler: clang++
            comp: clang
            run_64bit_tests: false
            run_m1_tests: true
            shell: bash
          - name: macOS 15 GCC 11
            os: macos-15-intel
            compiler: g++-11
            comp: gcc
            run_64bit_tests: true
            shell: bash
          - name: Windows 2022 Mingw-w64 GCC x86_64
            os: windows-2022
            compiler: g++
            comp: mingw
            run_64bit_tests: true
            msys_sys: mingw64
            msys_env: x86_64-gcc
            shell: msys2 {0}
          - name: Windows 2022 Mingw-w64 GCC i686
            os: windows-2022
            compiler: g++
            comp: mingw
            run_32bit_tests: true
            msys_sys: mingw32
            msys_env: i686-gcc
            shell: msys2 {0}
          - name: Windows 2022 Mingw-w64 Clang x86_64
            os: windows-2022
            compiler: clang++
            comp: clang
            run_64bit_tests: true
            msys_sys: clang64
            msys_env: clang-x86_64-clang
            shell: msys2 {0}
          - name: Windows 11 Mingw-w64 Clang arm64
            os: windows-11-arm
            compiler: clang++
            comp: clang
            run_armv8_tests: true
            msys_sys: clangarm64
            msys_env: clang-aarch64-clang
            shell: msys2 {0}
    defaults:
      run:
        working-directory: src
        shell: ${{ matrix.config.shell }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Download required linux packages
        if: runner.os == 'Linux'
        run: |
          sudo apt update
          sudo apt install expect valgrind g++-multilib qemu-user-static

      - name: Install NDK
        if: runner.os == 'Linux'
        run: |
          if [ $COMP == ndk ]; then
            NDKV="27.2.12479018"
            ANDROID_ROOT=/usr/local/lib/android
            ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
            SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
            echo "y" | $SDKMANAGER "ndk;$NDKV"
            ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDKV
            ANDROID_NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
            echo "ANDROID_NDK_BIN=$ANDROID_NDK_BIN" >> $GITHUB_ENV
          fi

      - name: Set up QEMU
        if: matrix.config.base_image
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        if: matrix.config.base_image
        uses: docker/setup-buildx-action@v3

      - name: Build Docker container
        if: matrix.config.base_image
        run: |
          docker buildx build --platform ${{ matrix.config.platform }} --load -t sf_builder - << EOF
          FROM ${{ matrix.config.base_image }}
          WORKDIR /app
          RUN apk update && apk add make g++
          CMD ["sh", "src/script.sh"]
          EOF

      - name: Download required macOS packages
        if: runner.os == 'macOS'
        run: brew install coreutils gcc@11

      - name: Setup msys and install required packages
        if: runner.os == 'Windows'
        uses: msys2/setup-msys2@v2
        with:
          msystem: ${{ matrix.config.msys_sys }}
          install: mingw-w64-${{ matrix.config.msys_env }} make git expect

      - name: Download the used network from the fishtest framework
        run: make net

      - name: Extract the bench number from the commit history
        run: |
          for hash in $(git rev-list -100 HEAD); do
            benchref=$(git show -s $hash | tac | grep -m 1 -o -x '[[:space:]]*\b[Bb]ench[ :]\+[1-9][0-9]\{5,7\}\b[[:space:]]*' | sed 's/[^0-9]//g') && break || true
          done
          [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $hash" && echo "Reference bench: $benchref" || echo "No bench found"

      - name: Check compiler
        run: |
          if [ -z "${{ matrix.config.base_image }}" ]; then
            if [ $COMP == ndk ]; then
              export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
            fi
            $COMPCXX -v
          else
            echo "$COMPCXX -v" > script.sh
            docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}:/app sf_builder
          fi

      - name: Test help target
        run: make help

      - name: Check git
        run: git --version

      # x86-32 tests

      - name: Test debug x86-32 build
        if: matrix.config.run_32bit_tests
        run: |
          export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
          make clean
          make -j4 ARCH=x86-32 optimize=no debug=yes build
          ../tests/signature.sh $benchref

      - name: Test x86-32 build
        if: matrix.config.run_32bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-32 build
          ../tests/signature.sh $benchref

      - name: Test x86-32-sse41-popcnt build
        if: matrix.config.run_32bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-32-sse41-popcnt build
          ../tests/signature.sh $benchref

      - name: Test x86-32-sse2 build
        if: matrix.config.run_32bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-32-sse2 build
          ../tests/signature.sh $benchref

      - name: Test general-32 build
        if: matrix.config.run_32bit_tests
        run: |
          make clean
          make -j4 ARCH=general-32 build
          ../tests/signature.sh $benchref

      # x86-64 tests

      - name: Test debug x86-64-avx2 build
        if: matrix.config.run_64bit_tests
        run: |
          export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
          make clean
          make -j4 ARCH=x86-64-avx2 optimize=no debug=yes build
          ../tests/signature.sh $benchref

      - name: Test x86-64-bmi2 build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-bmi2 build
          ../tests/signature.sh $benchref

      - name: Test x86-64-avx2 build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-avx2 build
          ../tests/signature.sh $benchref

      # Test a deprecated arch
      - name: Test x86-64-modern build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-modern build
          ../tests/signature.sh $benchref

      - name: Test x86-64-sse41-popcnt build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-sse41-popcnt build
          ../tests/signature.sh $benchref

      - name: Test x86-64-ssse3 build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-ssse3 build
          ../tests/signature.sh $benchref

      - name: Test x86-64-sse3-popcnt build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-sse3-popcnt build
          ../tests/signature.sh $benchref

      - name: Test x86-64 build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64 build
          ../tests/signature.sh $benchref

      - name: Test general-64 build
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=general-64 build
          ../tests/signature.sh $benchref

      - name: Test apple-silicon build
        if: matrix.config.run_m1_tests
        run: |
          make clean
          make -j4 ARCH=apple-silicon build
          ../tests/signature.sh $benchref

      # armv8 tests

      - name: Test armv8 build
        if: matrix.config.run_armv8_tests
        run: |
          if [ $COMP == ndk ]; then
            export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
            export LDFLAGS="-static -Wno-unused-command-line-argument"
          fi
          make clean
          make -j4 ARCH=armv8 build
          ../tests/signature.sh $benchref

      - name: Test armv8-dotprod build
        if: matrix.config.run_armv8_tests
        run: |
          if [ $COMP == ndk ]; then
            export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
            export LDFLAGS="-static -Wno-unused-command-line-argument"
          fi
          make clean
          make -j4 ARCH=armv8-dotprod build
          ../tests/signature.sh $benchref

      # armv7 tests

      - name: Test armv7 build
        if: matrix.config.run_armv7_tests
        run: |
          export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
          export LDFLAGS="-static -Wno-unused-command-line-argument"
          make clean
          make -j4 ARCH=armv7 build
          ../tests/signature.sh $benchref

      - name: Test armv7-neon build
        if: matrix.config.run_armv7_tests
        run: |
          export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
          export LDFLAGS="-static -Wno-unused-command-line-argument"
          make clean
          make -j4 ARCH=armv7-neon build
          ../tests/signature.sh $benchref

      # riscv64 tests

      - name: Test riscv64 build
        if: matrix.config.run_riscv64_tests
        run: |
          echo "cd src && export LDFLAGS='-static' && make clean && make -j4 ARCH=riscv64 build" > script.sh
          docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}:/app sf_builder
          ../tests/signature.sh $benchref

      # ppc64 tests

      - name: Test ppc64 build
        if: matrix.config.run_ppc64_tests
        run: |
          echo "cd src && export LDFLAGS='-static' && make clean && make -j4 ARCH=ppc-64 build" > script.sh
          docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}:/app sf_builder
          ../tests/signature.sh $benchref

      # Other tests

      - name: Check perft and search reproducibility
        if: matrix.config.run_64bit_tests
        run: |
          make clean
          make -j4 ARCH=x86-64-avx2 build
          ../tests/perft.sh
          ../tests/reprosearch.sh


================================================
FILE: .github/workflows/upload_binaries.yml
================================================
name: Upload Binaries
on:
  workflow_call:
    inputs:
      matrix:
        type: string
        required: true
    secrets:
      token:
        required: true

jobs:
  Artifacts:
    name: ${{ matrix.config.name }} ${{ matrix.binaries }}
    runs-on: ubuntu-latest
    env:
      EXT: ${{ matrix.config.ext }}
      NAME: ${{ matrix.config.simple_name }}
      BINARY: ${{ matrix.binaries }}
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(inputs.matrix) }}
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Download artifact from compilation
        uses: actions/download-artifact@v4
        with:
          name: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}
          path: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}

      - name: Create Package
        run: |
          mkdir stockfish

      - name: Download wiki
        run: |
          git clone https://github.com/official-stockfish/Stockfish.wiki.git wiki
          rm -rf wiki/.git
          mv wiki stockfish/

      - name: Copy files
        run: |
          mv "${{ matrix.config.simple_name }} ${{ matrix.binaries }}" stockfish-workflow
          cd stockfish-workflow
          cp -r src ../stockfish/
          cp -r scripts ../stockfish/
          cp stockfish-$NAME-$BINARY$EXT ../stockfish/
          cp "Top CPU Contributors.txt" ../stockfish/
          cp Copying.txt ../stockfish/
          cp AUTHORS ../stockfish/
          cp CITATION.cff ../stockfish/
          cp README.md ../stockfish/
          cp CONTRIBUTING.md ../stockfish/

      - name: Create tar
        if: ${{ !startsWith(matrix.config.os, 'windows') }}
        run: |
          chmod +x ./stockfish/stockfish-$NAME-$BINARY$EXT
          tar -cvf stockfish-$NAME-$BINARY.tar stockfish

      - name: Create zip
        if: ${{ startsWith(matrix.config.os, 'windows') }}
        run: |
          zip -r stockfish-$NAME-$BINARY.zip stockfish

      - name: Release
        if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
        uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
        with:
          files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
          token: ${{ secrets.token }}

      - name: Get last commit sha
        id: last_commit
        run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV

      - name: Get commit date
        id: commit_date
        run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV

      # Make sure that an old ci that still runs on master doesn't recreate a prerelease
      - name: Check Pullable Commits
        id: check_commits
        run: |
          git fetch
          CHANGES=$(git rev-list HEAD..origin/master --count)
          echo "CHANGES=$CHANGES" >> $GITHUB_ENV

      - name: Official Release?
        id: official_release
        # Check for "Official release version of Stockfish" in the commit message
        run: |
          if git log -1 --pretty=%B | grep -q "Official release version of Stockfish"; then
            echo "OFFICIAL_RELEASE=true" >> $GITHUB_ENV
          else
            echo "OFFICIAL_RELEASE=false" >> $GITHUB_ENV
          fi

      - name: Prerelease
        if: github.ref_name == 'master' && env.CHANGES == '0' && env.OFFICIAL_RELEASE == 'false'
        continue-on-error: true
        uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
        with:
          name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
          tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
          prerelease: true
          files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
          token: ${{ secrets.token }}


================================================
FILE: .gitignore
================================================
# Files from build
**/*.o
**/*.s
src/.depend
.build_sha.txt
.build_date.txt

# Built binary
src/stockfish*
src/-lstdc++.res

# Neural network for the NNUE evaluation
**/*.nnue

# Files generated by the instrumented tests
tsan.supp
__pycache__/
tests/syzygy
tests/bench_tmp.epd

================================================
FILE: AUTHORS
================================================
# Founders of the Stockfish project and Fishtest infrastructure
Tord Romstad (romstad)
Marco Costalba (mcostalba)
Joona Kiiski (zamar)
Gary Linscott (glinscott)

# Authors and inventors of NNUE, training, and NNUE port
Yu Nasu (ynasu87)
Motohiro Isozaki (yaneurao)
Hisayori Noda (nodchip)

# All other authors of Stockfish code (in alphabetical order)
87flowers
Aditya (absimaldata)
Adrian Petrescu (apetresc)
Ahmed Kerimov (wcdbmv)
Ajith Chandy Jose (ajithcj)
Alain Savard (Rocky640)
Alayan Feh (Alayan-stk-2)
Alexander Kure
Alexander Pagel (Lolligerhans)
Alfredo Menezes (lonfom169)
Ali AlZhrani (Cooffe)
AliceRoselia
Andreas Jan van der Meulen (Andyson007)
Andreas Matthies (Matthies)
Andrei Vetrov (proukornew)
Andrew Grant (AndyGrant)
Andrey Neporada (nepal)
Andy Duplain
Antoine Champion (antoinechampion)
Aram Tumanian (atumanian)
Arjun Temurnikar
Aron Petkovski (fury)
Arseniy Surkov (codedeliveryservice)
Artem Solopiy (EntityFX)
Auguste Pop
Balazs Szilagyi
Balint Pfliegel
Baptiste Rech (breatn)
Ben Chaney (Chaneybenjamini)
Ben Koshy (BKSpurgeon)
Bill Henry (VoyagerOne)
Bojun Guo (noobpwnftw, Nooby)
borg323
Boštjan Mejak (PedanticHacker)
braich
Brian Sheppard (SapphireBrand, briansheppard-toast)
Bruno de Melo Costa (BM123499)
Bruno Pellanda (pellanda)
Bryan Cross (crossbr)
candirufish
Carlos Esparza Sánchez (ces42)
Chess13234
Chris Bao (sscg13)
Chris Cain (ceebo)
Ciekce
clefrks
Clemens L. (rn5f107s2)
Cody Ho (aesrentai)
CSTENTOR
Dale Weiler (graphitemaster)
Daniel Axtens (daxtens)
Daniel Dugovic (ddugovic)
Daniel Monroe (daniel-monroe)
Daniel Samek (DanSamek)
Dan Schmidt (dfannius)
Dariusz Orzechowski (dorzechowski)
David (dav1312)
David Zar
Daylen Yang (daylen)
Deshawn Mohan-Smith (GoldenRare)
Dieter Dobbelaere (ddobbelaere)
DiscanX
Dominik Schlösser (domschl)
double-beep
Douglas Matos Gomes (dsmsgms)
Dubslow
Eduardo Cáceres (eduherminio)
Eelco de Groot (KingDefender)
Ehsan Rashid (erashid)
Elvin Liu (solarlight2)
erbsenzaehler
Ernesto Gatti
evqsx
Fabian Beuke (madnight)
Fabian Fichter (ianfab)
Fanael Linithien (Fanael)
fanon
Fauzi Akram Dabat (fauzi2)
Felix Wittmann
gamander
Gabriele Lombardo (gabe)
Gahtan Nahdi
Gary Heckman (gheckman)
George Sobala (gsobala)
gguliash
Giacomo Lorenzetti (G-Lorenz)
Gian-Carlo Pascutto (gcp)
Goh CJ (cj5716)
Gontran Lemaire (gonlem)
Goodkov Vasiliy Aleksandrovich (goodkov)
Gregor Cramer
GuardianRM
Guy Vreuls (gvreuls)
Günther Demetz (pb00067, pb00068)
Henri Wiechers
Hiraoka Takuya (HiraokaTakuya)
homoSapiensSapiens
Hongzhi Cheng
Ivan Ivec (IIvec)
Jacques B. (Timshel)
Jake Senne (w1wwwwww)
Jakub Ciolek (jake-ciolek)
Jan Ondruš (hxim)
Jared Kish (Kurtbusch, kurt22i)
Jarrod Torriero (DU-jdto)
Jasper Shovelton (Beanie496)
Jean-Francois Romang (jromang)
Jean Gauthier (OuaisBla)
Jekaa
Jerry Donald Watson (jerrydonaldwatson)
jjoshua2
Jonathan Buladas Dumale (SFisGOD)
Jonathan Calovski (Mysseno)
Jonathan McDermid (jonathanmcdermid)
Joost VandeVondele (vondele)
Joseph Ellis (jhellis3)
Joseph R. Prostko
Jost Triller (tsoj)
Jörg Oster (joergoster)
Julian Willemer (NightlyKing)
jundery
Justin Blanchard (UncombedCoconut)
Kazuki Yamashita (KazApps)
Kelly Wilson
Ken Takusagawa
Kenneth Lee (kennethlee33)
kevlu8
Kian E (KJE-98)
Kieren Pearson (KierenP)
kinderchocolate
Kiran Panditrao (Krgp)
Kirill Zaripov (kokodio)
Kojirion
Krisztián Peőcz
Krystian Kuzniarek (kuzkry)
Leonardo Ljubičić (ICCF World Champion)
Leonid Pechenik (lp--)
Li Ying (yl25946)
Liam Keegan (lkeegan)
Linmiao Xu (linrock)
Linus Arver (listx)
loco-loco
Lub van den Berg (ElbertoOne)
Luca Brivio (lucabrivio)
Lucas Braesch (lucasart)
Lyudmil Antonov (lantonov)
Maciej Żenczykowski (zenczykowski)
Malcolm Campbell (xoto10)
Mark Marosi (Mapika)
Mark Tenzer (31m059)
marotear
Mathias Parnaudeau (mparnaudeau)
Matt Ginsberg (mattginsberg)
Matthew Lai (matthewlai)
Matthew Sullivan (Matt14916)
Max A. (Disservin)
Maxim Masiutin (maximmasiutin)
Maxim Molchanov (Maxim)
Michael An (man)
Michael Byrne (MichaelB7)
Michael Chaly (Vizvezdenec)
Michael Stembera (mstembera)
Michael Whiteley (protonspring)
Michel Van den Bergh (vdbergh)
Miguel Lahoz (miguel-l)
Mikael Bäckman (mbootsector)
Mike Babigian (Farseer)
Mira
Miroslav Fontán (Hexik)
Moez Jellouli (MJZ1977)
Mohammed Li (tthsqe12)
Muzhen J (XInTheDark)
Nathan Rugg (nmrugg)
Nguyen Pham (nguyenpham)
Nicklas Persson (NicklasPersson)
Nick Pelling (nickpelling)
Nicolas Duhamel (nikloskoda)
Niklas Fiekas (niklasf)
Nikolay Kostov (NikolayIT)
Norman Schmidt (FireFather)
notruck
Nour Berakdar (Nonlinear)
Ofek Shochat (OfekShochat, ghostway)
Ondrej Mosnáček (WOnder93)
Ondřej Mišina (AndrovT)
Oskar Werkelin Ahlin
Ömer Faruk Tutkun (OmerFarukTutkun)
Pablo Vazquez
Panthee
Pascal Romaret
Pasquale Pigazzini (ppigazzini)
Patrick Jansen (mibere)
Patrick Leonhardt (Yoshie2000)
Peter Schneider (pschneider1968)
Peter Zsifkovits (CoffeeOne)
Pieter te Brake (pieterteb)
PikaCat
Praveen Kumar Tummala (praveentml)
Prokop Randáček (ProkopRandacek)
Rahul Dsilva (silversolver1)
Ralph Stößer (Ralph Stoesser)
Raminder Singh
renouve
Reuven Peleg (R-Peleg)
Richard Lloyd (Richard-Lloyd)
Robert Nürnberg (robertnurnberg)
Rodrigo Exterckötter Tjäder
Rodrigo Roim (roim)
Ronald de Man (syzygy1, syzygy)
Ron Britvich (Britvich)
rqs
Rui Coelho (ruicoelhopedro)
rustam-cpp
Ryan Hirsch
Ryan Schmitt
Ryan Takker
Sami Kiminki (skiminki)
Sebastian Buchwald (UniQP)
Sergei Antonov (saproj)
Sergei Ivanov (svivanov72)
Sergio Vieri (sergiovieri)
sf-x
Shahin M. Shahin (peregrine)
Shane Booth (shane31)
Shawn Varghese (xXH4CKST3RXx)
Shawn Xu (xu-shawn)
Siad Daboul (Topologist)
Stefan Geschwentner (locutus2)
Stefano Cardanobile (Stefano80)
Stefano Di Martino (StefanoD)
Steinar Gunderson (sesse)
Stéphane Nicolet (snicolet)
Stephen Touset (stouset)
Stockfisher69
Styx (styxdoto)
Syine Mineta (MinetaS)
Taras Vuk (TarasVuk)
Thanar2
thaspel
theo77186
TierynnB
Timothy Herchen (anematode)
Ting-Hsuan Huang (fffelix-huang)
Tobias Steinmann
Tomasz Sobczyk (Sopel97)
Tom Truscott
Tom Vijlbrief (tomtor)
Torsten Franz (torfranz, tfranzer)
Torsten Hellwig (Torom)
Tracey Emery (basepr1me)
tttak
Unai Corzo (unaiic)
Uri Blass (uriblass)
Vince Negri (cuddlestmonkey)
Viren
Wencey Wang
Will Miles (willm)
windfishballad
xefoci7612
Xiang Wang (KatyushaScarlet)
Yen-Chao Shen (lemteay)
ZlomenyMesic
zz4032

# Additionally, we acknowledge the authors and maintainers of fishtest,
# an amazing and essential framework for Stockfish development!
#
# https://github.com/official-stockfish/fishtest/blob/master/AUTHORS


================================================
FILE: CITATION.cff
================================================
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Stockfish
message: >-
  Please cite this software using the metadata from this
  file.
type: software
authors:
  - name: The Stockfish developers (see AUTHORS file)
repository-code: 'https://github.com/official-stockfish/Stockfish'
url: 'https://stockfishchess.org/'
repository-artifact: 'https://stockfishchess.org/download/'
abstract: Stockfish is a free and strong UCI chess engine.
keywords:
  - chess
  - artificial intelligence (AI)
  - tree search
  - alpha-beta search
  - neural networks (NN)
  - efficiently updatable neural networks (NNUE)
license: GPL-3.0


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to Stockfish

Welcome to the Stockfish project! We are excited that you are interested in
contributing. This document outlines the guidelines and steps to follow when
making contributions to Stockfish.

## Table of Contents

- [Building Stockfish](#building-stockfish)
- [Making Contributions](#making-contributions)
  - [Reporting Issues](#reporting-issues)
  - [Submitting Pull Requests](#submitting-pull-requests)
- [Code Style](#code-style)
- [Community and Communication](#community-and-communication)
- [License](#license)

## Building Stockfish

In case you do not have a C++ compiler installed, you can follow the
instructions from our wiki.

- [Ubuntu][ubuntu-compiling-link]
- [Windows][windows-compiling-link]
- [macOS][macos-compiling-link]

## Making Contributions

### Reporting Issues

If you find a bug, please open an issue on the
[issue tracker][issue-tracker-link]. Be sure to include relevant information
like your operating system, build environment, and a detailed description of the
problem.

_Please note that Stockfish's development is not focused on adding new features.
Thus any issue regarding missing features will potentially be closed without
further discussion._

### Submitting Pull Requests

- Functional changes need to be tested on fishtest. See
  [Creating my First Test][creating-my-first-test] for more details.
  The accompanying pull request should include a link to the test results and
  the new bench.

- Non-functional changes (e.g. refactoring, code style, documentation) do not
  need to be tested on fishtest, unless they might impact performance.

- Provide a clear and concise description of the changes in the pull request
  description.

_First time contributors should add their name to [AUTHORS](./AUTHORS)._

_Stockfish's development is not focused on adding new features. Thus any pull
request introducing new features will potentially be closed without further
discussion._

## Code Style

Changes to Stockfish C++ code should respect our coding style defined by
[.clang-format](.clang-format). You can format your changes by running
`make format`. This requires clang-format version 20 to be installed on your system.

## Navigate

For experienced Git users who frequently use git blame, it is recommended to
configure the blame.ignoreRevsFile setting.
This setting is useful for excluding noisy formatting commits.

```bash
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

## Community and Communication

- Join the [Stockfish discord][discord-link] to discuss ideas, issues, and
  development.
- Participate in the [Stockfish GitHub discussions][discussions-link] for
  broader conversations.

## License

By contributing to Stockfish, you agree that your contributions will be licensed
under the GNU General Public License v3.0. See [Copying.txt][copying-link] for
more details.

Thank you for contributing to Stockfish and helping us make it even better!

[copying-link]:           https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt
[discord-link]:           https://discord.gg/GWDRS3kU6R
[discussions-link]:       https://github.com/official-stockfish/Stockfish/discussions/new
[creating-my-first-test]: https://github.com/official-stockfish/fishtest/wiki/Creating-my-first-test#create-your-test
[issue-tracker-link]:     https://github.com/official-stockfish/Stockfish/issues
[ubuntu-compiling-link]:  https://github.com/official-stockfish/Stockfish/wiki/Developers#user-content-installing-a-compiler-1
[windows-compiling-link]: https://github.com/official-stockfish/Stockfish/wiki/Developers#user-content-installing-a-compiler
[macos-compiling-link]:   https://github.com/official-stockfish/Stockfish/wiki/Developers#user-content-installing-a-compiler-2


================================================
FILE: Copying.txt
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
<div align="center">

  [![Stockfish][stockfish128-logo]][website-link]

  <h3>Stockfish</h3>

  A free and strong UCI chess engine.
  <br>
  <strong>[Explore Stockfish docs »][wiki-link]</strong>
  <br>
  <br>
  [Report bug][issue-link]
  ·
  [Open a discussion][discussions-link]
  ·
  [Discord][discord-link]
  ·
  [Blog][website-blog-link]

  [![Build][build-badge]][build-link]
  [![License][license-badge]][license-link]
  <br>
  [![Release][release-badge]][release-link]
  [![Commits][commits-badge]][commits-link]
  <br>
  [![Website][website-badge]][website-link]
  [![Fishtest][fishtest-badge]][fishtest-link]
  [![Discord][discord-badge]][discord-link]

</div>

## Overview

[Stockfish][website-link] 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][wiki-usage-link] for further usage help.

## Files

This distribution of Stockfish consists of the following files:

  * [README.md][readme-link], the file you are currently reading.

  * [Copying.txt][license-link], a text file containing the GNU General Public
    License version 3.

  * [AUTHORS][authors-link], a text file with the list of authors for the project.

  * [src][src-link], 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](CONTRIBUTING.md).__

### Donating hardware

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

### Improving the code

In the [chessprogramming wiki][programming-link], many techniques used in
Stockfish are explained with a lot of background information.
The [section on Stockfish][programmingsf-link] 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][fishtest-link].
If you want to help improve Stockfish, please read this [guideline][guideline-link]
first, where the basics of Stockfish development are explained.

Discussions about Stockfish take place these days mainly in the Stockfish
[Discord server][discord-link]. 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
```

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

## Terms of use

Stockfish is free and distributed under the
[**GNU General Public License version 3**][license-link] (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.

## Acknowledgements

Stockfish uses neural networks trained on [data provided by the Leela Chess Zero
project][lc0-data-link], which is made available under the [Open Database License][odbl-link] (ODbL).


[authors-link]:       https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS
[build-link]:         https://github.com/official-stockfish/Stockfish/actions/workflows/stockfish.yml
[commits-link]:       https://github.com/official-stockfish/Stockfish/commits/master
[discord-link]:       https://discord.gg/GWDRS3kU6R
[issue-link]:         https://github.com/official-stockfish/Stockfish/issues/new?assignees=&labels=&template=BUG-REPORT.yml
[discussions-link]:   https://github.com/official-stockfish/Stockfish/discussions/new
[fishtest-link]:      https://tests.stockfishchess.org/tests
[guideline-link]:     https://github.com/official-stockfish/fishtest/wiki/Creating-my-first-test
[license-link]:       https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt
[programming-link]:   https://www.chessprogramming.org/Main_Page
[programmingsf-link]: https://www.chessprogramming.org/Stockfish
[readme-link]:        https://github.com/official-stockfish/Stockfish/blob/master/README.md
[release-link]:       https://github.com/official-stockfish/Stockfish/releases/latest
[src-link]:           https://github.com/official-stockfish/Stockfish/tree/master/src
[stockfish128-logo]:  https://stockfishchess.org/images/logo/icon_128x128.png
[uci-link]:           https://backscattering.de/chess/uci/
[website-link]:       https://stockfishchess.org
[website-blog-link]:  https://stockfishchess.org/blog/
[wiki-link]:          https://github.com/official-stockfish/Stockfish/wiki
[wiki-compile-link]:  https://github.com/official-stockfish/Stockfish/wiki/Compiling-from-source
[wiki-uci-link]:      https://github.com/official-stockfish/Stockfish/wiki/UCI-&-Commands
[wiki-usage-link]:    https://github.com/official-stockfish/Stockfish/wiki/Download-and-usage
[worker-link]:        https://github.com/official-stockfish/fishtest/wiki/Running-the-worker
[lc0-data-link]:      https://storage.lczero.org/files/training_data
[odbl-link]:          https://opendatacommons.org/licenses/odbl/odbl-10.txt

[build-badge]:        https://img.shields.io/github/actions/workflow/status/official-stockfish/Stockfish/stockfish.yml?branch=master&style=for-the-badge&label=stockfish&logo=github
[commits-badge]:      https://img.shields.io/github/commits-since/official-stockfish/Stockfish/latest?style=for-the-badge
[discord-badge]:      https://img.shields.io/discord/435943710472011776?style=for-the-badge&label=discord&logo=Discord
[fishtest-badge]:     https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=Fishtest&up_color=success&up_message=Online&url=https%3A%2F%2Ftests.stockfishchess.org%2Ftests%2Ffinished
[license-badge]:      https://img.shields.io/github/license/official-stockfish/Stockfish?style=for-the-badge&label=license&color=success
[release-badge]:      https://img.shields.io/github/v/release/official-stockfish/Stockfish?style=for-the-badge&label=official%20release
[website-badge]:      https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=website&up_color=success&up_message=Online&url=https%3A%2F%2Fstockfishchess.org


================================================
FILE: Top CPU Contributors.txt
================================================
Contributors to Fishtest with >10,000 CPU hours, as of 2025-12-24.
Thank you!

Username                                CPU Hours     Games played
------------------------------------------------------------------
noobpwnftw                               42692720       3385202467
vdv                                      39922218       1277282126
technologov                              26354561       1163905856
linrock                                  12002255        785641643
olafm                                     3030005        197722318
mlang                                     3026000        200065824
okrout                                    3020471        268364402
pemo                                      2009761         66178221
TueRens                                   1956328         83294326
sebastronomy                              1806628         73868874
dew                                       1689162        100033738
grandphish2                               1479778         92306101
JojoM                                     1130646         73666860
rpngn                                     1081976         65292619
oz                                        1029329         69522328
gvreuls                                    844572         59249068
tvijlbrief                                 796125         51897690
mibere                                     703840         46867607
leszek                                     609538         45301765
cw                                         519602         34988289
fastgm                                     503862         30260818
robal                                      503208         32703510
maximmasiutin                              500174         30818270
CSU_Dynasty                                481663         31916842
ctoks                                      435431         28551199
crunchy                                    427414         27371625
bcross                                     415724         29061187
mgrabiak                                   380202         27586936
tolkki963                                  358623         26373242
velislav                                   342588         22140902
ncfish1                                    329039         20624527
Fisherman                                  327231         21829379
Fifis                                      323909         16200123
Sylvain27                                  320732         11671388
marrco                                     310446         19587107
Calis007                                   310201         18969692
Viren6                                     297938          5847458
Dantist                                    296386         18031762
naclosagc                                  296040         13865010
anematode                                  293146          3918134
maposora                                   278093         20454200
javran                                     271465         20506096
cody                                       258835         13301710
nordlandia                                 249322         16420192
Goatminola                                 218812         21411814
Torom                                      211061          7238522
glinscott                                  208125         13277240
drabel                                     204167         13930674
Wencey                                     203584          9943614
mhoram                                     202894         12601997
sschnee                                    201756         12874780
bking_US                                   198894         11876016
Mineta                                     195312         10337614
Thanar                                     179852         12365359
armo9494                                   169747         11254404
amicic                                     161636         11290899
DesolatedDodo                              160605         10392474
markkulix                                  158320         13538874
spams                                      157128         10319326
sqrt2                                      147963          9724586
vdbergh                                    141201          9308647
jcAEie                                     140086         10603658
CoffeeOne                                  137100          5024116
malala                                     136182          8002293
xoto                                       133759          9159372
Dubslow                                    130795          8609646
zeryl                                      129154          7911565
davar                                      129023          8376525
DMBK                                       122960          8980062
cuistot                                    122470          8393996
megaman7de                                 122254          8066174
dsmith                                     122059          7570238
Wolfgang                                   120919          8619168
CypressChess                               120902          8683904
sterni1971                                 113754          6054022
Spprtr                                     113356          8129809
Data                                       113305          8220352
BrunoBanani                                112960          7436849
skiminki                                   107583          7218170
MediumBerry5575                            103884          7830022
MaZePallas                                 102823          6633619
YvesKn                                     102213          5098076
sunu                                       100167          7040199
thirdlife                                   99182          2246960
ElbertoOne                                  99028          7023771
TechiePirate                                98957          1249064
DeepnessFulled                              97313          5083358
TataneSan                                   97257          4239502
romangol                                    95662          7784954
bigpen0r                                    94825          6529241
jojo2357                                    94358          7635486
malfoy                                      92712          3392874
voidedstarlight                             92582          2342038
brabos                                      92118          6186135
Maxim                                       90818          3283364
psk                                         89957          5984901
szupaw                                      89775          7800606
jromang                                     87260          5988073
racerschmacer                               85805          6122790
Vizvezdenec                                 83761          5344740
0x3C33                                      82614          5271253
MarcusTullius                               82359          5335665
BRAVONE                                     81239          5054681
rn                                          78566          6000852
nssy                                        76497          5259388
woutboat                                    76379          6031688
teddybaer                                   75125          5407666
Pking_cda                                   73776          5293873
yurikvelo                                   73611          5046822
Zirie                                       71260          4602355
Bobo1239                                    70579          4794999
solarlight                                  70517          5028306
dv8silencer                                 70287          3883992
0x539                                       67147          2918044
manap                                       66273          4121774
tinker                                      64333          4268790
CounterFlow                                 63914          3775062
mecevdimitar                                62493          3508750
DanielMiao1                                 62188          1335664
qurashee                                    61208          3429862
AGI                                         58316          4336328
robnjr                                      57262          4053117
Freja                                       56938          3733019
MaxKlaxxMiner                               56879          3423958
ttruscott                                   56010          3680085
rkl                                         55132          4164467
jmdana                                      54988          4041917
notchris                                    53936          4184018
renouve                                     53811          3501516
jibarbosa                                   53504          5110028
somethingintheshadows                       52333          4344808
finfish                                     51360          3370515
eva42                                       51272          3599691
eastorwest                                  51117          3454811
sylvek                                      50391          3765170
rap                                         49985          3219146
pb00067                                     49733          3298934
GPUex                                       48686          3684998
OuaisBla                                    48626          3445134
lemtea                                      48563          1672454
ronaldjerum                                 47654          3240695
abdicj                                      46740          2709482
biffhero                                    46564          3111352
oryx                                        46422          3607582
VoyagerOne                                  45476          3452465
rdp65536                                    43948          2881890
speedycpu                                   43842          3003273
jbwiebe                                     43305          2805433
gopeto                                      43046          2821514
Antihistamine                               41788          2761312
mhunt                                       41735          2691355
WoodMan777                                  40858          3491196
Epic29                                      40771          4067404
drauh                                       40419          1634770
homyur                                      39893          2850481
gri                                         39871          2515779
vidar808                                    39774          1656372
Gaster319                                   38994          3477702
Garf                                        37741          2999686
SC                                          37299          2731694
ZacHFX                                      36533          2553282
csnodgrass                                  36207          2688994
icewulf                                     34935          2421834
strelock                                    34716          2074055
Jopo12321                                   33921          2531448
xuhdev                                      33798          3295210
csnodgra                                    33780          1446866
EthanOConnor                                33370          2090311
slakovv                                     32915          2021889
IslandLambda                                32667          1659344
Kataiser                                    32477          2688862
shawnxu                                     32330          2830036
srowen                                      32248          1791136
qgluca                                      31941          2491622
Gelma                                       31771          1551204
kdave                                       31157          2198362
manapbk                                     30987          1810399
votoanthuan                                 30691          2460856
Prcuvu                                      30377          2170122
anst                                        30301          2190091
jkiiski                                     30136          1904470
spcc                                        29925          1901692
hyperbolic.tom                              29840          2017394
chuckstablers                               29659          2093438
Pyafue                                      29650          1902349
Flopzee                                     29388          1899905
hoching                                     29054          2067144
belzedar94                                  28846          1811530
wizardassassin                              28007          2318204
purpletree                                  27892          2061966
Kyrega                                      27674           963872
joendter                                    27193          1781570
Danielv123                                  27132          1043614
chriswk                                     26902          1868317
xwziegtm                                    26897          2124586
spotscene                                   26877          2139674
achambord                                   26582          1767323
shreven                                     26448          1703328
Patrick_G                                   26276          1801617
yorkman                                     26193          1992080
ols                                         26173          1443517
wer                                         26136           793146
Skiff84                                     26083          1135002
RudyMars                                    25980          2211364
Ulysses                                     25544          1714542
SFTUser                                     25182          1675689
nabildanial                                 25068          1531665
Sharaf_DG                                   24765          1786697
rodneyc                                     24376          1416402
jsys14                                      24297          1721230
AndreasKrug                                 24235          1934711
agg177                                      23890          1395014
Disservin                                   23768          1934576
Ente                                        23752          1678188
JanErik                                     23408          1703875
Isidor                                      23388          1680691
Norabor                                     23371          1603244
Nullvalue                                   23155          2022752
fishtester                                  23115          1581502
cisco2015                                   22920          1763301
Hjax                                        22561          1566151
gerbil                                      22435          1679842
Serpensin                                   22396          1861156
team-oh                                     22272          1636708
mkstockfishtester                           22253          2029566
Roady                                       22220          1465606
tsim67                                      22077          1353048
MazeOfGalious                               21978          1629593
sg4032                                      21950          1643373
sev                                         21791          1983016
ianh2105                                    21725          1632562
xor12                                       21628          1680365
dex                                         21612          1467203
nesoneg                                     21494          1463031
user213718                                  21454          1404128
sphinx                                      21211          1384728
qoo_charly_cai                              21136          1514927
jjoshua2                                    21001          1423089
Zake9298                                    20938          1565848
horst.prack                                 20878          1465656
0xB00B1ES                                   20590          1208666
t3hf1sht3ster                               20544           673134
Dinde                                       20459          1292774
j3corre                                     20405           941444
Adrian.Schmidt123                           20316          1281436
wei                                         19973          1745989
teenychess                                  19819          1762006
RickGroszkiewicz                            19749          1913986
rstoesser                                   19569          1293588
eudhan                                      19274          1283717
nalanzeyu                                   19211           396674
vulcan                                      18871          1729392
Karpovbot                                   18766          1053178
Farseer                                     18536          1078326
jundery                                     18445          1115855
sebv15                                      18267          1262588
whelanh                                     17887           347974
ville                                       17883          1384026
chris                                       17698          1487385
purplefishies                               17595          1092533
dju                                         17414           981289
iisiraider                                  17275          1049015
Karby                                       17177          1030688
fogleman                                    17134           815562
zhujianzhao                                 17111          1666972
DragonLord                                  17014          1162790
pirt                                        16993          1274363
redstone59                                  16842          1461780
Alb11747                                    16787          1213990
Naven94                                     16414           951718
scuzzi                                      16155           995347
IgorLeMasson                                16064          1147232
micpilar                                    15866          1399266
ako027ako                                   15671          1173203
infinigon                                   15285           965966
fishtrawler                                 15205          1436165
Nikolay.IT                                  15154          1068349
Andrew Grant                                15114           895539
OssumOpossum                                14857          1007129
LunaticBFF57                                14525          1190310
YELNAMRON                                   14480          1141420
enedene                                     14476           905279
MooTheCow                                   14459          1023868
BestBoyBerlin                               14353          1365584
bpfliegel                                   14233           882523
mpx86                                       14019           759568
jpulman                                     13982           870599
getraideBFF                                 13871          1172846
crocogoat                                   13817          1119086
Nesa92                                      13806          1116101
joster                                      13717           946960
mbeier                                      13650          1044928
Pablohn26                                   13552          1088532
wxt9861                                     13550          1312306
biniek                                      13469           930029
Dark_wizzie                                 13422          1007152
Jackfish                                    13422           914984
Hongildong                                  13297           699288
Rudolphous                                  13244           883140
Phoenix17                                   13032          1124066
Machariel                                   13010           863104
mabichito                                   12903           749391
FormazChar                                  12899           980413
thijsk                                      12886           722107
AdrianSA                                    12860           804972
szczur90                                    12720           979324
mschmidt                                    12644           863193
korposzczur                                 12606           838168
fatmurphy                                   12547           853210
Oakwen                                      12537           856257
SapphireBrand                               12416           969604
Snuuka                                      12392           509082
deflectooor                                 12386           579392
modolief                                    12386           896470
ckaz                                        12273           754644
pgontarz                                    12151           848794
dbernier                                    12103           860824
rensonthemove                               11999           971993
stocky                                      11954           699440
ali-al-zhrani                               11887           836126
3cho                                        11842          1036786
Craftyawesome                               11736           832254
dragon123118                                11578          1044142
ImperiumAeternum                            11482           979142
lvdv                                        11475           594400
infinity                                    11470           727027
kusihe                                      11468           468450
vaskoul                                     11446           976902
aga                                         11412           695127
Def9Infinity                                11408           700682
torbjo                                      11395           729145
Thomas A. Anderson                          11372           732094
savage84                                    11358           670860
d64                                         11263           789184
Poly                                        11172           455568
enizor                                      11140           630194
snicolet                                    11106           869170
dapper                                      11032           771402
Ethnikoi                                    10993           945906
Karmatron                                   10871           678306
zarthus                                     10773          1034536
OliverClarke                                10696           942654
Omed                                        10680           669816
cyberthink                                  10647           936538
basepi                                      10637           744851
michaelrpg                                  10624           748179
Cubox                                       10621           826448
GBx3TV                                      10499           343266
Styx                                        10450           867836
OIVAS7572                                   10420           995586
Garruk                                      10365           706465
dzjp                                        10343           732529
Lorenz                                      10311           886308
borinot                                     10026           902130


================================================
FILE: scripts/.gitattributes
================================================
*.sh text eol=lf


================================================
FILE: scripts/get_native_properties.sh
================================================
#!/bin/sh

#
# Returns the best architecture supported by the CPU (as expected by src/Makefile ARCH=).
#
# Output format:
#   "<true_arch>\n"
#

# ---------------------------
# Helpers (POSIX)
# ---------------------------

# Test hooks (optional env overrides)
#   GP_UNAME_S: override `uname -s`
#   GP_UNAME_M: override `uname -m`
#   GP_CPUINFO: path to a cpuinfo-like fixture file (defaults to /proc/cpuinfo)
#   GP_BITS: override getconf LONG_BIT result (32/64)
#   GP_SYSCTL_FEATURES: override sysctl feature strings on Darwin x86_64

cpuinfo_path=${GP_CPUINFO:-/proc/cpuinfo}

# Normalize to a single-line, space-separated string.
normalize_ws() {
	printf '%s\n' "$*" | tr '\n\t' '  ' | tr -s ' '
}

die() {
	printf '%s\n' "$*" >&2
	exit 1
}

# Populate $flags from /proc/cpuinfo when available,
# removing underscores and dots to reduce naming variations.
get_flags() {
	if [ -r "$cpuinfo_path" ]; then
		flags=$(
			awk '
				/^flags[ \t]*:|^Features[ \t]*:/ {
					if (!found) {
						gsub(/^flags[ \t]*:[ \t]*|^Features[ \t]*:[ \t]*|[_.]/, "");
						line=$0
						found=1
					}
				}
				END { print line }
			' "$cpuinfo_path" 2>/dev/null
		)
	else
		flags=''
	fi
	flags=$(printf '%s\n' "$flags" | tr '[:upper:]' '[:lower:]')
	flags=$(normalize_ws "$flags")
}

# Populate $flags from sysctl on Darwin x86_64.
get_sysctl_flags() {
	if [ -n "${GP_SYSCTL_FEATURES:-}" ]; then
		flags=$(printf '%s\n' "$GP_SYSCTL_FEATURES")
	else
		flags=$(sysctl -n machdep.cpu.features machdep.cpu.leaf7_features 2>/dev/null)
	fi
	flags=$(printf '%s\n' "$flags" | tr '\n' ' ' | tr '[:upper:]' '[:lower:]' | tr -d '._')
	flags=$(normalize_ws "$flags")
}

# Best-effort bitness for fallback arch selection.
get_bits() {
	if [ -n "${GP_BITS:-}" ]; then
		bits=$GP_BITS
	else
		bits=$(getconf LONG_BIT 2>/dev/null)
	fi
	case $bits in
		32|64) : ;;
		*) bits=64 ;;
	esac
}

# Extract ARM architecture level (5/6/7/8/...) from /proc/cpuinfo when present.
get_arm_arch_level() {
	[ -r "$cpuinfo_path" ] || return 1
	awk '
		/^CPU architecture[ \t]*:/{
			s=$0
			sub(/^[^:]*:[ \t]*/, "", s)
			if (match(s, /[0-9]+/)) { print substr(s, RSTART, RLENGTH); exit }
		}
		/^Processor[ \t]*:/{
			s=$0
			sub(/^[^:]*:[ \t]*/, "", s)
			if (match(s, /ARMv[0-9]+/)) { print substr(s, RSTART+4, RLENGTH-4); exit }
		}
	' "$cpuinfo_path" 2>/dev/null
}

# Best-effort ARM architecture level (5/6/7/8/...) with a minimal fallback.
# Prefer /proc/cpuinfo when available; fall back to uname -m only when it encodes it.
get_arm_level() {
	arm_level=$(get_arm_arch_level || :)
	if [ -n "$arm_level" ]; then
		printf '%s\n' "$arm_level"
		return 0
	fi
	case ${1:-} in
		armv5*) printf '5\n' ;;
		armv6*) printf '6\n' ;;
		armv7*) printf '7\n' ;;
		armv8l) printf '8\n' ;;
		*) return 1 ;;
	esac
}

# Whole-token membership check.
has_flag() {
	case " $flags " in
		*" $1 "*) return 0 ;;
		*)        return 1 ;;
	esac
}

match_flags() {
	for f; do
		has_flag "$f" || return 1
	done
	return 0
}

match_any_flags() {
	for f; do
		has_flag "$f" && return 0
	done
	return 1
}

# SSE3 is often exposed as "pni" in /proc/cpuinfo.
match_sse3() {
	match_any_flags sse3 pni
}

# AMD Zen1/2 exclusion logic (used for bmi2 tier).
# https://web.archive.org/web/20250821132355/https://en.wikichip.org/wiki/amd/cpuid
is_znver_1_2() (
	[ -r "$cpuinfo_path" ] || exit 1
	vendor_id=$(awk '/^vendor_id/{print $3; exit}' "$cpuinfo_path" 2>/dev/null)
	cpu_family=$(awk '/^cpu family/{print $4; exit}' "$cpuinfo_path" 2>/dev/null)
	[ "$vendor_id" = "AuthenticAMD" ] && [ "$cpu_family" = "23" ]
)

match_not_znver12_and_flags() {
	is_znver_1_2 && return 1
	match_flags "$@"
}

match_sse3_popcnt() {
	has_flag popcnt || return 1
	match_sse3
}

match_true() { return 0; }

# Generic selector: reads lines like "arch|predicate|arg1 arg2 ..."
# First match wins; blank lines and lines starting with '#' are ignored.
select_arch_from_table() {
	while IFS='|' read -r arch pred args; do
		[ -z "$arch" ] && continue
		case $arch in \#*) continue ;; esac

		if [ -n "$args" ]; then
			# Intentional splitting of args into words for the predicate.
			# shellcheck disable=SC2086
			$pred $args && { printf '%s\n' "$arch"; return 0; }
		else
			$pred && { printf '%s\n' "$arch"; return 0; }
		fi
	done
	return 1
}

# ---------------------------
# Arch selection (table-driven)
# ---------------------------

set_arch_loongarch64() {
	true_arch=$(
		select_arch_from_table <<'EOF'
loongarch64-lasx|match_flags|lasx
loongarch64-lsx|match_flags|lsx
loongarch64|match_true|
EOF
	)
}

set_arch_x86_64() {
	true_arch=$(
		select_arch_from_table <<'EOF'
# Strongest -> weakest (first match wins)
x86-64-avx512icl|match_flags|avx512f avx512cd avx512vl avx512dq avx512bw avx512ifma avx512vbmi avx512vbmi2 avx512vpopcntdq avx512bitalg avx512vnni vpclmulqdq gfni vaes
x86-64-vnni512|match_flags|avx512vnni avx512dq avx512f avx512bw avx512vl
x86-64-avx512|match_flags|avx512f avx512bw
x86-64-avxvnni|match_flags|avxvnni
x86-64-bmi2|match_not_znver12_and_flags|bmi2
x86-64-avx2|match_flags|avx2
x86-64-sse41-popcnt|match_flags|sse41 popcnt
x86-64-ssse3|match_flags|ssse3
x86-64-sse3-popcnt|match_sse3_popcnt|
x86-64|match_true|
EOF
	)
}

set_arch_x86_32() {
	true_arch=$(
		select_arch_from_table <<'EOF'
x86-32-sse41-popcnt|match_flags|sse41 popcnt
x86-32-sse2|match_flags|sse2
x86-32|match_true|
EOF
	)
}

# PPC64 needs a little parsing to distinguish vsx vs altivec.
set_arch_ppc_64() {
	if [ -r "$cpuinfo_path" ] && grep -q "altivec" "$cpuinfo_path" 2>/dev/null; then
		# Typical: "cpu : POWER8E" (extract the number after POWER)
		power=$(
			awk -F: '/^cpu[ \t]*:/{print $2; exit}' "$cpuinfo_path" 2>/dev/null \
				| sed -n 's/.*[Pp][Oo][Ww][Ee][Rr][^0-9]*\([0-9][0-9]*\).*/\1/p'
		)
		if [ -z "$power" ]; then
			power=$(
				awk -F: '/^cpu[ \t]*:/{print $2; exit}' "$cpuinfo_path" 2>/dev/null \
					| sed -n 's/.*\([0-9][0-9]*\).*/\1/p'
			)
		fi
		case $power in
			''|*[!0-9]*)
				true_arch='ppc-64-altivec'
				;;
			*)
				if [ "$power" -gt 7 ] 2>/dev/null; then
					true_arch='ppc-64-vsx'
				else
					true_arch='ppc-64-altivec'
				fi
				;;
		esac
	else
		true_arch='ppc-64'
	fi
}

# ---------------------------
# OS / machine dispatch
# ---------------------------

uname_s=$(uname -s 2>/dev/null)
uname_m=$(uname -m 2>/dev/null)
uname_s=${GP_UNAME_S:-$uname_s}
uname_m=${GP_UNAME_M:-$uname_m}

case $uname_s in
	Darwin)
		case $uname_m in
			arm64)
				true_arch='apple-silicon'
				;;
			x86_64)
				get_sysctl_flags
				set_arch_x86_64
				;;
			*)
				get_bits
				if [ "$bits" = "32" ]; then
					true_arch='general-32'
				else
					true_arch='general-64'
				fi
				;;
		esac
		;;

	Linux)
		get_flags
		case $uname_m in
			x86_64)
				set_arch_x86_64
				;;
			i?86)
				set_arch_x86_32
				;;
			ppc64*)
				set_arch_ppc_64
				;;
			aarch64|arm64)
				true_arch='armv8'
				if match_flags asimddp; then
					true_arch='armv8-dotprod'
				fi
				;;
			armv5*|armv6*|armv7*|armv8l|arm*)
				arm_level=$(get_arm_level "$uname_m" || :)
				case $arm_level in
					5|6)
						true_arch='general-32'
						;;
					7|8)
						true_arch='armv7'
						if match_flags neon; then
							true_arch='armv7-neon'
						fi
						;;
					*)
						true_arch='general-32'
						if match_flags neon; then
							true_arch='armv7-neon'
						fi
						;;
				esac
				;;
			loongarch64*)
				set_arch_loongarch64
				;;
			riscv64)
				true_arch='riscv64'
				;;
			e2k*)
				true_arch='e2k'
				;;
			ppc|ppc32|powerpc)
				true_arch='ppc-32'
				;;
			*)
				# Don't hard-fail: fall back to general-* so ARCH=native still builds
				get_bits
				if [ "$bits" = "32" ]; then
					true_arch='general-32'
				else
					true_arch='general-64'
				fi
				;;
		esac
		;;

	MINGW*ARM64*)
		# Windows ARM64 (MSYS2/MinGW)
		# Can't reliably detect ARM CPU features here
		true_arch='armv8-dotprod'
		;;

	CYGWIN*|MINGW*|MSYS*)
		# Windows x86_64 (MSYS2/Cygwin/MinGW)
		get_flags
		set_arch_x86_64
		;;

	*)
		die "Unsupported system type: $uname_s"
		;;
esac

printf '%s\n' "$true_arch"


================================================
FILE: scripts/net.sh
================================================
#!/bin/sh

# download commands with a 5min time-out to ensure things fail if the server stalls
wget_or_curl=$( (command -v wget >/dev/null 2>&1 && echo "wget -qO- --timeout=300 --tries=1") ||
  (command -v curl >/dev/null 2>&1 && echo "curl -skL --max-time 300"))

sha256sum=$( (command -v shasum >/dev/null 2>&1 && echo "shasum -a 256") ||
  (command -v sha256sum >/dev/null 2>&1 && echo "sha256sum"))

if [ -z "$sha256sum" ]; then
  >&2 echo "sha256sum not found, NNUE files will be assumed valid."
fi

get_nnue_filename() {
  grep "$1" evaluate.h | grep "#define" | sed "s/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/"
}

validate_network() {
  # If no sha256sum command is available, assume the file is always valid.
  if [ -n "$sha256sum" ] && [ -f "$1" ]; then
    if [ "$1" != "nn-$($sha256sum "$1" | cut -c 1-12).nnue" ]; then
      rm -f "$1"
      return 1
    fi
  fi
}

fetch_network() {
  _filename="$(get_nnue_filename "$1")"

  if [ -z "$_filename" ]; then
    >&2 echo "NNUE file name not found for: $1"
    return 1
  fi

  if [ -f "$_filename" ]; then
    if validate_network "$_filename"; then
      echo "Existing $_filename validated, skipping download"
      return
    else
      echo "Removing invalid NNUE file: $_filename"
    fi
  fi

  if [ -z "$wget_or_curl" ]; then
    >&2 printf "%s\n" "Neither wget or curl is installed." \
      "Install one of these tools to download NNUE files automatically."
    exit 1
  fi

  for url in \
    "https://tests.stockfishchess.org/api/nn/$_filename" \
    "https://github.com/official-stockfish/networks/raw/master/$_filename"; do
    echo "Downloading from $url ..."
    if $wget_or_curl "$url" >"$_filename"; then
      if validate_network "$_filename"; then
        echo "Successfully validated $_filename"
      else
        rm -f $_filename
        echo "Downloaded $_filename is invalid, and has been removed."
        continue
      fi
    else
      rm -f $_filename
      echo "Failed to download from $url"
    fi
    if [ -f "$_filename" ]; then
      return
    fi
  done

  # Download was not successful in the loop, return false.
  >&2 echo "Failed to download $_filename"
  return 1
}

fetch_network EvalFileDefaultNameBig &&
  fetch_network EvalFileDefaultNameSmall


================================================
FILE: src/Makefile
================================================
# Stockfish, a UCI chess playing engine derived from Glaurung 2.1
# Copyright (C) 2004-2026 The Stockfish developers (see AUTHORS file)
#
# Stockfish is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Stockfish is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


### ==========================================================================
### Section 1. General Configuration
### ==========================================================================

### Establish the operating system name
KERNEL := $(shell uname -s)
ifeq ($(KERNEL),Linux)
	OS := $(shell uname -o)
endif

### Command prefix to run the built executable (e.g. wine, sde, qemu)
### Backward compatible alias: WINE_PATH (deprecated)
ifneq ($(strip $(WINE_PATH)),)
ifeq ($(strip $(RUN_PREFIX)),)
RUN_PREFIX := $(WINE_PATH)
endif
ifeq ($(MAKELEVEL),0)
ifneq ($(strip $(RUN_PREFIX)),$(strip $(WINE_PATH)))
$(warning *** Both RUN_PREFIX and WINE_PATH are set; ignoring WINE_PATH. ***)
else
$(warning *** WINE_PATH is deprecated; use RUN_PREFIX instead. ***)
endif
endif
endif

### Target Windows OS
ifeq ($(OS),Windows_NT)
	ifneq ($(COMP),ndk)
		target_windows = yes
	endif
else ifeq ($(COMP),mingw)
	target_windows = yes
	ifeq ($(RUN_PREFIX),)
		RUN_PREFIX := $(shell which wine)
	endif
endif

### Executable name
ifeq ($(target_windows),yes)
	EXE = stockfish.exe
else
	EXE = stockfish
endif

### Installation dir definitions
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin

### Built-in benchmark for pgo-builds
PGOBENCH = $(RUN_PREFIX) ./$(EXE) bench

### Source and object files
SRCS = benchmark.cpp bitboard.cpp evaluate.cpp main.cpp \
	misc.cpp movegen.cpp movepick.cpp position.cpp \
	search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
	nnue/nnue_accumulator.cpp nnue/nnue_misc.cpp nnue/network.cpp \
	nnue/features/half_ka_v2_hm.cpp nnue/features/full_threats.cpp \
	engine.cpp score.cpp memory.cpp

HEADERS = benchmark.h bitboard.h evaluate.h misc.h movegen.h movepick.h history.h \
		nnue/nnue_misc.h nnue/features/half_ka_v2_hm.h nnue/features/full_threats.h \
		nnue/layers/affine_transform.h nnue/layers/affine_transform_sparse_input.h \
		nnue/layers/clipped_relu.h nnue/layers/sqr_clipped_relu.h nnue/nnue_accumulator.h \
		nnue/nnue_architecture.h nnue/nnue_common.h nnue/nnue_feature_transformer.h nnue/simd.h \
		position.h search.h syzygy/tbprobe.h thread.h thread_win32_osx.h timeman.h \
		tt.h tune.h types.h uci.h ucioption.h perft.h nnue/network.h engine.h score.h numa.h memory.h shm.h shm_linux.h

OBJS = $(notdir $(SRCS:.cpp=.o))

VPATH = syzygy:nnue:nnue/features

### ==========================================================================
### Section 2. High-level Configuration
### ==========================================================================
#
# flag                --- Comp switch        --- Description
# ----------------------------------------------------------------------------
#
# debug = yes/no      --- -DNDEBUG           --- Enable/Disable debug mode
# sanitize = none/<sanitizer> ... (-fsanitize )
#                     --- ( undefined )      --- enable undefined behavior checks
#                     --- ( thread    )      --- enable threading error checks
#                     --- ( address   )      --- enable memory access checks
#                     --- ...etc...          --- see compiler documentation for supported sanitizers
# optimize = yes/no   --- (-O3/-fast etc.)   --- Enable/Disable optimizations
# arch = (name)       --- (-arch)            --- Target architecture
# bits = 64/32        --- -DIS_64BIT         --- 64-/32-bit operating system
# prefetch = yes/no   --- -DUSE_PREFETCH     --- Use prefetch asm-instruction
# popcnt = yes/no     --- -DUSE_POPCNT       --- Use popcnt asm-instruction
# pext = yes/no       --- -DUSE_PEXT         --- Use pext x86_64 asm-instruction
# sse = yes/no        --- -msse              --- Use Intel Streaming SIMD Extensions
# mmx = yes/no        --- -mmmx              --- Use Intel MMX instructions
# sse2 = yes/no       --- -msse2             --- Use Intel Streaming SIMD Extensions 2
# ssse3 = yes/no      --- -mssse3            --- Use Intel Supplemental Streaming SIMD Extensions 3
# sse41 = yes/no      --- -msse4.1           --- Use Intel Streaming SIMD Extensions 4.1
# avx2 = yes/no       --- -mavx2             --- Use Intel Advanced Vector Extensions 2
# avxvnni = yes/no    --- -mavxvnni          --- Use Intel Vector Neural Network Instructions AVX
# avx512 = yes/no     --- -mavx512bw         --- Use Intel Advanced Vector Extensions 512
# vnni512 = yes/no    --- -mavx512vnni       --- Use Intel Vector Neural Network Instructions 512
# avx512icl = yes/no  --- ... multiple ...   --- Use All AVX-512 features available on both Intel Ice Lake and AMD Zen 4
# altivec = yes/no    --- -maltivec          --- Use PowerPC Altivec SIMD extension
# vsx = yes/no        --- -mvsx              --- Use POWER VSX SIMD extension
# neon = yes/no       --- -DUSE_NEON         --- Use ARM SIMD architecture
# dotprod = yes/no    --- -DUSE_NEON_DOTPROD --- Use ARM advanced SIMD Int8 dot product instructions
# lsx = yes/no        --- -mlsx              --- Use Loongson SIMD eXtension
# lasx = yes/no       --- -mlasx             --- use Loongson Advanced SIMD eXtension
#
# Note that Makefile is space sensitive, so when adding new architectures
# or modifying existing flags, you have to make sure there are no extra spaces
# at the end of the line for flag values.
#
# Example of use for these flags:
# make build ARCH=x86-64-avx512 debug=yes sanitize="address undefined"


### 2.1. General and architecture defaults

ifeq ($(ARCH),)
   ARCH = native
endif

ifeq ($(ARCH), native)
   override ARCH := $(shell $(SHELL) ../scripts/get_native_properties.sh | cut -d " " -f 1)
endif

# explicitly check for the list of supported architectures (as listed with make help),
# the user can override with `make ARCH=x86-64-avx512icl SUPPORTED_ARCH=true`
ifeq ($(ARCH), $(filter $(ARCH), \
                 x86-64-avx512icl x86-64-vnni512 x86-64-avx512 x86-64-avxvnni \
                 x86-64-bmi2 x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
                 x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-64-altivec ppc-64-vsx ppc-32 e2k \
                 armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64 \
                 loongarch64 loongarch64-lsx loongarch64-lasx))
   SUPPORTED_ARCH=true
else
   SUPPORTED_ARCH=false
endif

optimize = yes
debug = no
sanitize = none
bits = 64
prefetch = no
popcnt = no
pext = no
sse = no
mmx = no
sse2 = no
ssse3 = no
sse41 = no
avx2 = no
avxvnni = no
avx512 = no
vnni512 = no
avx512icl = no
altivec = no
vsx = no
neon = no
dotprod = no
arm_version = 0
lsx = no
lasx = no
STRIP = strip

ifneq ($(shell which clang-format-20 2> /dev/null),)
	CLANG-FORMAT = clang-format-20
else
	CLANG-FORMAT = clang-format
endif

### 2.2 Architecture specific

ifeq ($(findstring x86,$(ARCH)),x86)

# x86-32/64

ifeq ($(findstring x86-32,$(ARCH)),x86-32)
	arch = i386
	bits = 32
	sse = no
	mmx = yes
else
	arch = x86_64
	sse = yes
	sse2 = yes
endif

ifeq ($(findstring -sse,$(ARCH)),-sse)
	sse = yes
endif

ifeq ($(findstring -popcnt,$(ARCH)),-popcnt)
	popcnt = yes
endif

ifeq ($(findstring -mmx,$(ARCH)),-mmx)
	mmx = yes
endif

ifeq ($(findstring -sse2,$(ARCH)),-sse2)
	sse = yes
	sse2 = yes
endif

ifeq ($(findstring -ssse3,$(ARCH)),-ssse3)
	sse = yes
	sse2 = yes
	ssse3 = yes
endif

ifeq ($(findstring -sse41,$(ARCH)),-sse41)
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
endif

ifeq ($(findstring -modern,$(ARCH)),-modern)
        $(warning *** ARCH=$(ARCH) is deprecated, defaulting to ARCH=x86-64-sse41-popcnt. Execute `make help` for a list of available architectures. ***)
        $(shell sleep 5)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
endif

ifeq ($(findstring -avx2,$(ARCH)),-avx2)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
endif

ifeq ($(findstring -avxvnni,$(ARCH)),-avxvnni)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
	avxvnni = yes
	pext = yes
endif

ifeq ($(findstring -bmi2,$(ARCH)),-bmi2)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
	pext = yes
endif

ifeq ($(findstring -avx512,$(ARCH)),-avx512)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
	pext = yes
	avx512 = yes
endif

ifeq ($(findstring -vnni512,$(ARCH)),-vnni512)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
	pext = yes
	avx512 = yes
	vnni512 = yes
endif

ifeq ($(findstring -avx512icl,$(ARCH)),-avx512icl)
	popcnt = yes
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	avx2 = yes
	pext = yes
	avx512 = yes
	vnni512 = yes
	avx512icl = yes
endif

ifeq ($(sse),yes)
	prefetch = yes
endif

# 64-bit pext is not available on x86-32
ifeq ($(bits),32)
	pext = no
endif

else

# all other architectures

ifeq ($(ARCH),general-32)
	arch = any
	bits = 32
endif

ifeq ($(ARCH),general-64)
	arch = any
endif

ifeq ($(ARCH),armv7)
	arch = armv7
	prefetch = yes
	bits = 32
	arm_version = 7
endif

ifeq ($(ARCH),armv7-neon)
	arch = armv7
	prefetch = yes
	popcnt = yes
	neon = yes
	bits = 32
	arm_version = 7
endif

ifeq ($(ARCH),armv8)
	arch = armv8
	prefetch = yes
	popcnt = yes
	neon = yes
	arm_version = 8
endif

ifeq ($(ARCH),armv8-dotprod)
	arch = armv8
	prefetch = yes
	popcnt = yes
	neon = yes
	dotprod = yes
	arm_version = 8
endif

ifeq ($(ARCH),apple-silicon)
	arch = arm64
	prefetch = yes
	popcnt = yes
	neon = yes
	dotprod = yes
	arm_version = 8
endif

ifeq ($(ARCH),ppc-32)
	arch = ppc
	bits = 32
endif

ifeq ($(ARCH),ppc-64)
	arch = ppc64
	popcnt = yes
	prefetch = yes
endif

ifeq ($(ARCH),ppc-64-altivec)
	arch = ppc64
	popcnt = yes
	prefetch = yes
	altivec = yes
endif

ifeq ($(ARCH),ppc-64-vsx)
	arch = ppc64
	popcnt = yes
	prefetch = yes
	vsx = yes
endif

ifeq ($(findstring e2k,$(ARCH)),e2k)
	arch = e2k
	mmx = yes
	bits = 64
	sse = yes
	sse2 = yes
	ssse3 = yes
	sse41 = yes
	popcnt = yes
endif

ifeq ($(ARCH),riscv64)
	arch = riscv64
endif

ifeq ($(findstring loongarch64,$(ARCH)),loongarch64)
	arch = loongarch64
	prefetch = yes

ifeq ($(findstring -lasx,$(ARCH)),-lasx)
	lsx = yes
	lasx = yes
endif

ifeq ($(findstring -lsx,$(ARCH)),-lsx)
	lsx = yes
endif

endif
endif


### ==========================================================================
### Section 3. Low-level Configuration
### ==========================================================================

### 3.1 Selecting compiler (default = gcc)
ifeq ($(MAKELEVEL),0)
       export ENV_CXXFLAGS := $(CXXFLAGS)
       export ENV_DEPENDFLAGS := $(DEPENDFLAGS)
       export ENV_LDFLAGS := $(LDFLAGS)
endif

CXXFLAGS = $(ENV_CXXFLAGS) -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
DEPENDFLAGS = $(ENV_DEPENDFLAGS) -std=c++17
LDFLAGS = $(ENV_LDFLAGS) $(EXTRALDFLAGS)

ifeq ($(COMP),)
	COMP=gcc
endif

ifeq ($(COMP),gcc)
	comp=gcc
	CXX=g++
	CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations

	ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
		ifeq ($(OS),Android)
			CXXFLAGS += -m$(bits)
			LDFLAGS += -m$(bits)
		endif
		ifeq ($(ARCH),riscv64)
			CXXFLAGS += -latomic
		endif
	else ifeq ($(arch),loongarch64)
		CXXFLAGS += -latomic
	else
		CXXFLAGS += -m$(bits)
		LDFLAGS += -m$(bits)
	endif

	ifeq ($(arch),$(filter $(arch),armv7))
		LDFLAGS += -latomic
	endif

	ifneq ($(KERNEL),Darwin)
	   LDFLAGS += -Wl,--no-as-needed
	endif
endif

ifeq ($(target_windows),yes)
	LDFLAGS += -static
endif

ifeq ($(COMP),mingw)
	comp=mingw

	ifeq ($(bits),64)
		ifeq ($(shell which x86_64-w64-mingw32-c++-posix 2> /dev/null),)
			CXX=x86_64-w64-mingw32-c++
		else
			CXX=x86_64-w64-mingw32-c++-posix
		endif
	else
		ifeq ($(shell which i686-w64-mingw32-c++-posix 2> /dev/null),)
			CXX=i686-w64-mingw32-c++
		else
			CXX=i686-w64-mingw32-c++-posix
		endif
	endif
	CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations
endif

ifeq ($(COMP),icx)
	comp=icx
	CXX=icpx
	CXXFLAGS += --intel -pedantic -Wextra -Wshadow -Wmissing-prototypes \
		-Wconditional-uninitialized -Wabi -Wdeprecated
endif

ifeq ($(COMP),clang)
	comp=clang
	CXX=clang++
	ifeq ($(target_windows),yes)
		CXX=x86_64-w64-mingw32-clang++
	endif

	CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-prototypes \
	            -Wconditional-uninitialized -flax-vector-conversions=none

	ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
	ifeq ($(target_windows),)
	ifneq ($(RTLIB),compiler-rt)
		LDFLAGS += -latomic
	endif
	endif
	endif

	ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64))
		ifeq ($(OS),Android)
			CXXFLAGS += -m$(bits)
			LDFLAGS += -m$(bits)
		endif
		ifeq ($(ARCH),riscv64)
			CXXFLAGS += -latomic
		endif
	else ifeq ($(arch),loongarch64)
		CXXFLAGS += -latomic
	else
		CXXFLAGS += -m$(bits)
		LDFLAGS += -m$(bits)
	endif
endif

ifeq ($(KERNEL),Darwin)
	CXXFLAGS += -mmacosx-version-min=10.15
	LDFLAGS += -mmacosx-version-min=10.15
	ifneq ($(arch),any)
		CXXFLAGS += -arch $(arch)
		LDFLAGS += -arch $(arch)
	endif
	XCRUN = xcrun
endif

# To cross-compile for Android, use NDK version r27c or later.
ifeq ($(COMP),ndk)
	CXXFLAGS += -stdlib=libc++
	comp=clang
	ifeq ($(arch),armv7)
		CXX=armv7a-linux-androideabi29-clang++
		CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
		ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
			STRIP=arm-linux-androideabi-strip
		else
			STRIP=llvm-strip
		endif
	endif
	ifeq ($(arch),armv8)
		CXX=aarch64-linux-android29-clang++
		ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
			STRIP=aarch64-linux-android-strip
		else
			STRIP=llvm-strip
		endif
	endif
	ifeq ($(arch),x86_64)
		CXX=x86_64-linux-android29-clang++
		ifneq ($(shell which x86_64-linux-android-strip 2>/dev/null),)
			STRIP=x86_64-linux-android-strip
		else
			STRIP=llvm-strip
		endif
	endif
	LDFLAGS += -static-libstdc++
endif

### Allow overwriting CXX from command line
ifdef COMPCXX
	CXX=$(COMPCXX)
endif

# llvm-profdata must be version compatible with the specified CXX (be it clang, or the gcc alias)
# make -j profile-build CXX=clang++-20 COMP=clang
# Locate the version in the same directory as the compiler used,
# with fallback to a generic one if it can't be located
	LLVM_PROFDATA := $(dir $(realpath $(shell which $(CXX) 2> /dev/null)))llvm-profdata
# for icx
ifeq ($(wildcard $(LLVM_PROFDATA)),)
	LLVM_PROFDATA := $(dir $(realpath $(shell which $(CXX) 2> /dev/null)))/compiler/llvm-profdata
endif
ifeq ($(wildcard $(LLVM_PROFDATA)),)
	LLVM_PROFDATA := llvm-profdata
endif

ifeq ($(comp),icx)
	profile_make = icx-profile-make
	profile_use = icx-profile-use
else ifeq ($(comp),clang)
	profile_make = clang-profile-make
	profile_use = clang-profile-use
else
	profile_make = gcc-profile-make
	profile_use = gcc-profile-use
	ifeq ($(KERNEL),Darwin)
		EXTRAPROFILEFLAGS = -fvisibility=hidden
	endif
endif

### Sometimes gcc is really clang
ifeq ($(COMP),gcc)
	gccversion := $(shell $(CXX) --version 2>/dev/null)
	gccisclang := $(findstring clang,$(gccversion))
	ifneq ($(gccisclang),)
		profile_make = clang-profile-make
		profile_use = clang-profile-use
	else
		CXXFLAGS += -Wstack-usage=128000
	endif
endif

### On mingw use Windows threads, otherwise POSIX
ifneq ($(comp),mingw)
	CXXFLAGS += -DUSE_PTHREADS
	# On Android Bionic's C library comes with its own pthread implementation bundled in
	ifneq ($(OS),Android)
		# Haiku has pthreads in its libroot, so only link it in on other platforms
		ifneq ($(KERNEL),Haiku)
			ifneq ($(COMP),ndk)
				LDFLAGS += -lpthread

				add_lrt = yes
				ifeq ($(target_windows),yes)
					add_lrt = no
				endif

				ifeq ($(KERNEL),Darwin)
					add_lrt = no
				endif

				ifeq ($(add_lrt),yes)
					LDFLAGS += -lrt
				endif
			endif
		endif
	endif
endif

### 3.2.1 Debugging
ifeq ($(debug),no)
	CXXFLAGS += -DNDEBUG
else
	CXXFLAGS += -g
	CXXFLAGS += -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG
endif

### 3.2.2 Debugging with undefined behavior sanitizers
ifneq ($(sanitize),none)
        CXXFLAGS += -g3 $(addprefix -fsanitize=,$(sanitize))
        LDFLAGS += $(addprefix -fsanitize=,$(sanitize))
endif

### 3.3 Optimization
ifeq ($(optimize),yes)

	CXXFLAGS += -O3 -funroll-loops

	ifeq ($(comp),gcc)
		ifeq ($(OS), Android)
			CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
		endif
	endif

	ifeq ($(KERNEL),Darwin)
		ifeq ($(comp),$(filter $(comp),clang icx))
			CXXFLAGS += -mdynamic-no-pic
		endif

		ifeq ($(comp),gcc)
			ifneq ($(arch),arm64)
				CXXFLAGS += -mdynamic-no-pic
			endif
		endif
	endif

	ifeq ($(comp),clang)
		clangmajorversion := $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
		ifeq ($(shell expr $(clangmajorversion) \< 16),1)
			CXXFLAGS += -fexperimental-new-pass-manager
		endif
	endif
endif

### 3.4 Bits
ifeq ($(bits),64)
	CXXFLAGS += -DIS_64BIT
endif

### 3.5 prefetch and popcount
ifeq ($(prefetch),yes)
	ifeq ($(sse),yes)
		CXXFLAGS += -msse
	endif
else
	CXXFLAGS += -DNO_PREFETCH
endif

ifeq ($(popcnt),yes)
	ifeq ($(arch),$(filter $(arch),ppc64 ppc64-altivec ppc64-vsx armv7 armv8 arm64))
		CXXFLAGS += -DUSE_POPCNT
	else
		CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
	endif
endif

### 3.6 SIMD architectures
ifeq ($(avx2),yes)
	CXXFLAGS += -DUSE_AVX2
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mavx2 -mbmi
	endif
endif

ifeq ($(avxvnni),yes)
	CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mavxvnni
	endif
endif

ifeq ($(avx512),yes)
	CXXFLAGS += -DUSE_AVX512
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mavx512f -mavx512bw -mavx512dq -mavx512vl
	endif
endif

ifeq ($(vnni512),yes)
	CXXFLAGS += -DUSE_VNNI
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mavx512f -mavx512bw -mavx512vnni -mavx512dq -mavx512vl
	endif
endif

ifeq ($(avx512icl),yes)
	CXXFLAGS += -DUSE_AVX512 -DUSE_VNNI -DUSE_AVX512ICL
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512ifma -mavx512vbmi -mavx512vbmi2 -mavx512vpopcntdq -mavx512bitalg -mavx512vnni -mvpclmulqdq -mgfni -mvaes
	endif
endif

ifeq ($(sse41),yes)
	CXXFLAGS += -DUSE_SSE41
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -msse4.1
	endif
endif

ifeq ($(ssse3),yes)
	CXXFLAGS += -DUSE_SSSE3
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mssse3
	endif
endif

ifeq ($(sse2),yes)
	CXXFLAGS += -DUSE_SSE2
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -msse2
	endif
endif

ifeq ($(mmx),yes)
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mmmx
	endif
endif

ifeq ($(altivec),yes)
	CXXFLAGS += -maltivec
	ifeq ($(COMP),gcc)
		CXXFLAGS += -mabi=altivec
	endif
endif

ifeq ($(vsx),yes)
	CXXFLAGS += -mvsx
	ifeq ($(COMP),gcc)
		CXXFLAGS += -DNO_WARN_X86_INTRINSICS -DUSE_SSE2
	endif
endif

ifeq ($(neon),yes)
	CXXFLAGS += -DUSE_NEON=$(arm_version)
	ifeq ($(KERNEL),Linux)
	ifneq ($(COMP),ndk)
	ifneq ($(arch),armv8)
		CXXFLAGS += -mfpu=neon
	endif
	endif
	endif
endif

ifeq ($(dotprod),yes)
	CXXFLAGS += -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD
endif

ifeq ($(lasx),yes)
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mlasx
	endif
endif

ifeq ($(lsx),yes)
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mlsx
	endif
endif

### 3.7 pext
ifeq ($(pext),yes)
	CXXFLAGS += -DUSE_PEXT
	ifeq ($(comp),$(filter $(comp),gcc clang mingw icx))
		CXXFLAGS += -mbmi2
	endif
endif

### 3.8.1 Try to include git info for versioning and avoid recompiles if nothing changes
BUILD_SHA_FILE  := .build_sha.txt
BUILD_DATE_FILE := .build_date.txt
GIT_SHA         := $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8 || true)
GIT_DATE        := $(shell git show -s --date=format:%Y%m%d --format=%cd HEAD 2>/dev/null || true)
COMPILER_DATE   := $(shell date +%Y%m%d 2>/dev/null)

BUILD_DATE      := $(if $(GIT_DATE),$(GIT_DATE),$(COMPILER_DATE))

define cache_file_contents
$(shell \
	if [ ! -f "$(1)" ] || [ "$$(cat "$(1)" 2>/dev/null)" != "$(2)" ]; then \
		printf '%s\n' "$(2)" > "$(1)"; \
	fi)
endef

ifneq ($(filter $(MAKECMDGOALS),help strip install clean net objclean profileclean format config-sanity),$(MAKECMDGOALS))
_ := $(call cache_file_contents,$(BUILD_SHA_FILE),$(GIT_SHA))
_ := $(call cache_file_contents,$(BUILD_DATE_FILE),$(BUILD_DATE))
endif

### 3.8.2 Try to include architecture
ifneq ($(ARCH), )
	CXXFLAGS += -DARCH=$(ARCH)
endif

### 3.9 Link Time Optimization
### This is a mix of compile and link time options because the lto link phase
### needs access to the optimization flags.
ifeq ($(optimize),yes)
ifeq ($(debug),no)
	ifneq ($(KERNEL),Darwin)
		LLD_BIN := $(shell command -v ld.lld 2>/dev/null)
		ifeq ($(LLD_BIN),)
			LLD_BIN := $(shell command -v lld 2>/dev/null)
		endif
		ifneq ($(LLD_BIN),)
			ifeq ($(comp),clang)
				LDFLAGS += -fuse-ld=lld
			else ifeq ($(comp),gcc)
				ifneq ($(gccisclang),)
					LDFLAGS += -fuse-ld=lld
				endif
			endif
		endif
	endif

	ifeq ($(comp),$(filter $(comp),clang icx))
		CXXFLAGS += -flto=full
		ifeq ($(comp),icx)
			CXXFLAGS += -fwhole-program-vtables
		endif
		LDFLAGS += $(CXXFLAGS)

# GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
# GCC on some systems.
	else ifeq ($(comp),gcc)
		ifeq ($(gccisclang),)
			CXXFLAGS += -flto -flto-partition=one
			LDFLAGS += $(CXXFLAGS) -flto=jobserver
		else
			CXXFLAGS += -flto=full
			LDFLAGS += $(CXXFLAGS)
		endif

# To use LTO and static linking on Windows,
# the tool chain requires gcc version 10.1 or later.
	else ifeq ($(comp),mingw)
		CXXFLAGS += -flto -flto-partition=one
		LDFLAGS += $(CXXFLAGS) -save-temps
	endif
endif
endif

### 3.10 Android 5 can only run position independent executables. Note that this
### breaks Android 4.0 and earlier.
ifeq ($(OS), Android)
	CXXFLAGS += -fPIE
	LDFLAGS += -fPIE -pie
endif

### 3.11 Inline settings
ifeq ($(optimize), yes)
	ifeq ($(comp), clang)
		CXXFLAGS += -Xclang -mllvm -Xclang -inline-threshold=500
	endif
endif

### ==========================================================================
### Section 4. Public Targets
### ==========================================================================

help:
	@echo "" && \
	echo "To compile stockfish, type: " && \
	echo "" && \
	echo "make -j target [ARCH=arch] [COMP=compiler] [COMPCXX=cxx]" && \
	echo "" && \
	echo "Supported targets:" && \
	echo "" && \
	echo "help                    > Display architecture details" && \
	echo "profile-build           > standard build with profile-guided optimization" && \
	echo "build                   > skip profile-guided optimization" && \
	echo "net                     > Download the default nnue nets" && \
	echo "strip                   > Strip executable" && \
	echo "install                 > Install executable" && \
	echo "clean                   > Clean up" && \
	echo "" && \
	echo "Supported archs:" && \
	echo "" && \
	echo "native                  > select the best architecture for the host processor (default)" && \
	echo "x86-64-avx512icl        > x86 64-bit with minimum avx512 support of Intel Ice Lake or AMD Zen 4" && \
	echo "x86-64-vnni512          > x86 64-bit with vnni 512bit support" && \
	echo "x86-64-avx512           > x86 64-bit with avx512 support" && \
	echo "x86-64-avxvnni          > x86 64-bit with vnni 256bit support" && \
	echo "x86-64-bmi2             > x86 64-bit with bmi2 support" && \
	echo "x86-64-avx2             > x86 64-bit with avx2 support" && \
	echo "x86-64-sse41-popcnt     > x86 64-bit with sse41 and popcnt support" && \
	echo "x86-64-modern           > deprecated, currently x86-64-sse41-popcnt" && \
	echo "x86-64-ssse3            > x86 64-bit with ssse3 support" && \
	echo "x86-64-sse3-popcnt      > x86 64-bit with sse3 compile and popcnt support" && \
	echo "x86-64                  > x86 64-bit generic (with sse2 support)" && \
	echo "x86-32-sse41-popcnt     > x86 32-bit with sse41 and popcnt support" && \
	echo "x86-32-sse2             > x86 32-bit with sse2 support" && \
	echo "x86-32                  > x86 32-bit generic (with mmx compile support)" && \
	echo "ppc-64                  > PPC 64-bit" && \
	echo "ppc-64-altivec          > PPC 64-bit with altivec support" && \
	echo "ppc-64-vsx              > PPC 64-bit with vsx support" && \
	echo "ppc-32                  > PPC 32-bit" && \
	echo "armv7                   > ARMv7 32-bit" && \
	echo "armv7-neon              > ARMv7 32-bit with popcnt and neon" && \
	echo "armv8                   > ARMv8 64-bit with popcnt and neon" && \
	echo "armv8-dotprod           > ARMv8 64-bit with popcnt, neon and dot product support" && \
	echo "e2k                     > Elbrus 2000" && \
	echo "apple-silicon           > Apple silicon ARM64" && \
	echo "general-64              > unspecified 64-bit" && \
	echo "general-32              > unspecified 32-bit" && \
	echo "riscv64                 > RISC-V 64-bit" && \
	echo "loongarch64             > LoongArch 64-bit" && \
	echo "loongarch64-lsx         > LoongArch 64-bit with SIMD eXtension" && \
	echo "loongarch64-lasx        > LoongArch 64-bit with Advanced SIMD eXtension" && \
	echo "" && \
	echo "Supported compilers:" && \
	echo "" && \
	echo "gcc                     > GNU compiler (default)" && \
	echo "mingw                   > GNU compiler with MinGW under Windows" && \
	echo "clang                   > LLVM Clang compiler" && \
	echo "icx                     > Intel oneAPI DPC++/C++ Compiler" && \
	echo "ndk                     > Google NDK to cross-compile for Android" && \
	echo "" && \
	echo "Simple examples. If you don't know what to do, you likely want to run one of: " && \
	echo "" && \
	echo "make -j profile-build ARCH=x86-64-avx2    # typically a fast compile for common systems " && \
	echo "make -j profile-build ARCH=x86-64-sse41-popcnt  # A more portable compile for 64-bit systems " && \
	echo "make -j profile-build ARCH=x86-64         # A portable compile for 64-bit systems " && \
	echo "" && \
	echo "Advanced examples, for experienced users: " && \
	echo "" && \
	echo "make -j profile-build ARCH=x86-64-avxvnni" && \
	echo "make -j profile-build ARCH=x86-64-avxvnni COMP=gcc COMPCXX=g++-12.0" && \
	echo "make -j build ARCH=x86-64-ssse3 COMP=clang" && \
	echo ""
ifneq ($(SUPPORTED_ARCH), true)
	@echo "Specify a supported architecture with the ARCH option for more details"
	@echo ""
endif


.PHONY: help analyze build profile-build strip install clean net \
	objclean profileclean config-sanity \
	icx-profile-use icx-profile-make \
	gcc-profile-use gcc-profile-make \
	clang-profile-use clang-profile-make FORCE \
	format analyze

analyze: net config-sanity objclean
	$(MAKE) -k ARCH=$(ARCH) COMP=$(COMP) $(OBJS)

build: net config-sanity
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) all

profile-build: net config-sanity objclean profileclean
	@echo ""
	@echo "Step 1/4. Building instrumented executable ..."
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
	@echo ""
	@echo "Step 2/4. Running benchmark for pgo-build ..."
	$(PGOBENCH) > PGOBENCH.out 2>&1
	tail -n 4 PGOBENCH.out
	@echo ""
	@echo "Step 3/4. Building optimized executable ..."
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use)
	@echo ""
	@echo "Step 4/4. Deleting profile data ..."
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean

strip:
	$(STRIP) $(EXE)

install:
	-mkdir -p -m 755 $(BINDIR)
	-cp $(EXE) $(BINDIR)
	$(STRIP) $(BINDIR)/$(EXE)

# clean all
clean: objclean profileclean
	@rm -f .depend *~ core

# clean binaries and objects
objclean:
	@rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o $(BUILD_SHA_FILE) $(BUILD_DATE_FILE)

# clean auxiliary profiling files
profileclean:
	@rm -rf profdir
	@rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s PGOBENCH.out
	@rm -f stockfish.profdata *.profraw
	@rm -f stockfish.*args*
	@rm -f stockfish.*lt*
	@rm -f stockfish.res
	@rm -f ./-lstdc++.res

# evaluation network (nnue)
net:
	@$(SHELL) ../scripts/net.sh

format:
	$(CLANG-FORMAT) -i $(SRCS) $(HEADERS) -style=file

### ==========================================================================
### Section 5. Private Targets
### ==========================================================================

all: $(EXE) .depend

config-sanity: net
	@echo ""
	@echo "Config:" && \
	echo "debug: '$(debug)'" && \
	echo "sanitize: '$(sanitize)'" && \
	echo "optimize: '$(optimize)'" && \
	echo "arch: '$(arch)'" && \
	echo "bits: '$(bits)'" && \
	echo "kernel: '$(KERNEL)'" && \
	echo "os: '$(OS)'" && \
	echo "prefetch: '$(prefetch)'" && \
	echo "popcnt: '$(popcnt)'" && \
	echo "pext: '$(pext)'" && \
	echo "sse: '$(sse)'" && \
	echo "mmx: '$(mmx)'" && \
	echo "sse2: '$(sse2)'" && \
	echo "ssse3: '$(ssse3)'" && \
	echo "sse41: '$(sse41)'" && \
	echo "avx2: '$(avx2)'" && \
	echo "avxvnni: '$(avxvnni)'" && \
	echo "avx512: '$(avx512)'" && \
	echo "vnni512: '$(vnni512)'" && \
	echo "avx512icl: '$(avx512icl)'" && \
	echo "altivec: '$(altivec)'" && \
	echo "vsx: '$(vsx)'" && \
	echo "neon: '$(neon)'" && \
	echo "dotprod: '$(dotprod)'" && \
	echo "arm_version: '$(arm_version)'" && \
	echo "lsx: '$(lsx)'" && \
	echo "lasx: '$(lasx)'" && \
	echo "target_windows: '$(target_windows)'" && \
	echo "" && \
	echo "Flags:" && \
	echo "CXX: $(CXX)" && \
	echo "CXXFLAGS: $(CXXFLAGS)" && \
	echo "LDFLAGS: $(LDFLAGS)" && \
	echo "" && \
	echo "Testing config sanity. If this fails, try 'make help' ..." && \
	echo "" && \
	(test "$(debug)" = "yes" || test "$(debug)" = "no") && \
	(test "$(optimize)" = "yes" || test "$(optimize)" = "no") && \
	(test "$(SUPPORTED_ARCH)" = "true") && \
	(test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
	 test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
	 test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || \
	 test "$(arch)" = "riscv64" || test "$(arch)" = "loongarch64") && \
	(test "$(bits)" = "32" || test "$(bits)" = "64") && \
	(test "$(prefetch)" = "yes" || test "$(prefetch)" = "no") && \
	(test "$(popcnt)" = "yes" || test "$(popcnt)" = "no") && \
	(test "$(pext)" = "yes" || test "$(pext)" = "no") && \
	(test "$(sse)" = "yes" || test "$(sse)" = "no") && \
	(test "$(mmx)" = "yes" || test "$(mmx)" = "no") && \
	(test "$(sse2)" = "yes" || test "$(sse2)" = "no") && \
	(test "$(ssse3)" = "yes" || test "$(ssse3)" = "no") && \
	(test "$(sse41)" = "yes" || test "$(sse41)" = "no") && \
	(test "$(avx2)" = "yes" || test "$(avx2)" = "no") && \
	(test "$(avx512)" = "yes" || test "$(avx512)" = "no") && \
	(test "$(vnni512)" = "yes" || test "$(vnni512)" = "no") && \
	(test "$(avx512icl)" = "yes" || test "$(avx512icl)" = "no") && \
	(test "$(altivec)" = "yes" || test "$(altivec)" = "no") && \
	(test "$(vsx)" = "yes" || test "$(vsx)" = "no") && \
	(test "$(neon)" = "yes" || test "$(neon)" = "no") && \
	(test "$(lsx)" = "yes" || test "$(lsx)" = "no") && \
	(test "$(lasx)" = "yes" || test "$(lasx)" = "no") && \
	(test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || \
	 test "$(comp)" = "clang" || test "$(comp)" = "armv7a-linux-androideabi16-clang" || \
	 test "$(comp)" = "aarch64-linux-android21-clang")

$(EXE): $(OBJS)
	+$(CXX) -o $@ $(OBJS) $(LDFLAGS)

%.o: %.cpp
	$(strip $(CXX) $(CPPFLAGS) $(CXXFLAGS)) -c -o $@ $<

# Cache git metadata when available, otherwise cache the compiler date.
misc.o: misc.cpp $(BUILD_SHA_FILE) $(BUILD_DATE_FILE)
	@sha="$$(cat $(BUILD_SHA_FILE))"; \
	set -- $(CXX) $(CPPFLAGS) $(CXXFLAGS); \
	test -n "$$sha"  && set -- "$$@" -DGIT_SHA=$$sha; \
	test -n "$(GIT_DATE)" && set -- "$$@" -DGIT_DATE=$(GIT_DATE); \
	set -- "$$@" -c $< -o $@; \
	printf '%s ' "$$@"; \
	printf '\n'; \
	"$$@"

clang-profile-make:
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-generate ' \
	EXTRALDFLAGS=' -fprofile-generate' \
	all

clang-profile-use:
	$(XCRUN) $(LLVM_PROFDATA) merge -output=stockfish.profdata *.profraw
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-use=stockfish.profdata' \
	EXTRALDFLAGS='-fprofile-use ' \
	all

gcc-profile-make:
	@mkdir -p profdir
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-generate=profdir' \
	EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
	EXTRALDFLAGS='-lgcov' \
	all

gcc-profile-use:
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
	EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
	EXTRALDFLAGS='-lgcov' \
	all

icx-profile-make:
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-instr-generate ' \
	EXTRALDFLAGS=' -fprofile-instr-generate' \
	all

icx-profile-use:
	$(XCRUN) $(LLVM_PROFDATA) merge -output=stockfish.profdata *.profraw
	$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
	EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
	EXTRALDFLAGS='-fprofile-use ' \
	all

.depend: $(SRCS)
	-@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null

ifeq (, $(filter $(MAKECMDGOALS), help strip install clean net objclean profileclean format config-sanity))
-include .depend
endif


================================================
FILE: src/benchmark.cpp
================================================
/*
  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
  Copyright (C) 2004-2026 The Stockfish developers (see AUTHORS file)

  Stockfish is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Stockfish is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "benchmark.h"
#include "numa.h"

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>

namespace {

// clang-format off
const std::vector<std::string> Defaults = {
  "setoption name UCI_Chess960 value false",
  "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
  "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 10",
  "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 11",
  "4rrk1/pp1n3p/3q2pQ/2p1pb2/2PP4/2P3N1/P2B2PP/4RRK1 b - - 7 19",
  "rq3rk1/ppp2ppp/1bnpb3/3N2B1/3NP3/7P/PPPQ1PP1/2KR3R w - - 7 14 moves d4e6",
  "r1bq1r1k/1pp1n1pp/1p1p4/4p2Q/4Pp2/1BNP4/PPP2PPP/3R1RK1 w - - 2 14 moves g2g4",
  "r3r1k1/2p2ppp/p1p1bn2/8/1q2P3/2NPQN2/PPP3PP/R4RK1 b - - 2 15",
  "r1bbk1nr/pp3p1p/2n5/1N4p1/2Np1B2/8/PPP2PPP/2KR1B1R w kq - 0 13",
  "r1bq1rk1/ppp1nppp/4n3/3p3Q/3P4/1BP1B3/PP1N2PP/R4RK1 w - - 1 16",
  "4r1k1/r1q2ppp/ppp2n2/4P3/5Rb1/1N1BQ3/PPP3PP/R5K1 w - - 1 17",
  "2rqkb1r/ppp2p2/2npb1p1/1N1Nn2p/2P1PP2/8/PP2B1PP/R1BQK2R b KQ - 0 11",
  "r1bq1r1k/b1p1npp1/p2p3p/1p6/3PP3/1B2NN2/PP3PPP/R2Q1RK1 w - - 1 16",
  "3r1rk1/p5pp/bpp1pp2/8/q1PP1P2/b3P3/P2NQRPP/1R2B1K1 b - - 6 22",
  "r1q2rk1/2p1bppp/2Pp4/p6b/Q1PNp3/4B3/PP1R1PPP/2K4R w - - 2 18",
  "4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - - 3 22",
  "3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26",
  "6k1/6p1/6Pp/ppp5/3pn2P/1P3K2/1PP2P2/3N4 b - - 0 1",
  "3b4/5kp1/1p1p1p1p/pP1PpP1P/P1P1P3/3KN3/8/8 w - - 0 1",
  "2K5/p7/7P/5pR1/8/5k2/r7/8 w - - 0 1 moves g5g6 f3e3 g6g5 e3f3",
  "8/6pk/1p6/8/PP3p1p/5P2/4KP1q/3Q4 w - - 0 1",
  "7k/3p2pp/4q3/8/4Q3/5Kp1/P6b/8 w - - 0 1",
  "8/2p5/8/2kPKp1p/2p4P/2P5/3P4/8 w - - 0 1",
  "8/1p3pp1/7p/5P1P/2k3P1/8/2K2P2/8 w - - 0 1",
  "8/pp2r1k1/2p1p3/3pP2p/1P1P1P1P/P5KR/8/8 w - - 0 1",
  "8/3p4/p1bk3p/Pp6/1Kp1PpPp/2P2P1P/2P5/5B2 b - - 0 1",
  "5k2/7R/4P2p/5K2/p1r2P1p/8/8/8 b - - 0 1",
  "6k1/6p1/P6p/r1N5/5p2/7P/1b3PP1/4R1K1 w - - 0 1",
  "1r3k2/4q3/2Pp3b/3Bp3/2Q2p2/1p1P2P1/1P2KP2/3N4 w - - 0 1",
  "6k1/4pp1p/3p2p1/P1pPb3/R7/1r2P1PP/3B1P2/6K1 w - - 0 1",
  "8/3p3B/5p2/5P2/p7/PP5b/k7/6K1 w - - 0 1",
  "5rk1/q6p/2p3bR/1pPp1rP1/1P1Pp3/P3B1Q1/1K3P2/R7 w - - 93 90",
  "4rrk1/1p1nq3/p7/2p1P1pp/3P2bp/3Q1Bn1/PPPB4/1K2R1NR w - - 40 21",
  "r3k2r/3nnpbp/q2pp1p1/p7/Pp1PPPP1/4BNN1/1P5P/R2Q1RK1 w kq - 0 16",
  "3Qb1k1/1r2ppb1/pN1n2q1/Pp1Pp1Pr/4P2p/4BP2/4B1R1/1R5K b - - 11 40",
  "4k3/3q1r2/1N2r1b1/3ppN2/2nPP3/1B1R2n1/2R1Q3/3K4 w - - 5 1",
  "1r6/1P4bk/3qr1p1/N6p/3pp2P/6R1/3Q1PP1/1R4K1 w - - 1 42",

  // Positions with high numbers of changed threats
  "k7/2n1n3/1nbNbn2/2NbRBn1/1nbRQR2/2NBRBN1/3N1N2/7K w - - 0 1",
  "K7/8/8/BNQNQNB1/N5N1/R1Q1q2r/n5n1/bnqnqnbk w - - 0 1",

  // 5-man positions
  "8/8/8/8/5kp1/P7/8/1K1N4 w - - 0 1",     // Kc2 - mate
  "8/8/8/5N2/8/p7/8/2NK3k w - - 0 1",      // Na2 - mate
  "8/3k4/8/8/8/4B3/4KB2/2B5 w - - 0 1",    // draw

  // 6-man positions
  "8/8/1P6/5pr1/8/4R3/7k/2K5 w - - 0 1",   // Re5 - mate
  "8/2p4P/8/kr6/6R1/8/8/1K6 w - - 0 1",    // Ka2 - mate
  "8/8/3P3k/8/1p6/8/1P6/1K3n2 b - - 0 1",  // Nd2 - draw

  // 7-man positions
  "8/R7/2q5/8/6k1/8/1P5p/K6R w - - 0 124", // Draw

  // Mate and stalemate positions
  "6k1/3b3r/1p1p4/p1n2p2/1PPNpP1q/P3Q1p1/1R1RB1P1/5K2 b - - 0 1",
  "r2r1n2/pp2bk2/2p1p2p/3q4/3PN1QP/2P3R1/P4PP1/5RK1 w - - 0 1",
  "8/8/8/8/8/6k1/6p1/6K1 w - -",
  "7k/7P/6K1/8/3B4/8/8/8 b - -",

  // Chess 960
  "setoption name UCI_Chess960 value true",
  "bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w HFhf - 0 1 moves g2g3 d7d5 d2d4 c8h3 c1g5 e8d6 g5e7 f7f6",
  "nqbnrkrb/pppppppp/8/8/8/8/PPPPPPPP/NQBNRKRB w KQkq - 0 1",
  "setoption name UCI_Chess960 value false"
};
// clang-format on

// clang-format off
// human-randomly picked 5 games with <60 moves from
// https://tests.stockfishchess.org/tests/view/665c71f9fd45fb0f907c21e0
// only moves for one side
const std::vector<std::vector<std::string>> BenchmarkPositions = {
    {
        "rnbq1k1r/ppp1bppp/4pn2/8/2B5/2NP1N2/PPP2PPP/R1BQR1K1 b - - 2 8",
        "rnbq1k1r/pp2bppp/4pn2/2p5/2B2B2/2NP1N2/PPP2PPP/R2QR1K1 b - - 1 9",
        "r1bq1k1r/pp2bppp/2n1pn2/2p5/2B1NB2/3P1N2/PPP2PPP/R2QR1K1 b - - 3 10",
        "r1bq1k1r/pp2bppp/2n1p3/2p5/2B1PB2/5N2/PPP2PPP/R2QR1K1 b - - 0 11",
        "r1b2k1r/pp2bppp/2n1p3/2p5/2B1PB2/5N2/PPP2PPP/3RR1K1 b - - 0 12",
        "r1b1k2r/pp2bppp/2n1p3/2p5/2B1PB2/2P2N2/PP3PPP/3RR1K1 b - - 0 13",
        "r1b1k2r/1p2bppp/p1n1p3/2p5/4PB2/2P2N2/PP2BPPP/3RR1K1 b - - 1 14",
        "r1b1k2r/4bppp/p1n1p3/1pp5/P3PB2/2P2N2/1P2BPPP/3RR1K1 b - - 0 15",
        "r1b1k2r/4bppp/p1n1p3/1P6/2p1PB2/2P2N2/1P2BPPP/3RR1K1 b - - 0 16",
        "r1b1k2r/4bppp/2n1p3/1p6/2p1PB2/1PP2N2/4BPPP/3RR1K1 b - - 0 17",
        "r3k2r/3bbppp/2n1p3/1p6/2P1PB2/2P2N2/4BPPP/3RR1K1 b - - 0 18",
        "r3k2r/3bbppp/2n1p3/8/1pP1P3/2P2N2/3BBPPP/3RR1K1 b - - 1 19",
        "1r2k2r/3bbppp/2n1p3/8/1pPNP3/2P5/3BBPPP/3RR1K1 b - - 3 20",
        "1r2k2r/3bbppp/2n1p3/8/2PNP3/2B5/4BPPP/3RR1K1 b - - 0 21",
        "1r2k2r/3bb1pp/2n1pp2/1N6/2P1P3/2B5/4BPPP/3RR1K1 b - - 1 22",
        "1r2k2r/3b2pp/2n1pp2/1N6/1BP1P3/8/4BPPP/3RR1K1 b - - 0 23",
        "1r2k2r/3b2pp/4pp2/1N6/1nP1P3/8/3RBPPP/4R1K1 b - - 1 24",
        "1r5r/3bk1pp/4pp2/1N6/1nP1PP2/8/3RB1PP/4R1K1 b - - 0 25",
        "1r5r/3bk1pp/2n1pp2/1N6/2P1PP2/8/3RBKPP/4R3 b - - 2 26",
        "1r5r/3bk1pp/2n2p2/1N2p3/2P1PP2/6P1/3RBK1P/4R3 b - - 0 27",
        "1r1r4/3bk1pp/2n2p2/1N2p3/2P1PP2/6P1/3RBK1P/R7 b - - 2 28",
        "1r1r4/N3k1pp/2n1bp2/4p3/2P1PP2/6P1/3RBK1P/R7 b - - 4 29",
        "1r1r4/3bk1pp/2N2p2/4p3/2P1PP2/6P1/3RBK1P/R7 b - - 0 30",
        "1r1R4/4k1pp/2b2p2/4p3/2P1PP2/6P1/4BK1P/R7 b - - 0 31",
        "3r4/4k1pp/2b2p2/4P3/2P1P3/6P1/4BK1P/R7 b - - 0 32",
        "3r4/R3k1pp/2b5/4p3/2P1P3/6P1/4BK1P/8 b - - 1 33",
        "8/3rk1pp/2b5/R3p3/2P1P3/6P1/4BK1P/8 b - - 3 34",
        "8/3r2pp/2bk4/R1P1p3/4P3/6P1/4BK1P/8 b - - 0 35",
        "8/2kr2pp/2b5/R1P1p3/4P3/4K1P1/4B2P/8 b - - 2 36",
        "1k6/3r2pp/2b5/RBP1p3/4P3/4K1P1/7P/8 b - - 4 37",
        "8/1k1r2pp/2b5/R1P1p3/4P3/3BK1P1/7P/8 b - - 6 38",
        "1k6/3r2pp/2b5/2P1p3/4P3/3BK1P1/7P/R7 b - - 8 39",
        "1k6/r5pp/2b5/2P1p3/4P3/3BK1P1/7P/5R2 b - - 10 40",
        "1k3R2/6pp/2b5/2P1p3/4P3/r2BK1P1/7P/8 b - - 12 41",
        "5R2/2k3pp/2b5/2P1p3/4P3/r2B2P1/3K3P/8 b - - 14 42",
        "5R2/2k3pp/2b5/2P1p3/4P3/3BK1P1/r6P/8 b - - 16 43",
        "5R2/2k3pp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 18 44",
        "5R2/2k3pp/2b5/2P1p3/4P3/3B1KP1/r6P/8 b - - 20 45",
        "8/2k2Rpp/2b5/2P1p3/4P3/r2B1KP1/7P/8 b - - 22 46",
        "3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 24 47",
        "3k4/5Rpp/2b5/2P1p3/4P3/3B1KP1/r6P/8 b - - 26 48",
        "3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 28 49",
        "3k4/5Rpp/2b5/2P1p3/4P3/3BK1P1/r6P/8 b - - 30 50",
        "3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/3K3P/8 b - - 32 51",
        "3k4/5Rpp/2b5/2P1p3/4P3/2KB2P1/r6P/8 b - - 34 52",
        "3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/2K4P/8 b - - 36 53",
        "3k4/5Rpp/2b5/2P1p3/4P3/1K1B2P1/r6P/8 b - - 38 54",
        "3k4/6Rp/2b5/2P1p3/4P3/1K1B2P1/7r/8 b - - 0 55",
        "3k4/8/2b3Rp/2P1p3/4P3/1K1B2P1/7r/8 b - - 1 56",
        "8/2k3R1/2b4p/2P1p3/4P3/1K1B2P1/7r/8 b - - 3 57",
        "3k4/8/2b3Rp/2P1p3/4P3/1K1B2P1/7r/8 b - - 5 58",
        "8/2k5/2b3Rp/2P1p3/1K2P3/3B2P1/7r/8 b - - 7 59",
        "8/2k5/2b3Rp/2P1p3/4P3/2KB2P1/3r4/8 b - - 9 60",
        "8/2k5/2b3Rp/2P1p3/1K2P3/3B2P1/6r1/8 b - - 11 61",
        "8/2k5/2b3Rp/2P1p3/4P3/2KB2P1/3r4/8 b - - 13 62",
        "8/2k5/2b3Rp/2P1p3/2K1P3/3B2P1/6r1/8 b - - 15 63",
        "4b3/2k3R1/7p/2P1p3/2K1P3/3B2P1/6r1/8 b - - 17 64",
    },
    {
        "r1bqkbnr/npp1pppp/p7/3P4/4pB2/2N5/PPP2PPP/R2QKBNR w KQkq - 1 6",
        "r1bqkb1r/npp1pppp/p4n2/3P4/4pB2/2N5/PPP1QPPP/R3KBNR w KQkq - 3 7",
        "r2qkb1r/npp1pppp/p4n2/3P1b2/4pB2/2N5/PPP1QPPP/2KR1BNR w kq - 5 8",
        "r2qkb1r/1pp1pppp/p4n2/1n1P1b2/4pB2/2N4P/PPP1QPP1/2KR1BNR w kq - 1 9",
        "r2qkb1r/1pp1pppp/5n2/1p1P1b2/4pB2/7P/PPP1QPP1/2KR1BNR w kq - 0 10",
        "r2qkb1r/1ppbpppp/5n2/1Q1P4/4pB2/7P/PPP2PP1/2KR1BNR w kq - 1 11",
        "3qkb1r/1Qpbpppp/5n2/3P4/4pB2/7P/rPP2PP1/2KR1BNR w k - 0 12",
        "q3kb1r/1Qpbpppp/5n2/3P4/4pB2/7P/rPP2PP1/1K1R1BNR w k - 2 13",
        "r3kb1r/2pbpppp/5n2/3P4/4pB2/7P/1PP2PP1/1K1R1BNR w k - 0 14",
        "r3kb1r/2Bb1ppp/4pn2/3P4/4p3/7P/1PP2PP1/1K1R1BNR w k - 0 15",
        "r3kb1r/2Bb2pp/4pn2/8/4p3/7P/1PP2PP1/1K1R1BNR w k - 0 16",
        "r3k2r/2Bb2pp/4pn2/2b5/4p3/7P/1PP1NPP1/1K1R1B1R w k - 2 17",
        "r6r/2Bbk1pp/4pn2/2b5/3Np3/7P/1PP2PP1/1K1R1B1R w - - 4 18",
        "r6r/b2bk1pp/4pn2/4B3/3Np3/7P/1PP2PP1/1K1R1B1R w - - 6 19",
        "r1r5/b2bk1pp/4pn2/4B3/2BNp3/7P/1PP2PP1/1K1R3R w - - 8 20",
        "r7/b2bk1pp/4pn2/2r1B3/2BNp3/1P5P/2P2PP1/1K1R3R w - - 1 21",
        "rb6/3bk1pp/4pn2/2r1B3/2BNpP2/1P5P/2P3P1/1K1R3R w - - 1 22",
        "1r6/3bk1pp/4pn2/2r5/2BNpP2/1P5P/2P3P1/1K1R3R w - - 0 23",
        "1r6/3bk1p1/4pn1p/2r5/2BNpP2/1P5P/2P3P1/2KR3R w - - 0 24",
        "8/3bk1p1/1r2pn1p/2r5/2BNpP1P/1P6/2P3P1/2KR3R w - - 1 25",
        "8/3bk3/1r2pnpp/2r5/2BNpP1P/1P6/2P3P1/2K1R2R w - - 0 26",
        "2b5/4k3/1r2pnpp/2r5/2BNpP1P/1P4P1/2P5/2K1R2R w - - 1 27",
        "8/1b2k3/1r2pnpp/2r5/2BNpP1P/1P4P1/2P5/2K1R1R1 w - - 3 28",
        "8/1b1nk3/1r2p1pp/2r5/2BNpPPP/1P6/2P5/2K1R1R1 w - - 1 29",
        "8/1b2k3/1r2p1pp/2r1nP2/2BNp1PP/1P6/2P5/2K1R1R1 w - - 1 30",
        "8/1b2k3/1r2p1p1/2r1nPp1/2BNp2P/1P6/2P5/2K1R1R1 w - - 0 31",
        "8/1b2k3/1r2p1n1/2r3p1/2BNp2P/1P6/2P5/2K1R1R1 w - - 0 32",
        "8/1b2k3/1r2p1n1/6r1/2BNp2P/1P6/2P5/2K1R3 w - - 0 33",
        "8/1b2k3/1r2p3/4n1P1/2BNp3/1P6/2P5/2K1R3 w - - 1 34",
        "8/1b2k3/1r2p3/4n1P1/2BN4/1P2p3/2P5/2K4R w - - 0 35",
        "8/1b2k3/1r2p2R/6P1/2nN4/1P2p3/2P5/2K5 w - - 0 36",
        "8/1b2k3/3rp2R/6P1/2PN4/4p3/2P5/2K5 w - - 1 37",
        "8/4k3/3rp2R/6P1/2PN4/2P1p3/6b1/2K5 w - - 1 38",
        "8/4k3/r3p2R/2P3P1/3N4/2P1p3/6b1/2K5 w - - 1 39",
        "8/3k4/r3p2R/2P2NP1/8/2P1p3/6b1/2K5 w - - 3 40",
        "8/3k4/4p2R/2P3P1/8/2P1N3/6b1/r1K5 w - - 1 41",
        "8/3k4/4p2R/2P3P1/8/2P1N3/3K2b1/6r1 w - - 3 42",
        "8/3k4/4p2R/2P3P1/8/2PKNb2/8/6r1 w - - 5 43",
        "8/4k3/4p1R1/2P3P1/8/2PKNb2/8/6r1 w - - 7 44",
        "8/4k3/4p1R1/2P3P1/3K4/2P1N3/8/6rb w - - 9 45",
        "8/3k4/4p1R1/2P1K1P1/8/2P1N3/8/6rb w - - 11 46",
        "8/3k4/4p1R1/2P3P1/5K2/2P1N3/8/4r2b w - - 13 47",
        "8/3k4/2b1p2R/2P3P1/5K2/2P1N3/8/4r3 w - - 15 48",
        "8/3k4/2b1p3/2P3P1/5K2/2P1N2R/8/6r1 w - - 17 49",
        "2k5/7R/2b1p3/2P3P1/5K2/2P1N3/8/6r1 w - - 19 50",
        "2k5/7R/4p3/2P3P1/b1P2K2/4N3/8/6r1 w - - 1 51",
        "2k5/3bR3/4p3/2P3P1/2P2K2/4N3/8/6r1 w - - 3 52",
        "3k4/3b2R1/4p3/2P3P1/2P2K2/4N3/8/6r1 w - - 5 53",
        "3kb3/6R1/4p1P1/2P5/2P2K2/4N3/8/6r1 w - - 1 54",
        "3kb3/6R1/4p1P1/2P5/2P2KN1/8/8/2r5 w - - 3 55",
        "3kb3/6R1/4p1P1/2P1N3/2P2K2/8/8/5r2 w - - 5 56",
        "3kb3/6R1/4p1P1/2P1N3/2P5/4K3/8/4r3 w - - 7 57",
    },
    {
        "rnbq1rk1/ppp1npb1/4p1p1/3P3p/3PP3/2N2N2/PP2BPPP/R1BQ1RK1 b - - 0 8",
        "rnbq1rk1/ppp1npb1/6p1/3pP2p/3P4/2N2N2/PP2BPPP/R1BQ1RK1 b - - 0 9",
        "rn1q1rk1/ppp1npb1/6p1/3pP2p/3P2b1/2N2N2/PP2BPPP/R1BQR1K1 b - - 2 10",
        "r2q1rk1/ppp1npb1/2n3p1/3pP2p/3P2bN/2N5/PP2BPPP/R1BQR1K1 b - - 4 11",
        "r4rk1/pppqnpb1/2n3p1/3pP2p/3P2bN/2N4P/PP2BPP1/R1BQR1K1 b - - 0 12",
        "r4rk1/pppqnpb1/2n3p1/3pP2p/3P3N/7P/PP2NPP1/R1BQR1K1 b - - 0 13",
        "r4rk1/pppq1pb1/2n3p1/3pPN1p/3P4/7P/PP2NPP1/R1BQR1K1 b - - 0 14",
        "r4rk1/ppp2pb1/2n3p1/3pPq1p/3P1N2/7P/PP3PP1/R1BQR1K1 b - - 1 15",
        "r4rk1/pppq1pb1/2n3p1/3pP2p/P2P1N2/7P/1P3PP1/R1BQR1K1 b - - 0 16",
        "r2n1rk1/pppq1pb1/6p1/3pP2p/P2P1N2/R6P/1P3PP1/2BQR1K1 b - - 2 17",
        "r4rk1/pppq1pb1/4N1p1/3pP2p/P2P4/R6P/1P3PP1/2BQR1K1 b - - 0 18",
        "r4rk1/ppp2pb1/4q1p1/3pP1Bp/P2P4/R6P/1P3PP1/3QR1K1 b - - 1 19",
        "r3r1k1/ppp2pb1/4q1p1/3pP1Bp/P2P1P2/R6P/1P4P1/3QR1K1 b - - 0 20",
        "r3r1k1/ppp3b1/4qpp1/3pP2p/P2P1P1B/R6P/1P4P1/3QR1K1 b - - 1 21",
        "r3r1k1/ppp3b1/4q1p1/3pP2p/P4P1B/R6P/1P4P1/3QR1K1 b - - 0 22",
        "r4rk1/ppp3b1/4q1p1/3pP1Bp/P4P2/R6P/1P4P1/3QR1K1 b - - 2 23",
        "r4rk1/pp4b1/4q1p1/2ppP1Bp/P4P2/3R3P/1P4P1/3QR1K1 b - - 1 24",
        "r4rk1/pp4b1/4q1p1/2p1P1Bp/P2p1PP1/3R3P/1P6/3QR1K1 b - - 0 25",
        "r4rk1/pp4b1/4q1p1/2p1P1B1/P2p1PP1/3R4/1P6/3QR1K1 b - - 0 26",
        "r5k1/pp3rb1/4q1p1/2p1P1B1/P2p1PP1/6R1/1P6/3QR1K1 b - - 2 27",
        "5rk1/pp3rb1/4q1p1/2p1P1B1/P2pRPP1/6R1/1P6/3Q2K1 b - - 4 28",
        "5rk1/1p3rb1/p3q1p1/P1p1P1B1/3pRPP1/6R1/1P6/3Q2K1 b - - 0 29",
        "4r1k1/1p3rb1/p3q1p1/P1p1P1B1/3pRPP1/1P4R1/8/3Q2K1 b - - 0 30",
        "4r1k1/5rb1/pP2q1p1/2p1P1B1/3pRPP1/1P4R1/8/3Q2K1 b - - 0 31",
        "4r1k1/5rb1/pq4p1/2p1P1B1/3pRPP1/1P4R1/4Q3/6K1 b - - 1 32",
        "4r1k1/1r4b1/pq4p1/2p1P1B1/3pRPP1/1P4R1/2Q5/6K1 b - - 3 33",
        "4r1k1/1r4b1/1q4p1/p1p1P1B1/3p1PP1/1P4R1/2Q5/4R1K1 b - - 1 34",
        "4r1k1/3r2b1/1q4p1/p1p1P1B1/2Qp1PP1/1P4R1/8/4R1K1 b - - 3 35",
        "4r1k1/3r2b1/4q1p1/p1p1P1B1/2Qp1PP1/1P4R1/5K2/4R3 b - - 5 36",
        "4r1k1/3r2b1/6p1/p1p1P1B1/2Pp1PP1/6R1/5K2/4R3 b - - 0 37",
        "4r1k1/3r2b1/6p1/p1p1P1B1/2P2PP1/3p2R1/5K2/3R4 b - - 1 38",
        "5rk1/3r2b1/6p1/p1p1P1B1/2P2PP1/3p2R1/8/3RK3 b - - 3 39",
        "5rk1/6b1/6p1/p1p1P1B1/2Pr1PP1/3R4/8/3RK3 b - - 0 40",
        "5rk1/3R2b1/6p1/p1p1P1B1/2r2PP1/8/8/3RK3 b - - 1 41",
        "5rk1/3R2b1/6p1/p1p1P1B1/4rPP1/8/3K4/3R4 b - - 3 42",
        "1r4k1/3R2b1/6p1/p1p1P1B1/4rPP1/2K5/8/3R4 b - - 5 43",
        "1r4k1/3R2b1/6p1/p1p1P1B1/2K2PP1/4r3/8/3R4 b - - 7 44",
        "1r3bk1/8/3R2p1/p1p1P1B1/2K2PP1/4r3/8/3R4 b - - 9 45",
        "1r3bk1/8/6R1/2p1P1B1/p1K2PP1/4r3/8/3R4 b - - 0 46",
        "1r3b2/5k2/R7/2p1P1B1/p1K2PP1/4r3/8/3R4 b - - 2 47",
        "5b2/1r3k2/R7/2p1P1B1/p1K2PP1/4r3/8/7R b - - 4 48",
        "5b2/5k2/R7/2pKP1B1/pr3PP1/4r3/8/7R b - - 6 49",
        "5b2/5k2/R1K5/2p1P1B1/p2r1PP1/4r3/8/7R b - - 8 50",
        "8/R4kb1/2K5/2p1P1B1/p2r1PP1/4r3/8/7R b - - 10 51",
        "8/R5b1/2K3k1/2p1PPB1/p2r2P1/4r3/8/7R b - - 0 52",
        "8/6R1/2K5/2p1PPk1/p2r2P1/4r3/8/7R b - - 0 53",
        "8/6R1/2K5/2p1PP2/p2r1kP1/4r3/8/5R2 b - - 2 54",
        "8/6R1/2K2P2/2p1P3/p2r2P1/4r1k1/8/5R2 b - - 0 55",
        "8/5PR1/2K5/2p1P3/p2r2P1/4r3/6k1/5R2 b - - 0 56",
    },
    {
        "rn1qkb1r/p1pbpppp/5n2/8/2pP4/2N5/1PQ1PPPP/R1B1KBNR w KQkq - 0 7",
        "r2qkb1r/p1pbpppp/2n2n2/8/2pP4/2N2N2/1PQ1PPPP/R1B1KB1R w KQkq - 2 8",
        "r2qkb1r/p1pbpppp/5n2/8/1npPP3/2N2N2/1PQ2PPP/R1B1KB1R w KQkq - 1 9",
        "r2qkb1r/p1pb1ppp/4pn2/8/1npPP3/2N2N2/1P3PPP/R1BQKB1R w KQkq - 0 10",
        "r2qk2r/p1pbbppp/4pn2/8/1nBPP3/2N2N2/1P3PPP/R1BQK2R w KQkq - 1 11",
        "r2q1rk1/p1pbbppp/4pn2/8/1nBPP3/2N2N2/1P3PPP/R1BQ1RK1 w - - 3 12",
        "r2q1rk1/2pbbppp/p3pn2/8/1nBPPB2/2N2N2/1P3PPP/R2Q1RK1 w - - 0 13",
        "r2q1rk1/2p1bppp/p3pn2/1b6/1nBPPB2/2N2N2/1P3PPP/R2QR1K1 w - - 2 14",
        "r2q1rk1/4bppp/p1p1pn2/1b6/1nBPPB2/1PN2N2/5PPP/R2QR1K1 w - - 0 15",
        "r4rk1/3qbppp/p1p1pn2/1b6/1nBPPB2/1PN2N2/3Q1PPP/R3R1K1 w - - 2 16",
        "r4rk1/1q2bppp/p1p1pn2/1b6/1nBPPB2/1PN2N1P/3Q1PP1/R3R1K1 w - - 1 17",
        "r3r1k1/1q2bppp/p1p1pn2/1b6/1nBPPB2/1PN2N1P/4QPP1/R3R1K1 w - - 3 18",
        "r3r1k1/1q1nbppp/p1p1p3/1b6/1nBPPB2/1PN2N1P/4QPP1/3RR1K1 w - - 5 19",
        "r3rbk1/1q1n1ppp/p1p1p3/1b6/1nBPPB2/1PN2N1P/3RQPP1/4R1K1 w - - 7 20",
        "r3rbk1/1q3ppp/pnp1p3/1b6/1nBPPB2/1PN2N1P/3RQPP1/4R2K w - - 9 21",
        "2r1rbk1/1q3ppp/pnp1p3/1b6/1nBPPB2/1PN2N1P/3RQPP1/1R5K w - - 11 22",
        "2r1rbk1/1q4pp/pnp1pp2/1b6/1nBPPB2/1PN2N1P/4QPP1/1R1R3K w - - 0 23",
        "2r1rbk1/5qpp/pnp1pp2/1b6/1nBPP3/1PN1BN1P/4QPP1/1R1R3K w - - 2 24",
        "2r1rbk1/5qp1/pnp1pp1p/1b6/1nBPP3/1PN1BN1P/4QPP1/1R1R2K1 w - - 0 25",
        "2r1rbk1/5qp1/pnp1pp1p/1b6/2BPP3/1P2BN1P/n3QPP1/1R1R2K1 w - - 0 26",
        "r3rbk1/5qp1/pnp1pp1p/1b6/2BPP3/1P2BN1P/Q4PP1/1R1R2K1 w - - 1 27",
        "rr3bk1/5qp1/pnp1pp1p/1b6/2BPP3/1P2BN1P/Q4PP1/R2R2K1 w - - 3 28",
        "rr2qbk1/6p1/pnp1pp1p/1b6/2BPP3/1P2BN1P/4QPP1/R2R2K1 w - - 5 29",
        "rr2qbk1/6p1/1np1pp1p/pb6/2BPP3/1P1QBN1P/5PP1/R2R2K1 w - - 0 30",
        "rr2qbk1/6p1/1n2pp1p/pp6/3PP3/1P1QBN1P/5PP1/R2R2K1 w - - 0 31",
        "rr2qbk1/6p1/1n2pp1p/1p1P4/p3P3/1P1QBN1P/5PP1/R2R2K1 w - - 0 32",
        "rr2qbk1/3n2p1/3Ppp1p/1p6/p3P3/1P1QBN1P/5PP1/R2R2K1 w - - 1 33",
        "rr3bk1/3n2p1/3Ppp1p/1p5q/pP2P3/3QBN1P/5PP1/R2R2K1 w - - 1 34",
        "rr3bk1/3n2p1/3Ppp1p/1p5q/1P2P3/p2QBN1P/5PP1/2RR2K1 w - - 0 35",
        "1r3bk1/3n2p1/r2Ppp1p/1p5q/1P2P3/pQ2BN1P/5PP1/2RR2K1 w - - 2 36",
        "1r2qbk1/2Rn2p1/r2Ppp1p/1p6
Download .txt
gitextract_iuycd67k/

├── .clang-format
├── .git-blame-ignore-revs
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── BUG-REPORT.yml
│   │   └── config.yml
│   ├── ci/
│   │   ├── arm_matrix.json
│   │   ├── libcxx17.imp
│   │   └── matrix.json
│   └── workflows/
│       ├── arm_compilation.yml
│       ├── avx2_compilers.yml
│       ├── clang-format.yml
│       ├── codeql.yml
│       ├── compilation.yml
│       ├── games.yml
│       ├── iwyu.yml
│       ├── matetrack.yml
│       ├── sanitizers.yml
│       ├── stockfish.yml
│       ├── tests.yml
│       └── upload_binaries.yml
├── .gitignore
├── AUTHORS
├── CITATION.cff
├── CONTRIBUTING.md
├── Copying.txt
├── README.md
├── Top CPU Contributors.txt
├── scripts/
│   ├── .gitattributes
│   ├── get_native_properties.sh
│   └── net.sh
├── src/
│   ├── Makefile
│   ├── benchmark.cpp
│   ├── benchmark.h
│   ├── bitboard.cpp
│   ├── bitboard.h
│   ├── engine.cpp
│   ├── engine.h
│   ├── evaluate.cpp
│   ├── evaluate.h
│   ├── history.h
│   ├── incbin/
│   │   ├── UNLICENCE
│   │   └── incbin.h
│   ├── main.cpp
│   ├── memory.cpp
│   ├── memory.h
│   ├── misc.cpp
│   ├── misc.h
│   ├── movegen.cpp
│   ├── movegen.h
│   ├── movepick.cpp
│   ├── movepick.h
│   ├── nnue/
│   │   ├── features/
│   │   │   ├── full_threats.cpp
│   │   │   ├── full_threats.h
│   │   │   ├── half_ka_v2_hm.cpp
│   │   │   └── half_ka_v2_hm.h
│   │   ├── layers/
│   │   │   ├── affine_transform.h
│   │   │   ├── affine_transform_sparse_input.h
│   │   │   ├── clipped_relu.h
│   │   │   └── sqr_clipped_relu.h
│   │   ├── network.cpp
│   │   ├── network.h
│   │   ├── nnue_accumulator.cpp
│   │   ├── nnue_accumulator.h
│   │   ├── nnue_architecture.h
│   │   ├── nnue_common.h
│   │   ├── nnue_feature_transformer.h
│   │   ├── nnue_misc.cpp
│   │   ├── nnue_misc.h
│   │   └── simd.h
│   ├── numa.h
│   ├── perft.h
│   ├── position.cpp
│   ├── position.h
│   ├── score.cpp
│   ├── score.h
│   ├── search.cpp
│   ├── search.h
│   ├── shm.h
│   ├── shm_linux.h
│   ├── syzygy/
│   │   ├── tbprobe.cpp
│   │   └── tbprobe.h
│   ├── thread.cpp
│   ├── thread.h
│   ├── thread_win32_osx.h
│   ├── timeman.cpp
│   ├── timeman.h
│   ├── tt.cpp
│   ├── tt.h
│   ├── tune.cpp
│   ├── tune.h
│   ├── types.h
│   ├── uci.cpp
│   ├── uci.h
│   ├── ucioption.cpp
│   └── ucioption.h
└── tests/
    ├── .gitattributes
    ├── instrumented.py
    ├── perft.sh
    ├── reprosearch.sh
    ├── signature.sh
    └── testing.py
Download .txt
SYMBOL INDEX (511 symbols across 64 files)

FILE: src/benchmark.cpp
  type Stockfish::Benchmark (line 378) | namespace Stockfish::Benchmark {
    function setup_bench (line 391) | std::vector<std::string> setup_bench(const std::string& currentFen, st...
    function BenchmarkSetup (line 445) | BenchmarkSetup setup_benchmark(std::istream& is) {

FILE: src/benchmark.h
  function namespace (line 26) | namespace Stockfish::Benchmark {

FILE: src/bitboard.cpp
  type Stockfish (line 27) | namespace Stockfish {
    function init_magics (line 105) | void init_magics(PieceType pt, Bitboard table[], Magic magics[][2]) {

FILE: src/bitboard.h
  function namespace (line 34) | namespace Stockfish {
  function Bitboard (line 97) | constexpr Bitboard square_bb(Square s) {
  function Bitboard (line 124) | constexpr Bitboard rank_bb(Rank r) { return Rank1BB << (8 * r); }
  function Bitboard (line 126) | constexpr Bitboard rank_bb(Square s) { return rank_bb(rank_of(s)); }
  function Bitboard (line 128) | constexpr Bitboard file_bb(File f) { return FileABB << f; }
  function Bitboard (line 130) | constexpr Bitboard file_bb(Square s) { return file_bb(file_of(s)); }
  function Bitboard (line 135) | Bitboard shift(Bitboard b) {
  function Bitboard (line 153) | Bitboard pawn_attacks_bb(Bitboard b) {
  function Bitboard (line 163) | inline Bitboard line_bb(Square s1, Square s2) {
  function Bitboard (line 177) | inline Bitboard between_bb(Square s1, Square s2) {
  function edge_distance (line 204) | inline int edge_distance(File f) { return std::min(f, File(FILE_H - f)); }
  function constexpr_popcount (line 207) | constexpr int constexpr_popcount(Bitboard b) {
  function popcount (line 215) | inline int popcount(Bitboard b) {
  function Square (line 236) | inline Square lsb(Bitboard b) {
  function Square (line 270) | inline Square msb(Bitboard b) {
  function Bitboard (line 306) | inline Bitboard least_significant_square_bb(Bitboard b) {
  function Square (line 312) | inline Square pop_lsb(Bitboard& b) {
  function namespace (line 319) | namespace Bitboards {
  function Bitboard (line 349) | constexpr Bitboard knight_attack(Square sq) {

FILE: src/engine.cpp
  type Stockfish (line 47) | namespace Stockfish {
    function OptionsMap (line 345) | const OptionsMap& Engine::get_options() const { return options; }
    function OptionsMap (line 346) | OptionsMap&       Engine::get_options() { return options; }

FILE: src/engine.h
  function namespace (line 43) | namespace Stockfish {

FILE: src/evaluate.cpp
  type Stockfish (line 38) | namespace Stockfish {
    function Value (line 53) | Value Eval::evaluate(const Eval::NNUE::Networks&    networks,

FILE: src/evaluate.h
  function namespace (line 26) | namespace Stockfish {

FILE: src/history.h
  function namespace (line 36) | namespace Stockfish {
  function namespace (line 183) | namespace Detail {
  function get_size (line 222) | struct SharedHistories {

FILE: src/main.cpp
  function main (line 30) | int main(int argc, char* argv[]) {

FILE: src/memory.cpp
  type Stockfish (line 61) | namespace Stockfish {
    function std_aligned_free (line 83) | void std_aligned_free(void* ptr) {
    function has_large_pages (line 146) | bool has_large_pages() {
    function aligned_large_pages_free (line 183) | void aligned_large_pages_free(void* mem) {
    function aligned_large_pages_free (line 196) | void aligned_large_pages_free(void* mem) { std_aligned_free(mem); }

FILE: src/memory.h
  function namespace (line 62) | namespace Stockfish {
  function func (line 225) | const auto   func   = [](size_t size) { return std_aligned_alloc(alignof...
  function HANDLE (line 253) | HANDLE hProcessToken{}
  function LUID (line 254) | LUID   luid{}
  function TOKEN_PRIVILEGES (line 289) | TOKEN_PRIVILEGES tp{}
  function TOKEN_PRIVILEGES (line 290) | TOKEN_PRIVILEGES prevTp{}

FILE: src/misc.cpp
  type Stockfish (line 38) | namespace Stockfish {
    type Tie (line 51) | struct Tie: public std::streambuf {  // MSVC requires split streambuf ...
      method Tie (line 53) | Tie(std::streambuf* b, std::streambuf* l) :
      method sync (line 57) | int sync() override { return logBuf->pubsync(), buf->pubsync(); }
      method overflow (line 58) | int overflow(int c) override { return log(buf->sputc(char(c)), "<< "...
      method underflow (line 59) | int underflow() override { return buf->sgetc(); }
      method uflow (line 60) | int uflow() override { return log(buf->sbumpc(), ">> "); }
      method log (line 64) | int log(int c, const char* prefix) {
    class Logger (line 75) | class Logger {
      method Logger (line 77) | Logger() :
      method start (line 86) | static void start(const std::string& fname) {
    function engine_version_info (line 127) | std::string engine_version_info() {
    function engine_info (line 159) | std::string engine_info(bool to_uci) {
    function compiler_info (line 166) | std::string compiler_info() {
    type DebugInfo (line 292) | struct DebugInfo {
      method DebugInfo (line 300) | constexpr DebugInfo& operator=(const DebugInfo& other) {
    type DebugExtremes (line 307) | struct DebugExtremes: public DebugInfo<3> {
      method DebugExtremes (line 308) | DebugExtremes() {
    function dbg_hit_on (line 322) | void dbg_hit_on(bool cond, int slot) {
    function dbg_mean_of (line 329) | void dbg_mean_of(int64_t value, int slot) {
    function dbg_stdev_of (line 335) | void dbg_stdev_of(int64_t value, int slot) {
    function dbg_extremes_of (line 342) | void dbg_extremes_of(int64_t value, int slot) {
    function dbg_correl_of (line 354) | void dbg_correl_of(int64_t value1, int64_t value2, int slot) {
    function dbg_print (line 364) | void dbg_print() {
    function dbg_clear (line 405) | void dbg_clear() {
    function sync_cout_start (line 428) | void sync_cout_start() { std::cout << IO_LOCK; }
    function sync_cout_end (line 429) | void sync_cout_end() { std::cout << IO_UNLOCK; }
    function hash_bytes (line 432) | uint64_t hash_bytes(const char* data, size_t size) {
    function start_logger (line 471) | void start_logger(const std::string& fname) { Logger::start(fname); }
    function str_to_size_t (line 482) | size_t str_to_size_t(const std::string& s) {
    function read_file_to_string (line 489) | std::optional<std::string> read_file_to_string(const std::string& path) {
    function remove_whitespace (line 496) | void remove_whitespace(std::string& s) {
    function is_whitespace (line 500) | bool is_whitespace(std::string_view s) {

FILE: src/misc.h
  function namespace (line 47) | namespace Stockfish {
  function class (line 327) | class PRNG {
  function mul_hi64 (line 356) | inline uint64_t mul_hi64(uint64_t a, uint64_t b) {
  function hash_combine (line 382) | void hash_combine(std::size_t& seed, const T& v) {
  function hash_string (line 393) | inline std::uint64_t hash_string(const std::string& sv) { return hash_by...
  function const (line 428) | const char& operator[](std::size_t i) const { return data_[i]; }
  function operator (line 442) | operator std::string() const { return std::string(data_, length_); }
  function noexcept (line 447) | const noexcept {
  function noexcept (line 452) | const noexcept {
  function clear (line 456) | void clear() {
  type CommandLine (line 466) | struct CommandLine {
  function namespace (line 479) | namespace Utility {

FILE: src/movegen.cpp
  type Stockfish (line 33) | namespace Stockfish {
    function Move (line 47) | inline Move* splat_pawn_moves(Move* moveList, Bitboard to_bb) {
    function Move (line 60) | inline Move* splat_moves(Move* moveList, Square from, Bitboard to_bb) {
    function Move (line 75) | inline Move* splat_pawn_moves(Move* moveList, Bitboard to_bb) {
    function Move (line 84) | inline Move* splat_moves(Move* moveList, Square from, Bitboard to_bb) {
    function Move (line 93) | Move* make_promotions(Move* moveList, [[maybe_unused]] Square to) {
    function Move (line 112) | Move* generate_pawn_moves(const Position& pos, Move* moveList, Bitboar...
    function Move (line 194) | Move* generate_moves(const Position& pos, Move* moveList, Bitboard tar...
    function Move (line 213) | Move* generate_all(const Position& pos, Move* moveList) {
    function Move (line 257) | Move* generate(const Position& pos, Move* moveList) {
    function Move (line 277) | Move* generate<LEGAL>(const Position& pos, Move* moveList) {

FILE: src/movegen.h
  function namespace (line 27) | namespace Stockfish {
  function explicit (line 60) | explicit MoveList(const Position& pos) :
  function Move (line 62) | const Move* begin() const { return moveList; }
  function Move (line 63) | const Move* end() const { return last; }
  function contains (line 65) | bool        contains(Move move) const { return std::find(begin(), end(),...

FILE: src/movepick.cpp
  type Stockfish (line 29) | namespace Stockfish {
    type Stages (line 33) | enum Stages {
    function partial_insertion_sort (line 62) | void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) {
    function ExtMove (line 125) | ExtMove* MovePicker::score(MoveList<Type>& ml) {
    function Move (line 196) | Move MovePicker::select(Pred filter) {
    function Move (line 208) | Move MovePicker::next_move() {

FILE: src/movepick.h
  function namespace (line 26) | namespace Stockfish {

FILE: src/nnue/features/full_threats.cpp
  type Stockfish::Eval::NNUE::Features (line 35) | namespace Stockfish::Eval::NNUE::Features {
    type HelperOffsets (line 37) | struct HelperOffsets {
    function make_piece_indices_type (line 47) | constexpr auto make_piece_indices_type() {
    function make_piece_indices_piece (line 66) | constexpr auto make_piece_indices_piece() {
    function index_lut2_array (line 86) | constexpr auto index_lut2_array() {
    function init_threat_offsets (line 116) | constexpr auto init_threat_offsets() {
    function init_index_luts (line 156) | constexpr auto init_index_luts() {
    function sf_always_inline (line 192) | inline sf_always_inline IndexType FullThreats::make_index(

FILE: src/nnue/features/full_threats.h
  function namespace (line 27) | namespace Stockfish {
  function namespace (line 31) | namespace Stockfish::Eval::NNUE::Features {

FILE: src/nnue/features/half_ka_v2_hm.cpp
  type Stockfish::Eval::NNUE::Features (line 28) | namespace Stockfish::Eval::NNUE::Features {
    function IndexType (line 101) | IndexType HalfKAv2_hm::make_index(Color perspective, Square s, Piece p...

FILE: src/nnue/features/half_ka_v2_hm.h
  function namespace (line 30) | namespace Stockfish {
  function namespace (line 34) | namespace Stockfish::Eval::NNUE::Features {

FILE: src/nnue/layers/affine_transform.h
  function namespace (line 41) | namespace Stockfish::Eval::NNUE::Layers {

FILE: src/nnue/layers/affine_transform_sparse_input.h
  function namespace (line 38) | namespace Stockfish::Eval::NNUE::Layers {
  function get_hash_value (line 205) | static constexpr std::uint32_t get_hash_value(std::uint32_t prevHash) {
  function IndexType (line 213) | static constexpr IndexType get_weight_index_scrambled(IndexType i) {
  function IndexType (line 218) | static constexpr IndexType get_weight_index(IndexType i) {
  function read_parameters (line 227) | bool read_parameters(std::istream& stream) {
  function write_parameters (line 236) | bool write_parameters(std::ostream& stream) const {
  function propagate (line 254) | void propagate(const InputType* input, OutputType* output) const {

FILE: src/nnue/layers/clipped_relu.h
  function namespace (line 30) | namespace Stockfish::Eval::NNUE::Layers {

FILE: src/nnue/layers/sqr_clipped_relu.h
  function namespace (line 30) | namespace Stockfish::Eval::NNUE::Layers {

FILE: src/nnue/network.cpp
  type EmbeddedNNUE (line 60) | struct EmbeddedNNUE {
    method EmbeddedNNUE (line 61) | EmbeddedNNUE(const unsigned char* embeddedData,
  function EmbeddedNNUE (line 74) | EmbeddedNNUE get_embedded(EmbeddedNNUEType type) {
    method EmbeddedNNUE (line 61) | EmbeddedNNUE(const unsigned char* embeddedData,
  type Stockfish::Eval::NNUE (line 84) | namespace Stockfish::Eval::NNUE {
    type Detail (line 87) | namespace Detail {
      function read_parameters (line 91) | bool read_parameters(std::istream& stream, T& reference) {
      function write_parameters (line 102) | bool write_parameters(std::ostream& stream, const T& reference) {
    function NetworkOutput (line 172) | NetworkOutput
    function NnueEvalTrace (line 234) | NnueEvalTrace
    class MemoryBuffer (line 279) | class MemoryBuffer: public std::basic_streambuf<char> {
      method MemoryBuffer (line 281) | MemoryBuffer(char* p, size_t n) {
    class Network<NetworkArchitecture<TransformedFeatureDimensionsBig, L2Big, L3Big>,
                       FeatureTransformer<TransformedFeatureDimensionsBig>> (line 410) | class Network<NetworkArchitecture<TransformedFeatureDimensionsBig, L2B...
    class Network<NetworkArchitecture<TransformedFeatureDimensionsSmall, L2Small, L3Small>,
                       FeatureTransformer<TransformedFeatureDimensionsSmall>> (line 413) | class Network<NetworkArchitecture<TransformedFeatureDimensionsSmall, L...

FILE: src/nnue/network.h
  function namespace (line 40) | namespace Stockfish {
  function EmbeddedNNUEType (line 46) | enum class EmbeddedNNUEType {
  function Networks (line 152) | struct std::hash<Stockfish::Eval::NNUE::Networks> {

FILE: src/nnue/nnue_accumulator.cpp
  type Stockfish::Eval::NNUE (line 36) | namespace Stockfish::Eval::NNUE {
    function fused_row_reduce (line 300) | void fused_row_reduce(const ElementType* in, ElementType* out, const T...
    type AccumulatorUpdateContext (line 312) | struct AccumulatorUpdateContext {
      method AccumulatorUpdateContext (line 318) | AccumulatorUpdateContext(Color                                 persp,
      method apply (line 330) | void apply(const Ts... indices) {
      method apply (line 350) | void apply(const typename FeatureSet::IndexList& added,
    function make_accumulator_update_context (line 483) | auto make_accumulator_update_context(Color                            ...
    function double_inc_update (line 492) | void double_inc_update(Color                                          ...
    function double_inc_update (line 540) | void double_inc_update(Color                                          ...
    function update_accumulator_incremental (line 573) | void update_accumulator_incremental(
    function Bitboard (line 659) | Bitboard get_changed_pieces(const std::array<Piece, SQUARE_NB>& oldPie...
    function update_accumulator_refresh_cache (line 697) | void update_accumulator_refresh_cache(Color                           ...
    function update_threats_accumulator_full (line 856) | void update_threats_accumulator_full(Color                            ...

FILE: src/nnue/nnue_accumulator.h
  function namespace (line 34) | namespace Stockfish {
  function Accumulator (line 48) | alignas(CacheLineSize) Accumulator {
  type AccumulatorCaches (line 61) | struct AccumulatorCaches {
  function Cache (line 69) | alignas(CacheLineSize) Cache {

FILE: src/nnue/nnue_architecture.h
  function namespace (line 36) | namespace Stockfish::Eval::NNUE {

FILE: src/nnue/nnue_common.h
  function namespace (line 49) | namespace Stockfish::Eval::NNUE {

FILE: src/nnue/nnue_feature_transformer.h
  function namespace (line 37) | namespace Stockfish::Eval::NNUE {
  type std (line 430) | struct std

FILE: src/nnue/nnue_misc.cpp
  type Stockfish::Eval::NNUE (line 39) | namespace Stockfish::Eval::NNUE {
    function format_cp_compact (line 48) | void format_cp_compact(Value v, char* buffer, const Position& pos) {
    function format_cp_aligned_dot (line 84) | void format_cp_aligned_dot(Value v, std::stringstream& stream, const P...
    function trace (line 98) | std::string

FILE: src/nnue/nnue_misc.h
  function namespace (line 30) | namespace Stockfish {
  function EvalFile (line 64) | struct std::hash<Stockfish::Eval::NNUE::EvalFile> {

FILE: src/nnue/simd.h
  function namespace (line 41) | namespace Stockfish::Eval::NNUE::SIMD {

FILE: src/numa.h
  function namespace (line 78) | namespace Stockfish {
  function WindowsAffinity (line 181) | inline WindowsAffinity get_process_affinity() {
  function std (line 422) | inline std::set<CpuIndex> get_process_affinity() {
  function class (line 480) | class NumaReplicatedAccessToken {
  type L3Domain (line 494) | struct L3Domain {
  type SystemNumaPolicy (line 500) | struct SystemNumaPolicy {}
  type L3DomainsPolicy (line 502) | struct L3DomainsPolicy {}
  type BundledL3Policy (line 504) | struct BundledL3Policy {
  function is_cpu_allowed (line 564) | auto is_cpu_allowed = [&allowedCpus](CpuIndex c) {
  function NumaConfig (line 971) | static NumaConfig empty() { return NumaConfig(EmptyNodeTag{}); }
  type EmptyNodeTag (line 973) | struct EmptyNodeTag {}
  function remove_empty_numa_nodes (line 979) | void remove_empty_numa_nodes() {
  function add_cpu_to_node (line 990) | bool add_cpu_to_node(NumaIndex n, CpuIndex c) {
  function add_cpu_range_to_node (line 1009) | bool add_cpu_range_to_node(NumaIndex n, CpuIndex cfirst, CpuIndex clast) {
  function nextUnseenCpu (line 1169) | auto               nextUnseenCpu = [&seenCpus]() {
  function L3Domain (line 1220) | L3Domain domain{}
  function NumaConfig (line 1241) | static NumaConfig from_l3_info(std::vector<L3Domain>&& domains, size_t b...
  function NumaReplicatedBase (line 1405) | NumaReplicatedBase(ctx) {
  function T (line 1430) | const T& operator[](NumaReplicatedAccessToken token) const {
  function ensure_present (line 1458) | void ensure_present(NumaIndex idx) const {
  function prepare_replicate_from (line 1476) | void prepare_replicate_from(T&& source) {
  function NumaReplicatedBase (line 1515) | NumaReplicatedBase(ctx) {
  function T (line 1540) | const T& operator[](NumaReplicatedAccessToken token) const {
  function attach (line 1655) | void attach(NumaReplicatedBase* obj) {
  function detach (line 1660) | void detach(NumaReplicatedBase* obj) {
  function move_attached (line 1666) | void move_attached([[maybe_unused]] NumaReplicatedBase* oldObj, NumaRepl...

FILE: src/perft.h
  function namespace (line 29) | namespace Stockfish::Benchmark {

FILE: src/position.cpp
  type Stockfish (line 44) | namespace Stockfish {
    type Zobrist (line 46) | namespace Zobrist {
    function H1 (line 110) | inline int H1(Key h) { return h & 0x1fff; }
    function H2 (line 111) | inline int H2(Key h) { return (h >> 16) & 0x1fff; }
    function Key (line 536) | Key Position::compute_material_key() const {
    function string (line 568) | string Position::fen() const {
    function Bitboard (line 648) | Bitboard Position::attackers_to(Square s, Bitboard occupied) const {
    function add_dirty_threat (line 1167) | inline void add_dirty_threat(
    function write_multiple_dirties (line 1182) | void write_multiple_dirties(const Position& p,

FILE: src/position.h
  function namespace (line 35) | namespace Stockfish {

FILE: src/score.cpp
  type Stockfish (line 27) | namespace Stockfish {

FILE: src/score.h
  function namespace (line 27) | namespace Stockfish {

FILE: src/search.cpp
  type Stockfish (line 53) | namespace Stockfish {
    function correction_value (line 79) | int correction_value(const Worker& w, const Position& pos, const Stack...
    function Value (line 97) | Value to_corrected_static_eval(const Value v, const int cv) {
    function update_correction_history (line 101) | void update_correction_history(const Position& pos,
    function Value (line 127) | Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes &...
    function is_shuffling (line 144) | bool is_shuffling(Move move, Stack* const ss, const Position& pos) {
    function Value (line 631) | Value Search::Worker::search(
    function Value (line 1517) | Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, V...
    function Depth (line 1756) | Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) co...
    function TimePoint (line 1769) | TimePoint Search::Worker::elapsed() const {
    function TimePoint (line 1773) | TimePoint Search::Worker::elapsed_time() const { return main_manager()...
    function Value (line 1775) | Value Search::Worker::evaluate(const Position& pos) {
    function Value (line 1784) | Value value_to_tt(Value v, int ply) { return is_win(v) ? v + ply : is_...
    function Value (line 1792) | Value value_from_tt(Value v, int ply, int r50c) {
    function update_pv (line 1830) | void update_pv(Move* pv, Move move, const Move* childPv) {
    function update_all_stats (line 1839) | void update_all_stats(const Position& pos,
    function update_continuation_histories (line 1893) | void update_continuation_histories(Stack* ss, Piece pc, Square to, int...
    function update_quiet_histories (line 1921) | void update_quiet_histories(
    function Move (line 1940) | Move Skill::pick_best(const RootMoves& rootMoves, size_t multiPV) {
    function syzygy_extend_pv (line 2007) | void syzygy_extend_pv(const OptionsMap&         options,

FILE: src/search.h
  function namespace (line 46) | namespace Stockfish {
  function time_to_pick (line 211) | bool time_to_pick(Depth depth) const { return depth == 1 + int(level); }
  function class (line 220) | class SearchManager: public ISearchManager {
  function class (line 261) | class NullSearchManager: public ISearchManager {
  function class (line 269) | class Worker {

FILE: src/shm.h
  function namespace (line 92) | namespace Stockfish {

FILE: src/shm_linux.h
  function namespace (line 52) | namespace Stockfish::shm {
  function portable_fallocate (line 144) | inline int portable_fallocate(int fd, off_t offset, off_t length) {
  function calculate_total_size (line 178) | static constexpr size_t calculate_total_size() noexcept {
  function std (line 182) | static std::string make_sentinel_base(const std::string& name) {
  function noexcept (line 196) | noexcept override {
  function open (line 242) | [[nodiscard]] bool open(const T& initial_value) noexcept {
  function T (line 384) | [[nodiscard]] const T& get() const noexcept { return *data_ptr_; }
  function cleanup_all_instances (line 398) | static void cleanup_all_instances() noexcept { detail::SharedMemoryRegis...
  function unmap_region (line 409) | void unmap_region() noexcept {
  function lock_file (line 419) | [[nodiscard]] bool lock_file(int operation) noexcept {
  function unlock_file (line 432) | void unlock_file() noexcept {
  function decrement_refcount_relaxed (line 451) | void decrement_refcount_relaxed() noexcept {
  function create_sentinel_file_locked (line 462) | bool create_sentinel_file_locked() noexcept {
  function remove_sentinel_file (line 492) | void remove_sentinel_file() noexcept {
  function pid_is_alive (line 500) | static bool pid_is_alive(pid_t pid) noexcept {
  function initialize_shared_mutex (line 510) | [[nodiscard]] bool initialize_shared_mutex() noexcept {
  function lock_shared_mutex (line 531) | [[nodiscard]] bool lock_shared_mutex() noexcept {
  function unlock_shared_mutex (line 557) | void unlock_shared_mutex() noexcept {
  function setup_new_region (line 598) | [[nodiscard]] bool setup_new_region(const T& initial_value) noexcept {

FILE: src/syzygy/tbprobe.cpp
  type Stockfish (line 65) | namespace Stockfish {
    type TBType (line 77) | enum TBType {
    type TBFlag (line 83) | enum TBFlag {
    function WDLScore (line 92) | inline WDLScore operator-(WDLScore d) { return WDLScore(-int(d)); }
    function Square (line 93) | inline Square   operator^(Square s, int i) { return Square(int(s) ^ i); }
    function pawns_comp (line 107) | bool pawns_comp(Square i, Square j) { return MapPawns[i] < MapPawns[j]; }
    function off_A1H8 (line 108) | int  off_A1H8(Square sq) { return int(rank_of(sq)) - file_of(sq); }
    function swap_endian (line 114) | inline void swap_endian(T& x) {
    function T (line 125) | T number(void* addr) {
    function dtz_before_zeroing (line 141) | int dtz_before_zeroing(WDLScore wdl) {
    function sign_of (line 151) | int sign_of(T val) {
    type SparseEntry (line 156) | struct SparseEntry {
    type LR (line 165) | struct LR {
      type Side (line 166) | enum Side {
      method Sym (line 175) | Sym get() {
    class TBFile (line 193) | class TBFile: public std::ifstream {
      method TBFile (line 206) | TBFile(const std::string& f) {
      type stat (line 231) | struct stat
      method unmap (line 307) | static void unmap(void* baseAddress, uint64_t mapping) {
    type PairsData (line 323) | struct PairsData {
    type TBTable (line 352) | struct TBTable {
      method PairsData (line 369) | PairsData* get(int stm, int f) { return &items[stm % Sides][hasPawns...
      method TBTable (line 371) | TBTable() :
    class TBTables (line 446) | class TBTables {
      type Entry (line 448) | struct Entry {
      method insert (line 469) | void insert(Key key, TBTable<WDL>* wdl, TBTable<DTZ>* dtz) {
      method clear (line 507) | void clear() {
      method info (line 515) | void info() const {
    function decompress_pairs (line 575) | int decompress_pairs(PairsData* d, uint64_t idx) {
    function check_dtz_stm (line 691) | bool check_dtz_stm(TBTable<WDL>*, int, File) { return true; }
    function check_dtz_stm (line 693) | bool check_dtz_stm(TBTable<DTZ>* entry, int stm, File f) {
    function WDLScore (line 703) | WDLScore map_score(TBTable<WDL>*, File, int value, WDLScore) { return ...
    function map_score (line 705) | int map_score(TBTable<DTZ>* entry, File f, int value, WDLScore wdl) {
    function Ret (line 745) | Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeS...
    function set_groups (line 977) | void set_groups(T& e, PairsData* d, int order[], File f) {
    function set_symlen (line 1032) | uint8_t set_symlen(PairsData* d, Sym s, std::vector<bool>& visited) {
    function set (line 1164) | void set(T& e, uint8_t* data) {
    function Ret (line 1276) | Ret probe_table(const Position& pos, ProbeState* result, WDLScore wdl ...
    function WDLScore (line 1303) | WDLScore search(Position& pos, ProbeState* result) {
    function WDLScore (line 1525) | WDLScore Tablebases::probe_wdl(Position& pos, ProbeState* result) {
    function Config (line 1736) | Config Tablebases::rank_root_moves(const OptionsMap&            options,

FILE: src/syzygy/tbprobe.h
  function namespace (line 27) | namespace Stockfish {
  function namespace (line 39) | namespace Stockfish::Tablebases {

FILE: src/thread.cpp
  type Stockfish (line 41) | namespace Stockfish {
    function next_power_of_two (line 144) | static size_t next_power_of_two(uint64_t count) { return count > 1 ? (...
    function Thread (line 347) | Thread* ThreadPool::get_best_thread() const {

FILE: src/thread.h
  function namespace (line 37) | namespace Stockfish {
  function class (line 74) | class Thread {
  function num_threads (line 138) | size_t num_threads() const;
  function nodes_searched (line 146) | uint64_t               nodes_searched() const;
  function noexcept (line 159) | auto begin() noexcept { return threads.begin(); }
  function noexcept (line 160) | auto end() noexcept { return threads.end(); }
  function noexcept (line 161) | auto cend() const noexcept { return threads.cend(); }
  function noexcept (line 162) | auto size() const noexcept { return threads.size(); }
  function noexcept (line 163) | auto empty() const noexcept { return threads.empty(); }
  function accumulate (line 170) | uint64_t accumulate(std::atomic<uint64_t> Search::Worker::* member) const {

FILE: src/thread_win32_osx.h
  function namespace (line 35) | namespace Stockfish {
  function namespace (line 70) | namespace Stockfish {

FILE: src/timeman.cpp
  type Stockfish (line 29) | namespace Stockfish {
    function TimePoint (line 31) | TimePoint TimeManagement::optimum() const { return optimumTime; }
    function TimePoint (line 32) | TimePoint TimeManagement::maximum() const { return maximumTime; }

FILE: src/timeman.h
  function namespace (line 26) | namespace Stockfish {

FILE: src/tt.cpp
  type Stockfish (line 32) | namespace Stockfish {
    type TTEntry (line 49) | struct TTEntry {
      method TTData (line 52) | TTData read() const {
    type Cluster (line 142) | struct Cluster {
    function TTEntry (line 247) | TTEntry* TranspositionTable::first_entry(const Key key) const {
      method TTData (line 52) | TTData read() const {

FILE: src/tt.h
  function namespace (line 29) | namespace Stockfish {

FILE: src/tune.cpp
  type Stockfish (line 32) | namespace Stockfish {
    function on_tune (line 40) | std::optional<std::string> on_tune(const Option& o) {
    function string (line 70) | string Tune::next(string& names, bool pop) {
  type Stockfish (line 122) | namespace Stockfish {
    function on_tune (line 40) | std::optional<std::string> on_tune(const Option& o) {
    function string (line 70) | string Tune::next(string& names, bool pop) {

FILE: src/tune.h
  function namespace (line 29) | namespace Stockfish {
  function class (line 79) | class Tune {

FILE: src/types.h
  function namespace (line 94) | namespace Stockfish {
  type DirtyThreats (line 329) | struct DirtyThreats {
  function ENABLE_INCR_OPERATORS_ON (line 341) | ENABLE_INCR_OPERATORS_ON(PieceType)
  function Direction (line 349) | constexpr Direction operator*(int i, Direction d) { return Direction(i *...
  function Square (line 361) | constexpr Square flip_rank(Square s) { return Square(s ^ SQ_A8); }
  function Square (line 364) | constexpr Square flip_file(Square s) { return Square(s ^ SQ_H1); }
  function Value (line 373) | constexpr Value mate_in(int ply) { return VALUE_MATE - ply; }
  function Value (line 375) | constexpr Value mated_in(int ply) { return -VALUE_MATE + ply; }
  function Square (line 377) | constexpr Square make_square(File f, Rank r) { return Square((r << 3) + ...
  function Piece (line 379) | constexpr Piece make_piece(Color c, PieceType pt) { return Piece((c << 3...
  function PieceType (line 381) | constexpr PieceType type_of(Piece pc) { return PieceType(pc & 7); }
  function Color (line 383) | constexpr Color color_of(Piece pc) {
  function is_ok (line 388) | constexpr bool is_ok(Square s) { return s >= SQ_A1 && s <= SQ_H8; }
  function File (line 390) | constexpr File file_of(Square s) { return File(s & 7); }
  function Rank (line 392) | constexpr Rank rank_of(Square s) { return Rank(s >> 3); }
  function Square (line 394) | constexpr Square relative_square(Color c, Square s) { return Square(s ^ ...
  function Rank (line 396) | constexpr Rank relative_rank(Color c, Rank r) { return Rank(r ^ (c * 7)); }
  function Rank (line 398) | constexpr Rank relative_rank(Color c, Square s) { return relative_rank(c...
  function Direction (line 400) | constexpr Direction pawn_push(Color c) { return c == WHITE ? NORTH : SOU...
  function Key (line 404) | constexpr Key make_key(uint64_t seed) {
  type MoveType (line 409) | enum MoveType : uint16_t {
  function class (line 428) | class Move {
  function Square (line 442) | constexpr Square from_sq() const {
  function PieceType (line 458) | constexpr PieceType promotion_type() const { return PieceType(((data >> ...
  function Move (line 462) | static constexpr Move null() { return Move(65); }
  function Move (line 463) | static constexpr Move none() { return Move(0); }
  function operator (line 465) | constexpr bool operator==(const Move& m) const { return data == m.data; }
  function operator (line 466) | constexpr bool operator!=(const Move& m) const { return data != m.data; }
  type MoveHash (line 472) | struct MoveHash {

FILE: src/uci.cpp
  type Stockfish (line 43) | namespace Stockfish {
    type overload (line 49) | struct overload: Ts... {
    type WinRateParams (line 503) | struct WinRateParams {
    function WinRateParams (line 508) | WinRateParams win_rate_params(const Position& pos) {
    function win_rate_model (line 528) | int win_rate_model(Value v, const Position& pos) {
    function Move (line 611) | Move UCIEngine::to_move(const Position& pos, std::string str) {

FILE: src/uci.h
  function namespace (line 31) | namespace Stockfish {

FILE: src/ucioption.cpp
  type Stockfish (line 31) | namespace Stockfish {
    function Option (line 61) | const Option& OptionsMap::operator[](const std::string& name) const {
    function Option (line 151) | Option& Option::operator=(const std::string& v) {

FILE: src/ucioption.h
  type CaseInsensitiveLess (line 31) | struct CaseInsensitiveLess {
  function class (line 38) | class Option {

FILE: tests/instrumented.py
  function get_prefix (line 23) | def get_prefix():
  function get_threads (line 32) | def get_threads():
  function get_path (line 38) | def get_path():
  function postfix_check (line 42) | def postfix_check(output):
  function Stockfish (line 66) | def Stockfish(*args, **kwargs):
  class TestCLI (line 70) | class TestCLI(metaclass=OrderedClassMembers):
    method beforeAll (line 71) | def beforeAll(self):
    method afterAll (line 74) | def afterAll(self):
    method beforeEach (line 77) | def beforeEach(self):
    method afterEach (line 80) | def afterEach(self):
    method test_eval (line 84) | def test_eval(self):
    method test_go_nodes_1000 (line 88) | def test_go_nodes_1000(self):
    method test_go_depth_10 (line 92) | def test_go_depth_10(self):
    method test_go_perft_4 (line 96) | def test_go_perft_4(self):
    method test_go_movetime_1000 (line 100) | def test_go_movetime_1000(self):
    method test_go_wtime_8000_btime_8000_winc_500_binc_500 (line 104) | def test_go_wtime_8000_btime_8000_winc_500_binc_500(self):
    method test_go_wtime_1000_btime_1000_winc_0_binc_0 (line 111) | def test_go_wtime_1000_btime_1000_winc_0_binc_0(self):
    method test_go_wtime_1000_btime_1000_winc_0_binc_0_movestogo_5 (line 118) | def test_go_wtime_1000_btime_1000_winc_0_binc_0_movestogo_5(self):
    method test_go_movetime_200 (line 125) | def test_go_movetime_200(self):
    method test_go_nodes_20000_searchmoves_e2e4_d2d4 (line 129) | def test_go_nodes_20000_searchmoves_e2e4_d2d4(self):
    method test_bench_128_threads_8_default_depth (line 135) | def test_bench_128_threads_8_default_depth(self):
    method test_bench_128_threads_3_bench_tmp_epd_depth (line 142) | def test_bench_128_threads_3_bench_tmp_epd_depth(self):
    method test_d (line 151) | def test_d(self):
    method test_compiler (line 155) | def test_compiler(self):
    method test_license (line 159) | def test_license(self):
    method test_uci (line 163) | def test_uci(self):
    method test_export_net_verify_nnue (line 167) | def test_export_net_verify_nnue(self):
    method test_network_equals_base (line 176) | def test_network_equals_base(self):
  class TestInteractive (line 204) | class TestInteractive(metaclass=OrderedClassMembers):
    method beforeAll (line 205) | def beforeAll(self):
    method afterAll (line 208) | def afterAll(self):
    method afterEach (line 212) | def afterEach(self):
    method test_startup_output (line 216) | def test_startup_output(self):
    method test_uci_command (line 219) | def test_uci_command(self):
    method test_set_threads_option (line 223) | def test_set_threads_option(self):
    method test_ucinewgame_and_startpos_nodes_1000 (line 226) | def test_ucinewgame_and_startpos_nodes_1000(self):
    method test_ucinewgame_and_startpos_moves (line 232) | def test_ucinewgame_and_startpos_moves(self):
    method test_fen_position_1 (line 238) | def test_fen_position_1(self):
    method test_fen_position_2_flip (line 244) | def test_fen_position_2_flip(self):
    method test_depth_5_with_callback (line 251) | def test_depth_5_with_callback(self):
    method test_ucinewgame_and_go_depth_9 (line 266) | def test_ucinewgame_and_go_depth_9(self):
    method test_clear_hash (line 292) | def test_clear_hash(self):
    method test_fen_position_mate_1 (line 295) | def test_fen_position_mate_1(self):
    method test_fen_position_mate_minus_1 (line 305) | def test_fen_position_mate_minus_1(self):
    method test_fen_position_fixed_node (line 314) | def test_fen_position_fixed_node(self):
    method test_fen_position_with_mate_go_depth (line 322) | def test_fen_position_with_mate_go_depth(self):
    method test_fen_position_with_mate_go_mate (line 332) | def test_fen_position_with_mate_go_mate(self):
    method test_fen_position_with_mate_go_nodes (line 342) | def test_fen_position_with_mate_go_nodes(self):
    method test_fen_position_depth_27 (line 352) | def test_fen_position_depth_27(self):
    method test_fen_position_with_mate_go_depth_and_promotion (line 362) | def test_fen_position_with_mate_go_depth_and_promotion(self):
    method test_fen_position_with_mate_go_depth_and_searchmoves (line 371) | def test_fen_position_with_mate_go_depth_and_searchmoves(self):
    method test_fen_position_with_moves_with_mate_go_depth_and_searchmoves (line 381) | def test_fen_position_with_moves_with_mate_go_depth_and_searchmoves(se...
    method test_verify_nnue_network (line 390) | def test_verify_nnue_network(self):
    method test_multipv_setting (line 401) | def test_multipv_setting(self):
    method test_fen_position_with_skill_level (line 407) | def test_fen_position_with_skill_level(self):
  class TestSyzygy (line 416) | class TestSyzygy(metaclass=OrderedClassMembers):
    method beforeAll (line 417) | def beforeAll(self):
    method afterAll (line 420) | def afterAll(self):
    method afterEach (line 424) | def afterEach(self):
    method test_syzygy_setup (line 428) | def test_syzygy_setup(self):
    method test_syzygy_bench (line 438) | def test_syzygy_bench(self):
    method test_syzygy_position (line 442) | def test_syzygy_position(self):
    method test_syzygy_position_2 (line 454) | def test_syzygy_position_2(self):
    method test_syzygy_position_3 (line 466) | def test_syzygy_position_3(self):
  class TestEnPassantSanitization (line 478) | class TestEnPassantSanitization(metaclass=OrderedClassMembers):
    method beforeAll (line 479) | def beforeAll(self):
    method afterAll (line 482) | def afterAll(self):
    method afterEach (line 486) | def afterEach(self):
    method test_position_1 (line 490) | def test_position_1(self):
    method test_position_2 (line 496) | def test_position_2(self):
    method test_position_3 (line 502) | def test_position_3(self):
    method test_position_4 (line 508) | def test_position_4(self):
    method test_position_5 (line 514) | def test_position_5(self):
    method test_position_6 (line 520) | def test_position_6(self):
    method test_position_7 (line 526) | def test_position_7(self):
    method test_position_8 (line 532) | def test_position_8(self):
    method test_position_9 (line 538) | def test_position_9(self):
    method test_position_10 (line 544) | def test_position_10(self):
    method test_position_11 (line 550) | def test_position_11(self):
    method test_position_find_draw (line 556) | def test_position_find_draw(self):
  function parse_args (line 567) | def parse_args():

FILE: tests/testing.py
  class Valgrind (line 31) | class Valgrind:
    method get_valgrind_command (line 33) | def get_valgrind_command():
    method get_valgrind_thread_command (line 42) | def get_valgrind_thread_command():
  class TSAN (line 46) | class TSAN:
    method set_tsan_option (line 48) | def set_tsan_option():
    method unset_tsan_option (line 62) | def unset_tsan_option():
  class EPD (line 67) | class EPD:
    method create_bench_epd (line 69) | def create_bench_epd():
    method delete_bench_epd (line 81) | def delete_bench_epd():
  class Syzygy (line 85) | class Syzygy:
    method get_syzygy_path (line 87) | def get_syzygy_path():
    method download_syzygy (line 91) | def download_syzygy():
  class OrderedClassMembers (line 112) | class OrderedClassMembers(type):
    method __prepare__ (line 114) | def __prepare__(self, name, bases):
    method __new__ (line 117) | def __new__(self, name, bases, classdict):
  class TimeoutException (line 124) | class TimeoutException(Exception):
    method __init__ (line 125) | def __init__(self, message: str, timeout: int):
  class UnexpectedOutputException (line 129) | class UnexpectedOutputException(Exception):
    method __init__ (line 130) | def __init__(self, actual: str, expected: str):
  function timeout_decorator (line 135) | def timeout_decorator(timeout: float):
  class MiniTestFramework (line 155) | class MiniTestFramework:
    method __init__ (line 156) | def __init__(self):
    method has_failed (line 163) | def has_failed(self) -> bool:
    method run (line 166) | def run(self, classes: List[type]) -> bool:
    method __run (line 188) | def __run(self, test_class) -> bool:
    method __run_test_method (line 210) | def __run_test_method(self, test_instance, method: str) -> int:
    method __handle_assertion_error (line 256) | def __handle_assertion_error(self, start_time, method: str):
    method __print_buffer_output (line 268) | def __print_buffer_output(self, buffer: io.StringIO):
    method __print_summary (line 276) | def __print_summary(self, duration: float):
    method print_failure (line 286) | def print_failure(self, add: str):
    method print_success (line 289) | def print_success(self, add: str):
  class Stockfish (line 293) | class Stockfish:
    method __init__ (line 294) | def __init__(
    method _check_process_alive (line 310) | def _check_process_alive(self):
    method start (line 315) | def start(self):
    method setoption (line 339) | def setoption(self, name: str, value: str):
    method send_command (line 342) | def send_command(self, command: str):
    method equals (line 352) | def equals(self, expected_output: str):
    method expect (line 358) | def expect(self, expected_output: str):
    method contains (line 364) | def contains(self, expected_output: str):
    method starts_with (line 370) | def starts_with(self, expected_output: str):
    method check_output (line 376) | def check_output(self, callback):
    method expect_for_line_matching (line 385) | def expect_for_line_matching(self, line_match: str, expected: str):
    method readline (line 393) | def readline(self):
    method clear_output (line 404) | def clear_output(self):
    method get_output (line 407) | def get_output(self) -> List[str]:
    method quit (line 410) | def quit(self):
    method close (line 413) | def close(self):
Condensed preview — 100 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,084K chars).
[
  {
    "path": ".clang-format",
    "chars": 1291,
    "preview": "AccessModifierOffset: -1\nAlignAfterOpenBracket: Align\nAlignConsecutiveAssignments: Consecutive\nAlignConsecutiveDeclarati"
  },
  {
    "path": ".git-blame-ignore-revs",
    "chars": 220,
    "preview": "# .git-blame-ignore-revs\n# Ignore commit which added clang-format\n2d0237db3f0e596fb06e3ffbadba84dcc4e018f6\n\n# Post commi"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/BUG-REPORT.yml",
    "chars": 1663,
    "preview": "name: Report issue\ndescription: Create a report to help us fix issues with the engine\nbody:\n- type: textarea\n  attribute"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "chars": 448,
    "preview": "blank_issues_enabled: false\ncontact_links:\n  - name: Discord server\n    url: https://discord.gg/GWDRS3kU6R\n    about: Fe"
  },
  {
    "path": ".github/ci/arm_matrix.json",
    "chars": 1125,
    "preview": "{\n  \"config\": [\n    {\n      \"name\": \"Android NDK aarch64\",\n      \"os\": \"ubuntu-22.04\",\n      \"simple_name\": \"android\",\n "
  },
  {
    "path": ".github/ci/libcxx17.imp",
    "chars": 1222,
    "preview": "[\n    # Mappings for libcxx's internal headers\n    { include: [ \"<__fwd/fstream.h>\", private, \"<iosfwd>\", public ] },\n  "
  },
  {
    "path": ".github/ci/matrix.json",
    "chars": 5353,
    "preview": "{\n  \"config\": [\n    {\n      \"name\": \"Ubuntu 22.04 GCC\",\n      \"os\": \"ubuntu-22.04\",\n      \"simple_name\": \"ubuntu\",\n     "
  },
  {
    "path": ".github/workflows/arm_compilation.yml",
    "chars": 3175,
    "preview": "name: Compilation\non:\n  workflow_call:\n    inputs:\n      matrix:\n        type: string\n        required: true\njobs:\n  Com"
  },
  {
    "path": ".github/workflows/avx2_compilers.yml",
    "chars": 3674,
    "preview": "name: AVX2 Compiler Matrix\n\non:\n  workflow_call:\n\njobs:\n  avx2-compiler-matrix:\n    name: avx2 (${{ matrix.name }})\n    "
  },
  {
    "path": ".github/workflows/clang-format.yml",
    "chars": 2007,
    "preview": "# This workflow will run clang-format and comment on the PR.\n# Because of security reasons, it is crucial that this work"
  },
  {
    "path": ".github/workflows/codeql.yml",
    "chars": 1896,
    "preview": "name: \"CodeQL\"\n\non:\n  push:\n    branches: [\"master\"]\n  pull_request:\n    # The branches below must be a subset of the br"
  },
  {
    "path": ".github/workflows/compilation.yml",
    "chars": 2697,
    "preview": "name: Compilation\non:\n  workflow_call:\n    inputs:\n      matrix:\n        type: string\n        required: true\njobs:\n  Com"
  },
  {
    "path": ".github/workflows/games.yml",
    "chars": 1497,
    "preview": "# This workflow will play games with a debug enabled SF using the PR\n\nname: Games\non:\n  workflow_call:\njobs:\n  Matetrack"
  },
  {
    "path": ".github/workflows/iwyu.yml",
    "chars": 1580,
    "preview": "name: IWYU\non:\n  workflow_call:\njobs:\n  Analyzers:\n    name: Check includes\n    runs-on: ubuntu-22.04\n    defaults:\n    "
  },
  {
    "path": ".github/workflows/matetrack.yml",
    "chars": 5067,
    "preview": "# This workflow will run matetrack on the PR\n\nname: Matetrack\non:\n  workflow_call:\njobs:\n  Matetrack:\n    name: Matetrac"
  },
  {
    "path": ".github/workflows/sanitizers.yml",
    "chars": 2787,
    "preview": "name: Sanitizers\non:\n  workflow_call:\njobs:\n  Test-under-sanitizers:\n    name: ${{ matrix.sanitizers.name }}\n    runs-on"
  },
  {
    "path": ".github/workflows/stockfish.yml",
    "chars": 4909,
    "preview": "name: Stockfish\non:\n  push:\n    tags:\n      - \"*\"\n    branches:\n      - master\n      - tools\n      - github_ci\n  pull_re"
  },
  {
    "path": ".github/workflows/tests.yml",
    "chars": 12103,
    "preview": "name: Tests\non:\n  workflow_call:\njobs:\n  Test-Targets:\n    name: ${{ matrix.config.name }}\n    runs-on: ${{ matrix.confi"
  },
  {
    "path": ".github/workflows/upload_binaries.yml",
    "chars": 3957,
    "preview": "name: Upload Binaries\non:\n  workflow_call:\n    inputs:\n      matrix:\n        type: string\n        required: true\n    sec"
  },
  {
    "path": ".gitignore",
    "chars": 276,
    "preview": "# Files from build\n**/*.o\n**/*.s\nsrc/.depend\n.build_sha.txt\n.build_date.txt\n\n# Built binary\nsrc/stockfish*\nsrc/-lstdc++."
  },
  {
    "path": "AUTHORS",
    "chars": 6459,
    "preview": "# Founders of the Stockfish project and Fishtest infrastructure\nTord Romstad (romstad)\nMarco Costalba (mcostalba)\nJoona "
  },
  {
    "path": "CITATION.cff",
    "chars": 704,
    "preview": "# This CITATION.cff file was generated with cffinit.\n# Visit https://bit.ly/cffinit to generate yours today!\n\ncff-versio"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 3766,
    "preview": "# Contributing to Stockfish\n\nWelcome to the Stockfish project! We are excited that you are interested in\ncontributing. T"
  },
  {
    "path": "Copying.txt",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 7768,
    "preview": "<div align=\"center\">\n\n  [![Stockfish][stockfish128-logo]][website-link]\n\n  <h3>Stockfish</h3>\n\n  A free and strong UCI c"
  },
  {
    "path": "Top CPU Contributors.txt",
    "chars": 23931,
    "preview": "Contributors to Fishtest with >10,000 CPU hours, as of 2025-12-24.\nThank you!\n\nUsername                                C"
  },
  {
    "path": "scripts/.gitattributes",
    "chars": 17,
    "preview": "*.sh text eol=lf\n"
  },
  {
    "path": "scripts/get_native_properties.sh",
    "chars": 8017,
    "preview": "#!/bin/sh\n\n#\n# Returns the best architecture supported by the CPU (as expected by src/Makefile ARCH=).\n#\n# Output format"
  },
  {
    "path": "scripts/net.sh",
    "chars": 2241,
    "preview": "#!/bin/sh\n\n# download commands with a 5min time-out to ensure things fail if the server stalls\nwget_or_curl=$( (command "
  },
  {
    "path": "src/Makefile",
    "chars": 33658,
    "preview": "# Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n# Copyright (C) 2004-2026 The Stockfish developers (se"
  },
  {
    "path": "src/benchmark.cpp",
    "chars": 26525,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/benchmark.h",
    "chars": 1345,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/bitboard.cpp",
    "chars": 6659,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/bitboard.h",
    "chars": 13730,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/engine.cpp",
    "chars": 12583,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/engine.h",
    "chars": 4722,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/evaluate.cpp",
    "chars": 4872,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/evaluate.h",
    "chars": 1912,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/history.h",
    "chars": 9545,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/incbin/UNLICENCE",
    "chars": 1292,
    "preview": "The file \"incbin.h\" is free and unencumbered software released into\nthe public domain by Dale Weiler, see:\n   <https://g"
  },
  {
    "path": "src/incbin/incbin.h",
    "chars": 16036,
    "preview": "/**\n * @file incbin.h\n * @author Dale Weiler\n * @brief Utility for including binary files\n *\n * Facilities for including"
  },
  {
    "path": "src/main.cpp",
    "chars": 1193,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/memory.cpp",
    "chars": 5401,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/memory.h",
    "chars": 10721,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/misc.cpp",
    "chars": 14885,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/misc.h",
    "chars": 16341,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/movegen.cpp",
    "chars": 9994,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/movegen.h",
    "chars": 2131,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/movepick.cpp",
    "chars": 9254,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/movepick.h",
    "chars": 2863,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/features/full_threats.cpp",
    "chars": 12089,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/features/full_threats.h",
    "chars": 4318,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/features/half_ka_v2_hm.cpp",
    "chars": 6898,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/features/half_ka_v2_hm.h",
    "chars": 5903,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/layers/affine_transform.h",
    "chars": 12166,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/layers/affine_transform_sparse_input.h",
    "chars": 14285,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/layers/clipped_relu.h",
    "chars": 7070,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/layers/sqr_clipped_relu.h",
    "chars": 3883,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/network.cpp",
    "chars": 14589,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/network.h",
    "chars": 5262,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_accumulator.cpp",
    "chars": 40547,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_accumulator.h",
    "chars": 7900,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_architecture.h",
    "chars": 7043,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_common.h",
    "chars": 9198,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_feature_transformer.h",
    "chars": 18021,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_misc.cpp",
    "chars": 6235,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/nnue_misc.h",
    "chars": 2264,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/nnue/simd.h",
    "chars": 15568,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/numa.h",
    "chars": 62894,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/perft.h",
    "chars": 1914,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/position.cpp",
    "chars": 59522,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/position.h",
    "chars": 14128,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/score.cpp",
    "chars": 1414,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/score.h",
    "chars": 1605,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/search.cpp",
    "chars": 88402,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/search.h",
    "chars": 12884,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/shm.h",
    "chars": 20155,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/shm_linux.h",
    "chars": 19632,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/syzygy/tbprobe.cpp",
    "chars": 66895,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/syzygy/tbprobe.h",
    "chars": 2640,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/thread.cpp",
    "chars": 16591,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/thread.h",
    "chars": 6132,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/thread_win32_osx.h",
    "chars": 2461,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/timeman.cpp",
    "chars": 5372,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/timeman.h",
    "chars": 2031,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/tt.cpp",
    "chars": 8916,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/tt.h",
    "chars": 3730,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/tune.cpp",
    "chars": 3512,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/tune.h",
    "chars": 6714,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/types.h",
    "chars": 16421,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/uci.cpp",
    "chars": 22171,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/uci.h",
    "chars": 2621,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/ucioption.cpp",
    "chars": 6116,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "src/ucioption.h",
    "chars": 3204,
    "preview": "/*\n  Stockfish, a UCI chess playing engine derived from Glaurung 2.1\n  Copyright (C) 2004-2026 The Stockfish developers "
  },
  {
    "path": "tests/.gitattributes",
    "chars": 17,
    "preview": "*.sh text eol=lf\n"
  },
  {
    "path": "tests/instrumented.py",
    "chars": 21471,
    "preview": "import argparse\nimport re\nimport sys\nimport subprocess\nimport pathlib\nimport os\nimport fnmatch\n\nfrom testing import (\n  "
  },
  {
    "path": "tests/perft.sh",
    "chars": 3318,
    "preview": "#!/bin/bash\n# verify perft numbers (positions from https://www.chessprogramming.org/Perft_Results)\n\nTESTS_FAILED=0\n\nerro"
  },
  {
    "path": "tests/reprosearch.sh",
    "chars": 1276,
    "preview": "#!/bin/bash\n# verify reproducible search\n\nerror()\n{\n  echo \"reprosearch testing failed on line $1\"\n  exit 1\n}\ntrap 'erro"
  },
  {
    "path": "tests/signature.sh",
    "chars": 1064,
    "preview": "#!/bin/bash\n# obtain and optionally verify Bench / signature\n# if no reference is given, the output is deliberately limi"
  },
  {
    "path": "tests/testing.py",
    "chars": 12765,
    "preview": "import subprocess\nfrom typing import List\nimport os\nimport collections\nimport time\nimport sys\nimport traceback\nimport fn"
  }
]

About this extraction

This page contains the full source code of the official-stockfish/Stockfish GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 100 files (1017.5 KB), approximately 278.3k tokens, and a symbol index with 511 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!