7-3 python-shogi
fileが列、rankが行を表現する
for sq in shogi.SQUARES:
print(shogi.file_index(sq),end="")
if (sq+1) % 9 == 0:
print("")
print("")
for sq in shogi.SQUARES:
print(shogi.rank_index(sq),end="")
if (sq+1) % 9 == 0:
print("")
shogi.file_indexに座標を渡すと所属している列を返してくれる
012345678
012345678
012345678
012345678
012345678
012345678
012345678
012345678
012345678
#shogi.rank_indexに座標を渡すと所属する行を返してくれる
000000000
111111111
222222222
333333333
444444444
555555555
666666666
777777777
888888888
bitboardの全体に掛けるmaskと思われる
print(hex(shogi.BB_VOID))
#81 bit
print(hex(shogi.BB_ALL))
BB_SQUARESは座標ごと固有のbitboardを表している
bb=shogi.BB_SQUARES
for index,b in enumerate(bb):
print("{0:>08x} ".format(b),end="")
if (index+1) % 9 == 0:
print("")
結果
A rank 00000001 00000002 00000004 00000008 00000010 00000020 00000040 00000080 00000100
B rank 00000200 00000400 00000800 00001000 00002000 00004000 00008000 00010000 00020000
.....
BB_SQUARES_L90はBB_SQUARES盤を左90度回転させた配置
BB_SQUARES_L45は左45度回転させた配置
BB_SQUARES_R45は右45度回転させた配置
BB_FILESはbitboardの列座標を検出できるmask
print(hex(shogi.BB_FILES[0]))
0x1008040201008040201
file9
A 0x01
B 0x200
C 0x40000
D 0x8000000
E 0x1000000000
F 0x200000000000
G 0x40000000000000
H 0x8000000000000000
I 0x1000000000000000000
BB_RABKSは行座標を検出できる