24.6 C
New York
Saturday, March 29, 2025

ios – Stockfish NNUE file not loading in ChessKitEngine


I’m utilizing ChessKitEngine to combine Stockfish into my iOS app. I’ve added the nn-1111cefa1111.nnue file to my challenge’s root folder and included it within the targets. The file was downloaded from the official Stockfish web site, and I’ve not renamed it.

Difficulty

Regardless of how I specify the NNUE file (filename, full path, escaped areas, and so on.), the engine all the time fails to load it and crashes.

My Code

import Basis
import ChessKitEngine

remaining class StockfishEngine {
    static let shared = StockfishEngine()
    personal let engine = Engine(sort: .stockfish)
    personal var isReady = false
    personal var pendingCompletionHandlers: [(String?) -> Void] = []

    init() {
        startEngine()
    }

    func startEngine() {
        print("Beginning engine initialization...")
        engine.loggingEnabled = true
        engine.begin {
            self.engine.ship(command: .uci)
            
            // Trying to set the NNUE file
            self.engine.ship(command: .setoption(id: "EvalFile", worth: "nn-1111cefa1111.nnue"))
            
            let threadCount = min(ProcessInfo.processInfo.processorCount - 1, 7)
            self.engine.ship(command: .setoption(id: "Threads", worth: String(threadCount)))
            self.engine.ship(command: .setoption(id: "Talent Stage", worth: "10"))
            
            self.engine.ship(command: .isready)
            
            self.engine.receiveResponse = { response in
                if "(response)".comprises("readyok") {
                    self.isReady = true
                    print("Stockfish Engine Began!")
                    self.processPendingRequests()
                    self.setupMoveResponseHandler()
                }
            }
        }
    }
}

Error Log

Beginning engine initialization...
uci
Stockfish 17 by the Stockfish builders (see AUTHORS file)
minemine
x
  Stockfish 17
  the Stockfish builders (see AUTHORS file)
possibility title Debug Log File sort string default 
possibility title Clear Hash sort button
possibility title Ponder sort test default false
possibility title EvalFile sort string default nn-1111cefa1111.nnue
possibility title EvalFileSmall sort string default nn-37f18f62d772.nnue

isready

setoption title EvalFile worth /Customers/myname/Library/Developer/CoreSimulator/Units/D1F042AC-7361-4EBC-86B7-6FA9050F68A9/knowledge/Containers/Bundle/Software/885F453B-3219-475A-9786-14C7DF2BFBB1/Apppercent20Name.app/nn-1111cefa1111.nnue
setoption title Threads worth 7
setoption title MultiPV worth 1
uci
setoption title EvalFile worth nn-1111cefa1111.nnue
setoption title Threads worth 7
setoption title Talent Stage worth 10
isready
Stockfish Engine Began!
  Utilizing 7 threads
  Stockfish 17
  the Stockfish builders (see AUTHORS file)
possibility title Debug Log File sort string default 
possibility title EvalFile sort string default nn-1111cefa1111.nnue
possibility title EvalFileSmall sort string default nn-37f18f62d772.nnue

  Utilizing 7 threads

setoption title Talent Stage worth 0
ucinewgame
place 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
  Out there processors: 0-7
  Utilizing 7 threads
  ERROR: Community analysis parameters appropriate with the engine have to be out there.
  ERROR: The community file nn-1111cefa1111.nnue was not loaded efficiently.
  ERROR:
The UCI possibility EvalFile would possibly have to specify the total path, together with the listing title, to the community file.
  ERROR: The default internet may be downloaded from: https://assessments.stockfishchess.org/api/nn/nn-1111cefa1111.nnue
  ERROR: The engine can be terminated now.

What I Have Tried

  • Specifying simply the filename: "nn-1111cefa1111.nnue"
  • Utilizing the total path:
    let path = Bundle.essential.path(forResource: "nn-1111cefa1111", ofType: "nnue")
    self.engine.ship(command: .setoption(id: "EvalFile", worth: path ?? ""))
    
  • Escaping areas within the path
  • Verifying the file exists within the app bundle

Nonetheless, nothing appears to work. How can I appropriately load the NNUE file for Stockfish utilizing ChessKitEngine?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles