Name | cchess JSON |
Version |
1.24.3
JSON |
| download |
home_page | None |
Summary | ChineseChess (AKA XiangQi) library |
upload_time | 2024-08-27 05:02:00 |
maintainer | None |
docs_url | None |
author | walker8088 |
requires_python | <4.0,>=3.6 |
license | LGPL3 |
keywords |
xiangqi
xiang qi
chinesechess
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# cchess
cchess是一个Python版的中国象棋库,主要功能如下:
##棋盘显示
```
board_strs = board.text_view()
print()
for s in board_strs:
print(s)
#or
board.print_board()
```
##走子(内部格式), 中文显示
```
move = board.copy().move((0,0),(0,1))
print(move.to_text())
```
##走子(ICCS纵线格式),中文显示
```
move = board.copy().move_iccs('a0a1')
print(move.to_text())
```
##走子(中文格式,尚待完善),中文显示
```
move = board.copy().move_text('车九进一')
print(move.to_text())
```
##产生某个棋子的合法走子
```
moves = board.create_piece_moves((0,0))
for mv in moves:
move = board.copy().move(*mv)
print(move.to_text())
```
##产生所有合法走子
```
moves = board.create_moves()
for mv in moves:
move = board.copy().move(*mv)
print(move.to_text())
```
##将军检测
```
board.from_fen('3k5/9/9/9/9/3R5/9/9/9/4K4 w - - 0 1')
print(board.is_checking()) #True
```
##将死对方检测
```
print(board.is_checkmate()) #True
```
##走子被将军检测
```
board.from_fen('3k5/9/9/9/9/3R5/9/9/9/4K4 b - - 0 1')
mv = move.from_iccs('d9e9')
print(board.is_checked_move(*mv)) #True
```
##被对方将死检测
```
print(board.no_moves()) #True
```
##读取xqf文件, 显示棋谱
```
#8.读取xqf文件, 显示棋谱
game = read_from_xqf("WildHouse.xqf")
game.init_board.print_board()
board_strs = game.init_board.text_view()
print()
for s in board_strs:
print(s)
game.print_text_moves()
```
以上参见demo/demo_base.py
##加载引擎进行对弈
参见demo/end_game.py
Raw data
{
"_id": null,
"home_page": null,
"name": "cchess",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.6",
"maintainer_email": null,
"keywords": "XiangQi, Xiang Qi, ChineseChess",
"author": "walker8088",
"author_email": "walker8088@gmail.com",
"download_url": null,
"platform": null,
"description": "# cchess\n\ncchess\u662f\u4e00\u4e2aPython\u7248\u7684\u4e2d\u56fd\u8c61\u68cb\u5e93\uff0c\u4e3b\u8981\u529f\u80fd\u5982\u4e0b:\n\n##\u68cb\u76d8\u663e\u793a\n```\nboard_strs = board.text_view()\nprint()\nfor s in board_strs:\n print(s)\n#or \nboard.print_board()\n```\n\n##\u8d70\u5b50(\u5185\u90e8\u683c\u5f0f), \u4e2d\u6587\u663e\u793a\n```\nmove = board.copy().move((0,0),(0,1))\nprint(move.to_text())\n```\n\n##\u8d70\u5b50(ICCS\u7eb5\u7ebf\u683c\u5f0f),\u4e2d\u6587\u663e\u793a\n```\nmove = board.copy().move_iccs('a0a1')\nprint(move.to_text())\n```\n\n##\u8d70\u5b50(\u4e2d\u6587\u683c\u5f0f,\u5c1a\u5f85\u5b8c\u5584),\u4e2d\u6587\u663e\u793a\n```\nmove = board.copy().move_text('\u8f66\u4e5d\u8fdb\u4e00')\nprint(move.to_text())\n```\n\n##\u4ea7\u751f\u67d0\u4e2a\u68cb\u5b50\u7684\u5408\u6cd5\u8d70\u5b50\n```\nmoves = board.create_piece_moves((0,0))\nfor mv in moves:\n move = board.copy().move(*mv)\n print(move.to_text())\n```\n\n##\u4ea7\u751f\u6240\u6709\u5408\u6cd5\u8d70\u5b50\n```\nmoves = board.create_moves()\nfor mv in moves:\n move = board.copy().move(*mv)\n print(move.to_text())\n```\n\n##\u5c06\u519b\u68c0\u6d4b\n```\nboard.from_fen('3k5/9/9/9/9/3R5/9/9/9/4K4 w - - 0 1') \nprint(board.is_checking()) #True\n```\n\n##\u5c06\u6b7b\u5bf9\u65b9\u68c0\u6d4b\n```\nprint(board.is_checkmate()) #True \n```\n\n##\u8d70\u5b50\u88ab\u5c06\u519b\u68c0\u6d4b\n```\nboard.from_fen('3k5/9/9/9/9/3R5/9/9/9/4K4 b - - 0 1')\nmv = move.from_iccs('d9e9') \nprint(board.is_checked_move(*mv)) #True\n```\n\n##\u88ab\u5bf9\u65b9\u5c06\u6b7b\u68c0\u6d4b\n```\nprint(board.no_moves()) #True\n```\n\n##\u8bfb\u53d6xqf\u6587\u4ef6, \u663e\u793a\u68cb\u8c31\n```\n#8.\u8bfb\u53d6xqf\u6587\u4ef6, \u663e\u793a\u68cb\u8c31\ngame = read_from_xqf(\"WildHouse.xqf\")\ngame.init_board.print_board()\nboard_strs = game.init_board.text_view()\nprint()\nfor s in board_strs:\n print(s)\n \ngame.print_text_moves()\n```\n\n\u4ee5\u4e0a\u53c2\u89c1demo/demo_base.py\n\n##\u52a0\u8f7d\u5f15\u64ce\u8fdb\u884c\u5bf9\u5f08\n\n\u53c2\u89c1demo/end_game.py\n\n",
"bugtrack_url": null,
"license": "LGPL3",
"summary": "ChineseChess (AKA XiangQi) library",
"version": "1.24.3",
"project_urls": null,
"split_keywords": [
"xiangqi",
" xiang qi",
" chinesechess"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5b5878fd5790c3b4fbaf8ce8f71f8191820800ae4a18e99eb504ec652b924d6c",
"md5": "7c4a6c9781476431ccb860287599101b",
"sha256": "6a31d7a6f25415077f5f4199690a7aeb13a36e31ec6ed2f7f742219f8f07f5b4"
},
"downloads": -1,
"filename": "cchess-1.24.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c4a6c9781476431ccb860287599101b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.6",
"size": 80294,
"upload_time": "2024-08-27T05:02:00",
"upload_time_iso_8601": "2024-08-27T05:02:00.165751Z",
"url": "https://files.pythonhosted.org/packages/5b/58/78fd5790c3b4fbaf8ce8f71f8191820800ae4a18e99eb504ec652b924d6c/cchess-1.24.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-27 05:02:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cchess"
}