def _get_fen_board(self): pieces = [None] * 64 for sq, pc in self.squares.iteritems(): if pc: val = piece.str(pc) if self._get_square_color(sq) == 1: val = val.upper() pieces[square.index(sq)] = val ranks = [] for rank in xrange(8): count = 0 out = '' for file in xrange(8): pc = pieces[square.index(square.from_a8(rank, file))] if pc is None: count += 1 if file == 7: out += '%d' % count else: if count: out += '%d' % count count = 0 out += pc ranks.append(out) return '/'.join(ranks)
def mv(piece, frsq, tosq, promotion=ivory_piece.NONE): val = piece val = ((square.index(frsq) << FRSQ_OFF) | (square.index(tosq) << TOSQ_OFF) | (piece << PIECE_OFF) | (promotion << PROMOTION_OFF)) return val
def set_tosq(mv, sq): return mv & ~TOSQ | (square.index(sq) << TOSQ_OFF)
def set_frsq(mv, sq): return mv & ~FRSQ | (square.index(sq) << FRSQ_OFF)