{"id":20833466,"url":"https://github.com/bupticybee/elephantfish","last_synced_at":"2025-04-12T20:42:14.548Z","repository":{"id":61131078,"uuid":"244955869","full_name":"bupticybee/elephantfish","owner":"bupticybee","description":"elephantfish: 一个只有124行的中国象棋引擎","archived":false,"fork":false,"pushed_at":"2025-01-27T01:59:59.000Z","size":28446,"stargazers_count":250,"open_issues_count":0,"forks_count":47,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T02:35:20.127Z","etag":null,"topics":["chess","chess-engine","chinese-chess","chinese-chess-engine","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bupticybee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-04T16:59:08.000Z","updated_at":"2025-03-30T14:25:18.000Z","dependencies_parsed_at":"2025-03-04T09:00:23.663Z","dependency_job_id":"6c9e4c06-69dc-47a1-837d-aca5e0b378dc","html_url":"https://github.com/bupticybee/elephantfish","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bupticybee%2Felephantfish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bupticybee%2Felephantfish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bupticybee%2Felephantfish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bupticybee%2Felephantfish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bupticybee","download_url":"https://codeload.github.com/bupticybee/elephantfish/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631668,"owners_count":21136554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","chess-engine","chinese-chess","chinese-chess-engine","python"],"created_at":"2024-11-18T00:15:38.047Z","updated_at":"2025-04-12T20:42:14.527Z","avatar_url":"https://github.com/bupticybee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Elephantfish](logo/elephantfish.jpg)\n\n## 介绍 \n\nelephantfish 是受到 [sunfish](https://github.com/thomasahle/sunfish) 启发而撰写的纯python的中国象棋引擎， 整个象棋引擎核心代码只有124行（见[compressed.py](compressed.py)）,棋力方面我仅进行过其与象棋小巫师傻瓜难度的一场对局，在我测试的对剧中，elephantfish赢得了比赛。\n\n在几天前看到了[sunfish](https://github.com/thomasahle/sunfish)这个项目(是一个国际象棋引擎，只有111行)，觉得很有意思，于是做了一个类似中国象棋版本，中国象棋和国际象棋略有不同，我仅仅单独完成了棋规部分，子力价值表直接的参考了 [象眼](https://www.xqbase.com/league/elephanteye.htm) ,mtd search部分的代码由于原版sunfish写的非常通用，我也就一行未改。\n\n如果你对于程序中的mtd search看不懂建议先看一些对弈基础理论,比如articles下的几篇文章，如[对弈程序基本技术](articles/对弈程序基本技术.pdf)，其官方网址：https://www.xqbase.com/computer/outline.htm\n\nelephantfish默认会进行5秒钟的思考，当然实际一般会比5秒多一些，如果你想要它进行更长时间搜索以获得更好的性能可以对源码相应位置进行更改。\n\n如同sunfish一样，我认为elephantfish会是一个很好的平台，由于其代码非常少，可以很方便的进行各种实验，希望各位感兴趣的同学可以尝试对其进行优化. 如果在优化后想要评估和目前版本的棋力差别，可以使用test.py中的self_arena来将你的代码和elephantfish进行对弈。\n\n如果你觉得这个版本的象棋ai实力不够强，可以看看 [XQpy](https://github.com/bupticybee/XQPy)\n\n## 运行截图\n\n    Think depth: 6 My move: b9c7\n\n      9 俥．象士将士象傌俥\n      8 ．．．．．．．．．\n      7 ．砲傌．．．．砲．\n      6 卒．卒．卒．卒．卒\n      5 ．．．．．．．．．\n      4 ．．．．．．．．．\n      3 兵．兵．兵．兵．兵\n      2 ．炮．．炮．．．．\n      1 ．．．．．．．．．\n      0 车马相仕帅仕相马车\n        ａｂｃｄｅｆｇｈｉ\n        \n    Your move:\n\n\nWeb UI:\n\n\n![UI](ui/snapshot.png)\n\n# 运行elephantfish!\n\nelephahtfish 自包含在 `elephantfish.py` 文件中，只是用了python的自带操作而没有使用任何第三方库. 建议使用 `pypy` 或者 `pypy3` 来获得更好的性能表现.\n\n简单的使用命令```python elephantfish.py``` 或者```pypy elephantfish.py``` 就可以运行象棋程序,程序会利用自带一个命令行工具进行对局.\n\n如果以 Web UI 方式下棋，用命令行启动服务 `python ui-server.py`，程序监听HTTP 8000端口，浏览器打开 `ui/chess.html` 即可，行棋时前端以 HTTP Post 方式与服务交互。\n\n# 特性\n\n1. 使用简单而高效的 MTD 二分搜索算法（见[对弈程序基本技术](articles/对弈程序基本技术.pdf)）.\n2. 使用众所周知的现代象棋引擎trick 比如空着裁剪.\n3. 通过简单的子力价值表进行局面评估.\n4. 使用python标准数据结构.\n\n# License\n\n[GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbupticybee%2Felephantfish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbupticybee%2Felephantfish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbupticybee%2Felephantfish/lists"}