Пример #1
0
    """ Returns a Figurine Algebraic Notation string of a move """

    san = unicode(toSAN(board, move))
    if board.color == WHITE:
        return san.translate(san2WhiteFanDic)
    else:
        return san.translate(san2BlackFanDic)


################################################################################
# parseFAN                                                                     #
################################################################################

fan2SanDic = {}
for k, v in san2WhiteFanDic.items():
    fan2SanDic[ord(v)] = unichr(k)
for k, v in san2BlackFanDic.items():
    fan2SanDic[ord(v)] = unichr(k)


def parseFAN(board, fan):
    """ Parse a Figurine Algebraic Notation string """

    san = fan.translate(fan2SanDic)
    return parseSAN(board, san)


################################################################################
# toPolyglot                                                                   #
################################################################################
Пример #2
0
def toFAN (board, move):
    """ Returns a Figurine Algebraic Notation string of a move """
    
    san = unicode(toSAN (board, move))
    if board.color == WHITE:
        return san.translate(san2WhiteFanDic)
    else:
        return san.translate(san2BlackFanDic)

################################################################################
# parseFAN                                                                     #
################################################################################

fan2SanDic = {}
for k, v in san2WhiteFanDic.items():
    fan2SanDic[ord(v)] = unichr(k)
for k, v in san2BlackFanDic.items():
    fan2SanDic[ord(v)] = unichr(k)

def parseFAN (board, fan):
    """ Parse a Figurine Algebraic Notation string """

    san = fan.translate(fan2SanDic)
    return parseSAN (board, san)

################################################################################
# toPolyglot                                                                   #
################################################################################

def toPolyglot (board, move):
    """ Returns a 16-bit Polyglot-format move 
Пример #3
0
 (FAN_PIECES[WHITE][KNIGHT],'k'),
 (FAN_PIECES[WHITE][BISHOP],'j'),
 (FAN_PIECES[WHITE][ROOK],'l'),
 (FAN_PIECES[WHITE][QUEEN],'m'),
 (FAN_PIECES[WHITE][KING],'n'),
 ('†', '+'),
 ('‡', '+'),
 ('1/2', 'Z'))

def fanconv(fan):
    for f,r in lisPieces:
        fan = fan.replace(f,r)
    return fan

# Dictionaries and expressions for parsing diagrams
entitydefs = dict(("&%s;"%a,unichr(ord(b)).encode('utf-8'))
                  for a,b in entitydefs.items() if len(b)==1)
def2entity = dict((b, a) for a,b in entitydefs.items())
    

style = """
@font-face {font-family: "Chess Alpha 2"; src: local("Chess Alpha 2"),
url("http://pychess.org/fonts/ChessAlpha2.eot?") format("eot"),
url("http://pychess.org/fonts/ChessAlpha2.woff") format("woff"),
url("http://pychess.org/fonts/ChessAlpha2.ttf") format("truetype"),
url("http://pychess.org/fonts/ChessAlpha2.svg#ChessAlpha2") format("svg"); font-weight:"normal"; font-style:"normal";}
table.pychess {display:inline-block; vertical-align:top}
table.pychess td {margin:0; padding:0; font-size:10pt; font-family:"Chess Alpha 2"; padding-left:.5em}
table.pychess td.numa {width:0; text-align:right}
table.pychess td.numa {width:0; text-align:right; padding-left:1em}
table.pychess td.status {text-align:center; font-size:12pt; padding-right:2em}
Пример #4
0
 def entityDecode (self, text):
     return self.entityExpr.sub(lambda m: unichr(int(m.groups()[0],16)), text)