def prdashPiece(mv, mvs): assert tag(mv) == "-" assert isPiece(manAt(osq(mv))) # simplest form - pln p = man.pr(manAt(osq(mv))) ln = square.pr(nsq(mv)) s = "%s%s" % (p, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # disabiguate by file - pfln f = "abcdefgh"[col(osq(mv))] s = "%s%s%s" % (p, f, ln) found = algebraic.find(s, mvs) if (len(found)) == 1: return s # disambiguate by rank - prln r = "12345678"[row(osq(mv))] s = "%s%s%s" % (p, r, ln) found = algebraic.find(s, mvs) if (len(found)) == 1: return s # disambiguate by both -rare but possible - prfln s = "%s%s%s%s" % (p, r, f, ln) if (len(found)) == 1: return s # there should be no other cases given that move is legal assert False
def prcapturePiece(mv, mvs): assert tag(mv) in ["x", "x/", "xep"] assert isPiece(manAt(osq(mv))) # simplest form - pxln p = man.pr(manAt(osq(mv))) ln = square.pr(nsq(mv)) s = "%sx%s" % (p, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # disambiguate by file - pfxln f = "abcdefgh"[col(osq(mv))] s = "%s%sx%s" % (p, f, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # disambiguate by rank - prxln r = "12345678"[row(osq(mv))] s = "%s%sx%s" % (p, r, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # disambiguate by both - prfxln s = "%s%s%sx%s" % (p, r, f, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # if move is legal there should be no other cases assert False
def prcapturePawn(mv, mvs): assert tag(mv) in ["x", "x/", "xep"] assert isPawn(manAt(osq(mv))) # simplest form - fxln f = "abcdefgh"[col(osq(mv))] ln = square.pr(nsq(mv)) if tag(mv) == "x/": q = man.pr(pmn(mv)) s = "%sx%s=%s" % (f, ln, q) else: s = "%sx%s" % (f, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # disambiguate by both - rfxln rf = square.pr(osq(mv)) if tag(mv) == "x/": s = "%sx%s=%s" % (rf, ln, q) else: s = "%sx%s" % (rf, ln) found = algebraic.find(s, mvs) if len(found) == 1: return s # if move is legal there should be no other cases assert False
def prdashPawn(mv, mvs): assert tag(mv) == "-" or tag(mv) == "-/" assert isPawn(manAt(osq(mv))) # simplest form - ln ln = square.pr(nsq(mv)) if tag(mv) == "-/": q = man.pr(pmn(mv)) s = "%s=%s" % (ln, q) else: s = ln found = algebraic.find(s, mvs) if len(found) == 1: return s
def prcapturepromote(mv): return "%s(%s)" % (prcapture(mv), man.pr(pmn(mv)))
def prdashpromote(mv): return "%s(%s)" % (prdash(mv), man.pr(pmn(mv)))
def prcapture(mv): manthatmoves = man.pr(board.theBoard[osq(mv)]) fromsquare = square.pr(osq(mv)) tosquare = square.pr(nsq(mv)) return "%s%sx%s" % (manthatmoves, fromsquare, tosquare)
def prcapturepromote(mv): return "%s(%s)" % (prcapture(mv), man.pr(board.theBoard[mn(mv)]))
def prdashpromote(mv): return "%s(%s)" % (prdash(mv), man.pr(board.theBoard[mn(mv)]))