S人ving Privàte Ryän

Fixes problems with non-ASCII characters in paths. Fixes #3424.

Changes
- Bump the minimum supported Clang version to 11 to support std::filesystem
- Use std::optional for empty values instead of string sentinels like "None"
- Remove the FixedString class
- Move the EvalFile network path from the network struct to the engine
- Simplify parts of the command-line handling
- Remove the old dual-net logic from export_net
- And ofc we now support non-ascii paths for windows

Behavior Change
- Because the EvalFile is no longer part of the network, it won't be included in the hashing, thus the network sharing is no longer dependent on the EvalFile path
- As a result, if the binary version and network are the same, changing only the EvalFile location will now reuse the same shared network

This also fixes a master bug where:

```
export_net None
setoption name EvalFile value None
export_net None
Failed to export a net
```

would fail on the second export. With this patch, the second export succeeds.

Quick Fishtest Check that nets load like normal.
https://tests.stockfishchess.org/tests/view/6a455593f97ff95f787954da

<img width="833" height="1137" alt="image" src="https://github.com/user-attachments/assets/fffee63b-c63a-4d5e-b13d-87d58bc28c88" />

closes https://github.com/official-stockfish/Stockfish/pull/6937

No functional change

Co-authored-by: anematode <timothy.herchen@gmail.com>
This commit is contained in:
Disservin
2026-07-06 11:30:51 +02:00
committed by Joost VandeVondele
co-authored by anematode
parent d5bbc6b67d
commit 22548cb0c0
14 changed files with 240 additions and 254 deletions
+10 -7
View File
@@ -26,6 +26,7 @@
#include <optional>
#include <sstream>
#include <string_view>
#include <filesystem>
#include <utility>
#include <vector>
@@ -63,9 +64,9 @@ void UCIEngine::print_info_string(std::string_view str) {
sync_cout_end();
}
UCIEngine::UCIEngine(int argc, char** argv) :
engine(argv[0]),
cli(argc, argv) {
UCIEngine::UCIEngine(CommandLine cli_) :
engine(cli_.argc > 0 ? std::optional{path_from_utf8(cli_.argv[0])} : std::nullopt),
cli(std::move(cli_)) {
engine.get_options().add_info_listener([](const std::optional<std::string>& str) {
if (str.has_value())
@@ -85,6 +86,7 @@ void UCIEngine::init_search_update_listeners() {
}
void UCIEngine::loop() {
set_console_utf8();
std::string token, cmd;
for (int i = 1; i < cli.argc; ++i)
@@ -151,10 +153,11 @@ void UCIEngine::loop() {
sync_cout << compiler_info() << sync_endl;
else if (token == "export_net")
{
std::pair<std::optional<std::string>, std::string> file;
std::optional<std::filesystem::path> file;
std::string filename;
if (is >> file.second)
file.first = file.second;
if (is >> filename)
file = path_from_utf8(filename);
engine.save_network(file);
}
@@ -171,7 +174,7 @@ void UCIEngine::loop() {
sync_cout << "Unknown command: '" << cmd << "'. Type help for more information."
<< sync_endl;
} while (token != "quit" && cli.argc == 1); // The command-line arguments are one-shot
} while (token != "quit" && cli.argc <= 1); // The command-line arguments are one-shot
}
Search::LimitsType UCIEngine::parse_limits(std::istream& is) {