Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: khalid-a-omar/Polyfish
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 20231022
Choose a base ref
...
head repository: khalid-a-omar/Polyfish
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 17 commits
  • 61 files changed
  • 1 contributor

Commits on Nov 4, 2023

  1. Copy the full SHA
    cf4337c View commit details

Commits on Nov 7, 2023

  1. Copy the full SHA
    eb9060c View commit details

Commits on Nov 20, 2023

  1. Merge with latest Stockfish development branch (last revision SHA-1: …

    …7970236e9ea64796d5c7597cb1aedde737751f07)
    khalid-a-omar committed Nov 20, 2023
    Copy the full SHA
    5554eac View commit details

Commits on Jan 5, 2024

  1. Copy the full SHA
    42695be View commit details
  2. Merge with latest Stockfish development branch (last revision SHA-1: …

    …8b4583bce76da7d27aaa565e6302d2e540cd496a)
    khalid-a-omar committed Jan 5, 2024
    Copy the full SHA
    6ff6652 View commit details
  3. Copy the full SHA
    059a95b View commit details

Commits on Jan 11, 2024

  1. Merge with latest Stockfish development branch (last revision: 6deb88…

    …728fb141e853243c2873ad0cda4dd19320)
    khalid-a-omar committed Jan 11, 2024
    Copy the full SHA
    0fdf006 View commit details
  2. Copy the full SHA
    057cce2 View commit details

Commits on Jan 12, 2024

  1. Update README.md

    khalid-a-omar authored Jan 12, 2024
    Copy the full SHA
    64d2073 View commit details

Commits on Jan 14, 2024

  1. Merge with latest Stockfish development branch (last revision: b5e816…

    …9a85f6937d7d9d90612863fe5eec72d6ca)
    khalid-a-omar committed Jan 14, 2024
    Copy the full SHA
    bfb2654 View commit details
  2. Copy the full SHA
    a8e7eb1 View commit details

Commits on Jan 15, 2024

  1. Copy the full SHA
    4e41577 View commit details
  2. Copy the full SHA
    8706b1f View commit details
  3. Copy the full SHA
    6d613d9 View commit details
  4. Cleanup includes

    khalid-a-omar committed Jan 15, 2024
    Copy the full SHA
    b385c57 View commit details
  5. Copy the full SHA
    cbe14c4 View commit details

Commits on Jan 19, 2024

  1. Update README.md

    khalid-a-omar authored Jan 19, 2024
    Copy the full SHA
    e18d043 View commit details
Showing with 10,336 additions and 9,668 deletions.
  1. +4 −0 Polyfish.vcxproj
  2. +12 −0 Polyfish.vcxproj.filters
  3. +3 −5 README.md
  4. +71 −28 src/Makefile
  5. +45 −44 src/benchmark.cpp
  6. +3 −3 src/benchmark.h
  7. +73 −75 src/bitboard.cpp
  8. +182 −172 src/bitboard.h
  9. +5 −93 src/book/book.cpp
  10. +58 −55 src/book/book.h
  11. +98 −0 src/book/book_manager.cpp
  12. +37 −0 src/book/book_manager.h
  13. +1,005 −1,005 src/book/ctg/ctg.cpp
  14. +55 −52 src/book/ctg/ctg.h
  15. +178 −0 src/book/file_mapping.cpp
  16. +30 −0 src/book/file_mapping.h
  17. +527 −527 src/book/polyglot/polyglot.cpp
  18. +32 −30 src/book/polyglot/polyglot.h
  19. +166 −131 src/evaluate.cpp
  20. +32 −16 src/evaluate.h
  21. +5 −5 src/incbin/incbin.h
  22. +13 −22 src/main.cpp
  23. +558 −573 src/misc.cpp
  24. +110 −242 src/misc.h
  25. +80 −88 src/movegen.cpp
  26. +25 −30 src/movegen.h
  27. +309 −246 src/movepick.cpp
  28. +115 −73 src/movepick.h
  29. +259 −185 src/nnue/evaluate_nnue.cpp
  30. +43 −29 src/nnue/evaluate_nnue.h
  31. +47 −48 src/nnue/features/half_ka_v2_hm.cpp
  32. +39 −43 src/nnue/features/half_ka_v2_hm.h
  33. +217 −216 src/nnue/layers/affine_transform.h
  34. +162 −162 src/nnue/layers/affine_transform_sparse_input.h
  35. +110 −106 src/nnue/layers/clipped_relu.h
  36. +146 −168 src/nnue/layers/simd.h
  37. +50 −55 src/nnue/layers/sqr_clipped_relu.h
  38. +8 −7 src/nnue/nnue_accumulator.h
  39. +91 −84 src/nnue/nnue_architecture.h
  40. +226 −227 src/nnue/nnue_common.h
  41. +537 −523 src/nnue/nnue_feature_transformer.h
  42. +950 −980 src/position.cpp
  43. +229 −266 src/position.h
  44. +1,282 −1,271 src/search.cpp
  45. +211 −55 src/search.h
  46. +345 −298 src/syzygy/tbprobe.cpp
  47. +18 −16 src/syzygy/tbprobe.h
  48. +147 −153 src/thread.cpp
  49. +77 −96 src/thread.h
  50. +29 −26 src/thread_win32_osx.h
  51. +92 −75 src/timeman.cpp
  52. +27 −21 src/timeman.h
  53. +86 −99 src/tt.cpp
  54. +50 −50 src/tt.h
  55. +46 −53 src/tune.cpp
  56. +108 −90 src/tune.h
  57. +254 −260 src/types.h
  58. +356 −277 src/uci.cpp
  59. +67 −68 src/uci.h
  60. +115 −146 src/ucioption.cpp
  61. +81 −0 src/ucioption.h
