Apple Silicon上的Fuego ⚫️⚪️

.package(url: "https://github.com/mesqueeb/FuegoOnAppleSilicon", from: "1.0.0")

Apple Silicon上的Fuego是用于玩和分析围棋游戏的Fuego C++ Go引擎。构建为适用于iOS、macOS和visionOS的多平台XCframework。它被封装为一个现代化的Swift包,可以包含在任何Swift项目中,并且可以在所有Apple平台上构建。

相对于原始Fuego源代码的改进

此项目

它基于原始的Source Forge上的Fuego C++代码Fuego on iOS存储库的分支。(Fuego on iOS 仅编译到 iOS,并且依赖于 GNU++98 和 Boost 1.75.0)

安装问题

通过 Xcode 14.x 安装软件包时,您可能会遇到以下错误

https://github.com/... 返回的存档无效

修复方法(来自Stack Overflow)是删除依赖项,退出 Xcode,然后执行

rm -rf $HOME/Library/Caches/org.swift.swiftpm/

然后重新打开 Xcode,重新添加该包,它应该可以正确安装。 可惜的是,每次需要更新此包时,您都需要执行此操作(直到 Xcode 修复使用二进制目标的包的此问题为止)。

用法

import FuegoOnAppleSilicon

let bridge = FuegoBridge()

do {
  try await bridge.startEngine()
  
  // You need to feed the engine GTP (Go Text Protocol) strings to be able to request moves
  try await bridge.submitCommand("boardsize 19")
  try await bridge.submitCommand("clear_board")
  try await bridge.submitCommand("komi 6.5")
  try await bridge.submitCommand("play b D16")
  
  if let whiteMove = try await bridge.submitCommand("genmove w") {
    print("Fuego plays white:", whiteMove) // Eg. "Q4"
  }
  if let boardState = try await bridge.submitCommand("showboard") {
    print("Fuego shows the board:", boardState)
  }

  // Stop the engine when you're done:
  bridge.stopEngine()
} catch {
  print("Something went wrong... error:", error)
}

该库带有一些有用的类型和辅助函数,请务必查看Swift 封装器的源代码

示例项目

存储库中提供了一个示例 Xcode 项目,您可以在此处参考:FuegoTestApp

文档

请参阅 Swift Package Index 上的渲染文档 以获取更多信息。

开发

构建 XCframework

./build-xcframework.sh

此脚本构建 gtpenginesmartgamegogouct 库,将它们合并为一个库(每个平台),并将来自不同平台的库打包到 ./build/Fuego.xcframework 中。

此脚本还会下载 Boost(在构建之前),但是,现在无需构建 Boost 库,因为需要构建的 Boost 库不再用于这些 fuego 子项目。 只有 fuegomainfuegotest 依赖于需要构建的 boost.program_options 库。 但它们不是 Fuego.xcframework 的一部分。

您可以检查此构建文件并通过将 if true; then 切换为 if false; then 来启用/禁用输出。 目前,它设置为构建

运行单元测试

build-xcframework.sh 是一个多用途构建脚本。 它还通过合并 simpleplayersunittestmain 子项目来创建另一个 FuegoTest.xcframework。 虽然 unittestmain 旨在成为一个可执行文件,但它被构建为一个静态库,其中 main 方法被重命名为具有相同签名的 run_unit_tests。 因此,任何 iOS/macOS/visionOS 应用程序都可以通过嵌入此 FuegoTest.xcframework(除了 Fuego.xcframework 之外)并调用 run_unit_tests 方法来运行 Fuego 单元测试。 这样一个应用程序的示例是 xcode\FuegoTest\FuegoTest.xcodeproj,它表示一个简单的 SwiftUI 应用程序,当单击按钮时启动测试。

致谢

Fuego on iOS 存储库是此库的灵感来源。

Alexander Pototskiy 的帮助下完成了 C++ 代码和构建脚本的现代化改造。

谢谢大家!

其他项目

另请查看 Apple Silicon 上的 Micro-Max ♟️,这是为 Apple Silicon 封装的 µ-Max 国际象棋引擎。

github.com/mesqueeb/MicroMaxOnAppleSilicon

原始 Fuego C++ README

Description
===========

Fuego is a collection of C++ libraries for developing software for the
game of Go. It includes a Go player using Monte-Carlo tree search.

The initial version of the code was released by the Computer Go group at
the University of Alberta and is based in parts on the previous projects
Smart Game Board and Explorer.

Contact
=======

Fuego project page: http://sourceforge.net/projects/fuego/

Fuego Trac and Wiki: http://sourceforge.net/apps/trac/fuego/

Copyright
=========

See AUTHORS for the list of copyright holders on Fuego.

License
=======

Fuego is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Fuego is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Fuego.  If not, see <https://gnu.ac.cn/licenses/>.

Compilation
===========

See INSTALL for generic compilation instructions from GNU Automake.
The file doc/doxygen/general/pages/autotools.cpp contains additional and
Fuego specific documentation.

Documentation
=============

The developer documentation for the libraries and applications can be
created with Doxygen (https://doxygen.cn). There is a makefile in
doc/doxygen/Makefile.

The user manual for the main Go player is in doc/manual/

AUTHORS
=======

Fuego authors
=============

Martin Mueller
Markus Enzenberger
Fan Xie

Previous authors
================

Anders Kierulf (original Smart Game Board code)

Contributors
============

David Silver (SpDumbTactic player, improvements to SgHash)
Xiaozhen Niu (parts of GoRegionUtil, GoSafetyUtil)
Broderick Arneson (autobook; many enhancements)
Richard Segal (improvements to parallel search)
Chris Rosin (additive knowledge, Greenpeep-style patterns)
Timothy Yau (Greenpeep-style patterns)
Saradha Sankaran (deterministic mode; build improvements)
Aja Huang
Jakub Pawlewicz (better hash table; df-pn code)