Skip to main content

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文件, 显示棋谱

game = Game.read_from("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()

##读取cbr文件, 显示棋谱

game = Game.read_from("WildHouse.cbr")
game.init_board.print_board()
board_strs = game.init_board.text_view()
print()
for s in board_strs:
    print(s)
    
game.print_text_moves()

##读取cbl文件, 显示所有棋谱

lib = Game.read_from_lib("WildHouse.cbl")
for game in lib['games']:
    game.init_board.print_board()
    board_strs = game.init_board.text_view()
    print()
    for s in board_strs:
        print(s)
        
    game.print_text_moves()

##加载引擎进行对弈 支持 UCCI引擎(eyeele “象眼”引擎)和UCI引擎(pikafish “皮卡鱼”引擎) 参见demo/end_game_master.py

Release files for cchess 1.25.5

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

Source distribution (sdist)

Source distribution for cchess 1.25.5
File Size Uploaded
cchess-1.25.5.tar.gz 79.0 kB Details

Built distribution (wheel)

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

Total release size: 167.2 kB

Release files / cchess-1.25.5.tar.gz

Download URL cchess-1.25.5.tar.gz
Size 79.0 kB
Tags Source
SHA-256 checksum
How to use checksums
de4a0de300c0d9da05f25a5096cdc213d682e1b6843d043c03413cc508a7348a
BLAKE2b-256 checksum
How to use checksums
9be262ea3f0e5e6affb010dff4d7c7c9bf5380ba16d5a275e3aa166eef083ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.1

Release files / cchess-1.25.5-py3-none-any.whl

Download URL cchess-1.25.5-py3-none-any.whl
Size 88.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa48602cf76d7776f8e4f0568b5f9b8b32a32c5d3a9089c05855d1f49a303171
BLAKE2b-256 checksum
How to use checksums
778df88e22fe5a6bf44f6b8d88a01f19966d72afffa063dd6f7c412c06ea99fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.1

Release history Release notifications | RSS feed

This release

1.25.5 This release

2 release files

1.24.3

1 release file

1.24.1

1 release file

1.24.0

2 release files

0.80

1 release file

0.7

1 release file

0.6

2 release files

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