将棋AIで学ぶディープラーニングを読む

7-3 python-shogi

クラス Piece(object) 
    def __init__(self, piece_type,color)
        piece_typeとcolorを登録
    def symbol(self)
        実行例
        silver = shogi.Piece(shogi.SILVER,shogi.BLACK)
        silver.symbol()
        'S'
    def japanese_symbol(self)
        実行例
        silver = shogi.Piece(shogi.SILVER,shogi.BLACK)
        silver.japanese_symbol()
        '銀'
    def japanese_symbol_with_direction(self)
        実行例
        silver = shogi.Piece(shogi.SILVER,shogi.BLACK)
        silver. japanese_symbol_with_direction()
        ' 銀'
        silver_w = shogi.Piece(shogi.SILVER,shogi.WHITE)
        silver_w. japanese_symbol_with_direction()
        'v銀'
    def is_promoted(self)
        実行例
        silver = shogi.Piece(shogi.SILVER,shogi.BLACK)
        silver = shogi.is_promoted()
        False
        つまり成り駒かどうかを尋ねている
    def .__reduce__()
        実行例
        silver = shogi.Piece(shogi.SILVER,shogi.BLACK)
        silver = shogi.__reduce__()
        (<function copyreg._reconstructor>,
        (shogi.Piece.Piece, object, None),
        {'color': 0, 'piece_type': 4})

クラス Move(object)  Move.py
    def __init__(self, from_square, to_square, promotion=False, drop_piece_type=None)
        from_square座標
        to_square座標
        promotion 成り動作フラグ
       drop_piece_type 打つ手ならdrop_piece_typeを設定
      を登録
    def usi(self)
        usi表記の操作
    def __bool__(self)
        from_squareとto_squareが両方とも設定がない場合True
    def def __hash__(self)
        to_square,from_square,promotionを16bitぐらいの変数に圧縮して返す(promotionが何bitで表現されるのか不明)
    def from_usi(cls, usi)
        実行例
         m = shogi.Move(shogi.C5,shogi.D5)
        Move.from_usi('5c5d')
        m.from_usi('5c5d')