Skip to main content

fungame

这是一个游戏相关代码的杂货仓库(umbrella 仓库),把几个互不相关的小项目放在一起维护,不是一个统一封装的游戏 SDK。

  • src/fungame/games/ 下是实际代码:
    • fungame.games.nonogram —— 数织(Nonogram)自动求解器,含棋盘建模、多种求解算法(solver/bgu.py、solver/simpson.py、solver/machine.py 等)和 ASCII 渲染器。
    • fungame.games.sudoku —— 数独的生成/求解代码(Sudoku 类 + sudoku_generate / sudoku_solve_solution 等函数)。
    • fungame.games.topwar —— 针对手游《Top War》的自动化脚本(实体建模、请求/响应封装、任务/礼包码等),依赖 funsecret 中预先配置好的账号凭据。
    • fungame.shumo —— 一次数学建模比赛(UWB 定位数据分析)的解题脚本,属于一次性代码,未再维护;相关的 xgboost 依赖只在安装 fungame[shumo] extra 时才会拉取。
  • src/notegame/ 是一层把 notegame 前缀转发到 fungame 的兼容模块,只存在于源码仓库,不随 PyPI 的 fungame 包发布;导入路径一律写 fungame(详见下文「notegame 前缀的兼容层」)。

安装

# 安装已发布的游戏合集:
pip install fungame

# 如果需要运行 shumo 下的建模脚本(依赖 xgboost):
pip install "fungame[shumo]"

快速开始

from fungame.games.sudoku.core import sudoku_generate, sudoku_check_solution

# 生成一个 9x9 数独题目(mask_rate 控制挖空比例,默认 0.5)
puzzle = sudoku_generate(mask_rate=0.5)
print(puzzle)

# 校验一个完整数独解是否合法
full_solution = sudoku_generate(mask_rate=0.0)
assert sudoku_check_solution(full_solution.tolist())
from fungame.games.nonogram.solver.simpson import FastSolver
from fungame.games.nonogram.core.common import UNKNOWN

# 求解长度为 5、只有一个长度为 3 的色块的一行数织线索
line = [UNKNOWN] * 5
solved = FastSolver.solve([3], line)
print(solved)

notegame 前缀的兼容层

src/notegame/ 下的转发模块让 import notegame 仍然可用:它发出 DeprecationWarning 后转发到 fungame,模块路径与 API 一一对应,把前缀换掉即可。

from notegame.games.sudoku.core import sudoku_generate   # 已废弃
from fungame.games.sudoku.core import sudoku_generate    # 用这个
  • 不随包发布:这层转发只存在于源码仓库,pip install fungame 装不到它 (见 pyproject.toml 的 [tool.hatch.build.targets.wheel])。
  • 移除版本:将在 fungame 2.0.0 中删除。
  • PyPI 上的 notegame 是另一个发行包:最新版 0.5.18(2021-12-02), 只声明 tqdm 一个依赖,既不依赖也不转发到 fungame,装到的是一套独立的旧代码。 要用本仓库的 API 只能装 fungame。是否给 notegame 补发一个转发版属于仓库 所有者的发布决策,跟踪见 farfarfun/todo-list。

第三方代码与许可证

fungame.games.nonogram(src/fungame/games/nonogram/)不是本组织原创代码, 它派生自第三方开源项目:

项目 上游地址 原始作者 原始协议
pynogram https://github.com/tsionyx/pynogram Ivan L (tsionyx) Apache License 2.0
  • 该子包在本仓库中的使用范围:重命名顶层包、移除 six 兼容层、日志改用 farlog、 用 functools.lru_cache 替换已不可用的 memoized,并随 fungame 一起发布。 完整的变更说明见 src/fungame/games/nonogram/NOTICE, Apache-2.0 全文见 src/fungame/games/nonogram/LICENSE。
  • examples/nonogram/ 是上游项目的文档、示例棋盘、基准数据与测试用例,同为 Apache-2.0, 仅作参考保留在源码仓库,不参与构建与发布(见 examples/nonogram/NOTICE)。

本项目以 MIT 协议发布;games/nonogram 子包继续保留上游的 Apache-2.0 许可证、版权声明和 NOTICE。

关于 farfarfun

farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。

本项目基于 MIT 协议开源。

Metadata

Release files for fungame 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fungame 1.1.0
File Size Uploaded Provenance Actions
fungame-1.1.0.tar.gz 1.0 MB Without provenance Details for fungame-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fungame 1.1.0
File Interpreter ABI Platform Actions
fungame-1.1.0-py3-none-any.whl Python 3 none any Details for fungame-1.1.0-py3-none-any.whl

Total release size: 1.1 MB

Release files / fungame-1.1.0.tar.gz

Download URL fungame-1.1.0.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
cc0eb847b827c70b9e80ed969f2055a623663bed9028797738864b2f3b1af6f0
BLAKE2b-256 checksum
How to use checksums
01b2afbbaf7fc4fc4434262e7da55ae36625b5ecdf515aec1dfa7f70fbca25a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / fungame-1.1.0-py3-none-any.whl

Download URL fungame-1.1.0-py3-none-any.whl
Size 110.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c6c2118a35f44adcbdeac665c3582fb99cd6c8db4c0ba99985e94c25d1c58f5
BLAKE2b-256 checksum
How to use checksums
60d879123ad9b3b6a4df53cc645e28ecf8b869110f2baf715ad294d052198f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for fungame 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page