-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I am using ChessKitEngine to integrate Stockfish into my iOS app. I have added the nn-1111cefa1111.nnue file to my project's root folder and included it in the targets. The file was downloaded from the official Stockfish website, and I have not renamed it.
Issue
No matter how I specify the NNUE file (filename, full path, escaped spaces, etc.), the engine always fails to load it and crashes.
My Code
import Foundation
import ChessKitEngine
final class StockfishEngine {
static let shared = StockfishEngine()
private let engine = Engine(type: .stockfish)
private var isReady = false
private var pendingCompletionHandlers: [(String?) -> Void] = []
init() {
startEngine()
}
func startEngine() {
print("Starting engine initialization...")
engine.loggingEnabled = true
engine.start {
self.engine.send(command: .uci)
// Attempting to set the NNUE file
self.engine.send(command: .setoption(id: "EvalFile", value: "nn-1111cefa1111.nnue"))
let threadCount = min(ProcessInfo.processInfo.processorCount - 1, 7)
self.engine.send(command: .setoption(id: "Threads", value: String(threadCount)))
self.engine.send(command: .setoption(id: "Skill Level", value: "10"))
self.engine.send(command: .isready)
self.engine.receiveResponse = { response in
if "\(response)".contains("readyok") {
self.isReady = true
print("Stockfish Engine Started!")
self.processPendingRequests()
self.setupMoveResponseHandler()
}
}
}
}
}Error Log
Starting engine initialization...
uci
Stockfish 17 by the Stockfish developers (see AUTHORS file)
minemine
x
<id> <name> Stockfish 17
<id> <author> the Stockfish developers (see AUTHORS file)
option name Debug Log File type string default <empty>
option name Clear Hash type button
option name Ponder type check default false
option name EvalFile type string default nn-1111cefa1111.nnue
option name EvalFileSmall type string default nn-37f18f62d772.nnue
<uciok>
isready
<readyok>
setoption name EvalFile value /Users/myname/Library/Developer/CoreSimulator/Devices/D1F042AC-7361-4EBC-86B7-6FA9050F68A9/data/Containers/Bundle/Application/885F453B-3219-475A-9786-14C7DF2BFBB1/App%20Name.app/nn-1111cefa1111.nnue
setoption name Threads value 7
setoption name MultiPV value 1
uci
setoption name EvalFile value nn-1111cefa1111.nnue
setoption name Threads value 7
setoption name Skill Level value 10
isready
Stockfish Engine Started!
<info> <string> Using 7 threads
<id> <name> Stockfish 17
<id> <author> the Stockfish developers (see AUTHORS file)
option name Debug Log File type string default <empty>
option name EvalFile type string default nn-1111cefa1111.nnue
option name EvalFileSmall type string default nn-37f18f62d772.nnue
<uciok>
<info> <string> Using 7 threads
<readyok>
setoption name Skill Level value 0
ucinewgame
position fen rnbqkbnr/pppppppp/8/8/8/3P4/PPP1PPPP/RNBQKBNR b KQkq - 0 1
go depth 15
rnbqkbnr/pppppppp/8/8/8/3P4/PPP1PPPP/RNBQKBNR b KQkq - 0 1
<info> <string> Available processors: 0-7
<info> <string> Using 7 threads
<info> <string> ERROR: Network evaluation parameters compatible with the engine must be available.
<info> <string> ERROR: The network file nn-1111cefa1111.nnue was not loaded successfully.
<info> <string> ERROR:
The UCI option EvalFile might need to specify the full path, including the directory name, to the network file.
<info> <string> ERROR: The default net can be downloaded from: https://tests.stockfishchess.org/api/nn/nn-1111cefa1111.nnue
<info> <string> ERROR: The engine will be terminated now.
What I Have Tried
- Specifying just the filename:
"nn-1111cefa1111.nnue" - Using the full path:
let path = Bundle.main.path(forResource: "nn-1111cefa1111", ofType: "nnue") self.engine.send(command: .setoption(id: "EvalFile", value: path ?? ""))
- Escaping spaces in the path
- Verifying the file exists in the app bundle
Still, nothing seems to work. How can I correctly load the NNUE file for Stockfish using ChessKitEngine? I am honestly out of ideas at this point. Is it because my app name contains spaces?
Metadata
Metadata
Assignees
Labels
No labels