4 changes: 4 additions & 0 deletions Polyfish.vcxproj
Original file line number Diff line number Diff line change
@@ -14,7 +14,9 @@
<ClCompile Include="src\benchmark.cpp" />
<ClCompile Include="src\bitboard.cpp" />
<ClCompile Include="src\book\book.cpp" />
<ClCompile Include="src\book\book_manager.cpp" />
<ClCompile Include="src\book\ctg\ctg.cpp" />
<ClCompile Include="src\book\file_mapping.cpp" />
<ClCompile Include="src\book\polyglot\polyglot.cpp" />
<ClCompile Include="src\evaluate.cpp" />
<ClCompile Include="src\main.cpp" />
@@ -37,7 +39,9 @@
<ClInclude Include="src\benchmark.h" />
<ClInclude Include="src\bitboard.h" />
<ClInclude Include="src\book\book.h" />
<ClInclude Include="src\book\book_manager.h" />
<ClInclude Include="src\book\ctg\ctg.h" />
<ClInclude Include="src\book\file_mapping.h" />
<ClInclude Include="src\book\polyglot\polyglot.h" />
<ClInclude Include="src\evaluate.h" />
<ClInclude Include="src\incbin\incbin.h" />
12 changes: 12 additions & 0 deletions Polyfish.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -34,6 +34,12 @@
<ClCompile Include="src\book\book.cpp">
<Filter>book</Filter>
</ClCompile>
<ClCompile Include="src\book\book_manager.cpp">
<Filter>book</Filter>
</ClCompile>
<ClCompile Include="src\book\file_mapping.cpp">
<Filter>book</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\bitboard.h" />
@@ -96,6 +102,12 @@
<ClInclude Include="src\book\book.h">
<Filter>book</Filter>
</ClInclude>
<ClInclude Include="src\book\book_manager.h">
<Filter>book</Filter>
</ClInclude>
<ClInclude Include="src\book\file_mapping.h">
<Filter>book</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="src\Makefile" />
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -22,9 +22,7 @@ This distribution of Polyfish consists of the following files:

## UCI options

