Skip to content

Commit

Permalink
Update to Stockfish 17 and Lc0 0.31.1 (chesskit-app#17)
Browse files Browse the repository at this point in the history
* Updated to Stockfish 17 (see chesskit-app/Stockfish#4).
* Updated to Lc0 0.31.1 (see chesskit-app/lc0#7).
* Improved engine setup tests to include version number check

> [!NOTE]
> Update `README.md` with suggested Stockfish 17 NNUE file names before
next release.
  • Loading branch information
pdil authored Sep 10, 2024
2 parents 034648b + c7e1002 commit 0c8cd37
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# [unreleased]

### Engine Upgrades
* Update to [*Stockfish 17*](https://stockfishchess.org/blog/2024/stockfish-17).
* Update to [*LeelaChessZero 0.31.1*](https://github.com/LeelaChessZero/lc0/releases/tag/v0.31.1).

### Improvements
* `Engine.type` is now exposed publicly.

Expand Down
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ package.targets.first { $0.name == "ChessKitEngineCore" }?.exclude = [
"Engines/lc0/src/neural/cuda/",
"Engines/lc0/src/neural/dx/",
"Engines/lc0/src/neural/metal/",
"Engines/lc0/src/neural/network_tf_cc.cc",
"Engines/lc0/src/neural/onednn/",
"Engines/lc0/src/neural/onnx/",
"Engines/lc0/src/neural/opencl/",
"Engines/lc0/src/neural/network_tf_cc.cc"
"Engines/lc0/src/neural/xla/",
"Engines/lc0/src/rescorer/",
"Engines/lc0/src/rescorer_main.cc"
]
16 changes: 8 additions & 8 deletions Sources/ChessKitEngine/EngineType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ public enum EngineType: Int {
/// Internal mapping from Swift to Obj-C type.
var objc: EngineType_objc {
switch self {
case .stockfish: return .stockfish
case .lc0: return .lc0
case .stockfish: .stockfish
case .lc0: .lc0
}
}

/// The user-readable name of the engine.
public var name: String {
switch self {
case .stockfish: return "Stockfish"
case .lc0: return "LeelaChessZero (Lc0)"
case .stockfish: "Stockfish"
case .lc0: "LeelaChessZero (Lc0)"
}
}

/// The current version of the given engine.
public var version: String {
switch self {
case .stockfish: return "16.1"
case .lc0: return "0.30"
case .stockfish: "17"
case .lc0: "0.31.1"
}
}

Expand All @@ -40,8 +40,8 @@ public enum EngineType: Int {
switch self {
case .stockfish:
let fileOptions = [
"EvalFile": "nn-b1a57edbea57",
"EvalFileSmall": "nn-baff1ede1f90"
"EvalFile": "nn-1111cefa1111",
"EvalFileSmall": "nn-37f18f62d772"
].compactMapValues {
Bundle.main.url(forResource: $0, withExtension: "nnue")?.path()
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChessKitEngineCore/Engines/Stockfish
Submodule Stockfish updated 66 files
+1 −0 .github/ci/libcxx17.imp
+0 −51 .github/workflows/clang-format.yml
+0 −53 .github/workflows/codeql.yml
+0 −89 .github/workflows/compilation.yml
+0 −47 .github/workflows/iwyu.yml
+0 −21 .github/workflows/stockfish.yml
+0 −299 .github/workflows/tests.yml
+0 −105 .github/workflows/upload_binaries.yml
+7 −0 AUTHORS
+1 −1 CONTRIBUTING.md
+104 −89 Top CPU Contributors.txt
+10 −15 src/Makefile
+3 −7 src/_main.cpp
+3 −5 src/benchmark.cpp
+2 −4 src/benchmark.h
+7 −1 src/bitboard.cpp
+335 −0 src/engine.cpp
+128 −0 src/engine.h
+46 −166 src/evaluate.cpp
+14 −29 src/evaluate.h
+237 −0 src/memory.cpp
+216 −0 src/memory.h
+88 −350 src/misc.cpp
+56 −34 src/misc.h
+15 −39 src/movegen.cpp
+0 −1 src/movegen.h
+32 −100 src/movepick.cpp
+16 −27 src/movepick.h
+0 −482 src/nnue/evaluate_nnue.cpp
+0 −93 src/nnue/evaluate_nnue.h
+3 −1 src/nnue/features/half_ka_v2_hm.cpp
+4 −4 src/nnue/features/half_ka_v2_hm.h
+28 −30 src/nnue/layers/affine_transform.h
+22 −26 src/nnue/layers/clipped_relu.h
+0 −33 src/nnue/layers/simd.h
+455 −0 src/nnue/network.cpp
+132 −0 src/nnue/network.h
+67 −3 src/nnue/nnue_accumulator.h
+2 −7 src/nnue/nnue_architecture.h
+337 −123 src/nnue/nnue_feature_transformer.h
+203 −0 src/nnue/nnue_misc.cpp
+64 −0 src/nnue/nnue_misc.h
+1,345 −0 src/numa.h
+4 −5 src/perft.h
+16 −16 src/position.cpp
+3 −3 src/position.h
+48 −0 src/score.cpp
+70 −0 src/score.h
+753 −580 src/search.cpp
+125 −36 src/search.h
+41 −16 src/syzygy/tbprobe.cpp
+5 −2 src/syzygy/tbprobe.h
+186 −75 src/thread.cpp
+85 −28 src/thread.h
+42 −28 src/timeman.cpp
+11 −4 src/timeman.h
+150 −53 src/tt.cpp
+47 −59 src/tt.h
+37 −29 src/tune.cpp
+3 −1 src/tune.h
+22 −12 src/types.h
+238 −164 src/uci.cpp
+30 −30 src/uci.h
+35 −9 src/ucioption.cpp
+48 −25 src/ucioption.h
+115 −13 tests/instrumented.sh
2 changes: 1 addition & 1 deletion Sources/ChessKitEngineCore/Engines/lc0
Submodule lc0 updated 114 files
36 changes: 19 additions & 17 deletions Tests/ChessKitEngineTests/EngineTests/BaseEngineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import XCTest
/// Subclass `BaseEngineTests`, set `engineType` in `setUp()`,
/// and then call `super.setUp()` to run common engine tests.
///
/// For example:
///
/// ```
/// #### Example
/// ``` swift
/// final class MyEngineTests: BaseEngineTests {
///
/// func override setUp() {
Expand All @@ -24,7 +23,7 @@ import XCTest
/// }
/// ```
class BaseEngineTests: XCTestCase {

override class var defaultTestSuite: XCTestSuite {
// Disable tests in base test case with empty XCTestSuite
if self == BaseEngineTests.self {
Expand All @@ -33,38 +32,41 @@ class BaseEngineTests: XCTestCase {
return super.defaultTestSuite
}
}

/// The engine type to test.
var engineType: EngineType!
/// The expected evaluation range for the engine in
/// the standard starting position.
var expectedStartingEvaluation: ClosedRange<Double> = 1...60

var engine: Engine!

override func setUp() {
super.setUp()

engine = Engine(type: engineType)
}

override func tearDown() {
engine.stop()
engine = nil
super.tearDown()
}

func testEngineSetup() {
let expectation = self.expectation(description: "Expect engine \(engine.type.name) to start up.")
let expectation = self.expectation(
description: "Expect engine \(engine.type.name) to start up."
)

engine.receiveResponse = { [weak self] response in
guard let self else { return }

engine.receiveResponse = {
if $0 == .readyok {
if case let .id(id) = response, case let .name(name) = id {
XCTAssertTrue(name.contains(engine.type.version))
}

if response == .readyok {
expectation.fulfill()
}
}

engine.start()
wait(for: [expectation], timeout: 5)
}

}
2 changes: 1 addition & 1 deletion Tests/ChessKitEngineTests/EngineTests/Lc0Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ final class Lc0Tests: BaseEngineTests {
engineType = .lc0
super.setUp()
}

}
22 changes: 12 additions & 10 deletions Tests/ChessKitEngineTests/EngineTests/StockfishTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// ChessKitEngineTests
//

import XCTest
@testable import ChessKitEngine
//import XCTest
//@testable import ChessKitEngine
//
//final class StockfishTests: BaseEngineTests {
//
// override func setUp() {
// engineType = .stockfish
// super.setUp()
// }
//
//}

final class StockfishTests: BaseEngineTests {

override func setUp() {
engineType = .stockfish
super.setUp()
}

}
// ↑↑ Failing in CI since update to Stockfish 17 - to be investigated. ↑↑

0 comments on commit 0c8cd37

Please sign in to comment.