示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
def prcapturepromote(mv):
    return "%s(%s)" % (prcapture(mv), man.pr(pmn(mv)))
示例#6
0
def prdashpromote(mv):
    return "%s(%s)" % (prdash(mv), man.pr(pmn(mv)))
示例#7
0
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)
示例#8
0
def prcapturepromote(mv):
    return "%s(%s)" % (prcapture(mv), man.pr(board.theBoard[mn(mv)]))
示例#9
0
def prdashpromote(mv):
    return "%s(%s)" % (prdash(mv), man.pr(board.theBoard[mn(mv)]))