Polyfish supports all UCI options supported by Stockfish. *Click [here](https://github.com/official-stockfish/Stockfish/blob/master/README.md#the-uci-protocol-and-available-options) to see the full list of supported Stockfish UCI options*

Polyfish also supports the following UCI options
The following is a list of options supported by Polyfish (on top of all UCI options supported by Stockfish)
* #### CTG/BIN Book 1 File
The file name of the first book file which could be a polyglot (BIN) or Chessbase (CTG) book. To disable this book, use: ```<empty>```
If the book (CTG or BIN) is in a different directory than the engine executable, then configure the full path of the book file, example:
@@ -54,7 +52,7 @@ Polyfish also supports the following UCI options


## UCI commands
Polyfish supports all UCI commands supported by Stockfish. *Click [here](https://github.com/official-stockfish/Stockfish/blob/master/README.md#the-uci-protocol-and-available-options) to see the full list of supported Stockfish UCI commands*
Polyfish supports all UCI commands supported by Stockfish. *Click [here](https://github.com/official-stockfish/Stockfish/wiki/UCI-&-Commands) to see the full list of supported Stockfish UCI commands*

Polyfish also supports the following UCI commands

@@ -168,5 +166,5 @@ If no Green moves are found in the configured CTG book, then engine will check
<br/><br/>If it is allowed to play a non Green move, then the engine will calculate the weights of available moves (as described earlier) and play one of the top weight moves depending the configured value of ```Book 1 Width``` or (```Book 2 Width```)
<br/><br/>

- **<ins>What effect does the options ```(CTG) Book 1 Only Green``` and ```(CTG) Book 2 Only Green<``` have on my Polyglot (BIN) book?</ins>**<br/>
- **<ins>What effect does the options ```(CTG) Book 1 Only Green``` and ```(CTG) Book 2 Only Green``` have on my Polyglot (BIN) book?</ins>**<br/>
The options ```(CTG) Book 1 Only Green``` and ```(CTG) Book 2 Only Green``` do not have any effect on BIN books so it does not matter if they are checked (true) or unchecked (false). Use these two options only for CTG books
99 changes: 71 additions & 28 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Polyfish, a UCI chess playing engine derived from Stockfish
# Copyright (C) 2022-2023 The Polyfish developers (see AUTHORS file)
# Copyright (C) 2022-2024 The Polyfish developers (see AUTHORS file)
#
# Polyfish is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,9 +20,9 @@
### ==========================================================================

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

### Target Windows OS
@@ -33,7 +33,7 @@ ifeq ($(OS),Windows_NT)
else ifeq ($(COMP),mingw)
target_windows = yes
ifeq ($(WINE_PATH),)
WINE_PATH = $(shell which wine)
WINE_PATH := $(shell which wine)
endif
endif

@@ -50,7 +50,7 @@ BINDIR = $(PREFIX)/bin

### Built-in benchmark for pgo-builds
ifeq ($(SDE_PATH),)
PGOBENCH = $(WINE_PATH) ./$(EXE) bench
PGOBENCH = $(WINE_PATH) ./$(EXE) bench
else
PGOBENCH = $(SDE_PATH) -icx -- $(WINE_PATH) ./$(EXE) bench
endif
@@ -60,7 +60,15 @@ 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/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp \
book/book.cpp book/polyglot/polyglot.cpp book/ctg/ctg.cpp
book/file_mapping.cpp book/book.cpp book/book_manager.cpp book/polyglot/polyglot.cpp book/ctg/ctg.cpp

#HEADERS = benchmark.h bitboard.h evaluate.h misc.h movegen.h movepick.h \
# nnue/evaluate_nnue.h nnue/features/half_ka_v2_hm.h nnue/layers/affine_transform.h \
# nnue/layers/affine_transform_sparse_input.h nnue/layers/clipped_relu.h nnue/layers/simd.h \
# nnue/layers/sqr_clipped_relu.h nnue/nnue_accumulator.h nnue/nnue_architecture.h \
# nnue/nnue_common.h nnue/nnue_feature_transformer.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

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

@@ -113,7 +121,7 @@ VPATH = syzygy:nnue:nnue/features:book:book/polyglot:book/ctg
#endif

#ifeq ($(ARCH), native)
# override ARCH = $(shell $(SHELL) ../scripts/get_native_properties.sh | cut -d " " -f 1)
# 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),
@@ -122,7 +130,7 @@ ifeq ($(ARCH), $(filter $(ARCH), \
x86-64-vnni512 x86-64-vnni256 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-32 e2k \
armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64))
armv7 armv7-neon armv8 armv8-dotprod apple-silicon general-64 general-32 riscv64 loongarch64))
SUPPORTED_ARCH=true
else
SUPPORTED_ARCH=false
@@ -150,6 +158,12 @@ dotprod = no
arm_version = 0
STRIP = strip

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

### 2.2 Architecture specific

ifeq ($(findstring x86,$(ARCH)),x86)
@@ -360,6 +374,10 @@ endif
ifeq ($(ARCH),riscv64)
arch = riscv64
endif

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


@@ -374,7 +392,7 @@ ifeq ($(MAKELEVEL),0)
export ENV_LDFLAGS := $(LDFLAGS)
endif

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

@@ -395,6 +413,8 @@ ifeq ($(COMP),gcc)
ifeq ($(ARCH),riscv64)
CXXFLAGS += -latomic
endif
else ifeq ($(ARCH),loongarch64)
CXXFLAGS += -latomic
else
CXXFLAGS += -m$(bits)
LDFLAGS += -m$(bits)
@@ -465,6 +485,8 @@ ifeq ($(COMP),clang)
ifeq ($(ARCH),riscv64)
CXXFLAGS += -latomic
endif
else ifeq ($(ARCH),loongarch64)
CXXFLAGS += -latomic
else
CXXFLAGS += -m$(bits)
LDFLAGS += -m$(bits)
@@ -504,6 +526,14 @@ ifeq ($(COMP),ndk)
STRIP=llvm-strip
endif
endif
ifeq ($(arch),x86_64)
CXX=x86_64-linux-android21-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++ -pie -lm -latomic
endif

@@ -533,8 +563,8 @@ endif

### Sometimes gcc is really clang
ifeq ($(COMP),gcc)
gccversion = $(shell $(CXX) --version 2>/dev/null)
gccisclang = $(findstring clang,$(gccversion))
gccversion := $(shell $(CXX) --version 2>/dev/null)
gccisclang := $(findstring clang,$(gccversion))
ifneq ($(gccisclang),)
profile_make = clang-profile-make
profile_use = clang-profile-use
@@ -592,7 +622,7 @@ ifeq ($(optimize),yes)
endif

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

### 3.8.1 Try to include git commit sha for versioning
GIT_SHA = $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
ifneq ($(GIT_SHA), )
CXXFLAGS += -DGIT_SHA=$(GIT_SHA)
endif

### 3.8.2 Try to include git commit date for versioning
GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
GIT_DATE := $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
ifneq ($(GIT_DATE), )
CXXFLAGS += -DGIT_DATE=$(GIT_DATE)
endif
@@ -781,7 +811,7 @@ help:
@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 net"
@echo "net > Download the default nnue nets"
@echo "strip > Strip executable"
@echo "install > Install executable"
@echo "clean > Clean up"
@@ -814,6 +844,7 @@ help:
@echo "general-64 > unspecified 64-bit"
@echo "general-32 > unspecified 32-bit"
@echo "riscv64 > RISC-V 64-bit"
@echo "loongarch64 > LoongArch 64-bit"
@echo ""
@echo "Supported compilers:"
@echo ""
@@ -845,7 +876,8 @@ endif
objclean profileclean config-sanity \
icx-profile-use icx-profile-make \
gcc-profile-use gcc-profile-make \
clang-profile-use clang-profile-make FORCE
clang-profile-use clang-profile-make FORCE \
format analyze

analyze: net config-sanity objclean
$(MAKE) -k ARCH=$(ARCH) COMP=$(COMP) $(OBJS)
@@ -894,16 +926,7 @@ profileclean:
@rm -f Polyfish.res
@rm -f ./-lstdc++.res

# set up shell variables for the net stuff
netvariables:
$(eval nnuenet := $(shell grep EvalFileDefaultName evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
$(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
$(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
$(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
$(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))

# evaluation network (nnue)
net: netvariables
define fetch_network
@echo "Default net: $(nnuenet)"
@if [ "x$(curl_or_wget)" = "x" ]; then \
echo "Neither curl nor wget is installed. Install one of these tools unless the net has been downloaded manually"; \
@@ -938,7 +961,27 @@ net: netvariables
if [ "$(nnuenet)" = "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
echo "Network validated"; break; \
fi; \
fi; \
fi;
endef

# set up shell variables for the net stuff
define netvariables
$(eval nnuenet := $(shell grep $(1) evaluate.h | grep define | sed 's/.*\(nn-[a-z0-9]\{12\}.nnue\).*/\1/'))
$(eval nnuedownloadurl1 := https://tests.stockfishchess.org/api/nn/$(nnuenet))
$(eval nnuedownloadurl2 := https://github.com/official-stockfish/networks/raw/master/$(nnuenet))
$(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
$(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))
endef

# evaluation network (nnue)
net:
$(call netvariables, EvalFileDefaultNameBig)
$(call fetch_network)
$(call netvariables, EvalFileDefaultNameSmall)
$(call fetch_network)

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

# default target
default:
@@ -990,7 +1033,7 @@ config-sanity: net
@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)" = "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"
Loading