Exemplo n.º 1
0
def remake ():
    tsqlite.execSQL("drop table if exists openings")
    tsqlite.execSQL("create table openings( fen varchar(73), move varchar(7), \
                 wins int DEFAULT 0, draws int DEFAULT 0, loses int DEFAULT 0)")
    
    resd = ["wins","draws","loses"]
    
    sql1 = "select * from openings WHERE fen = '%s' AND move = '%s'"
    sql2 = "UPDATE openings SET %s = %s+1 WHERE fen = '%s' AND move = '%s'"
    sql3 = "INSERT INTO openings (fen,move,%s) VALUES ('%s','%s',1)"
    def toDb (fenstr, move, res):
        if tsqlite.execSQL (sql1 % (fenstr, move)):
            tsqlite.execSQL (sql2 % (res, res, fenstr, move))
        else: tsqlite.execSQL (sql3 % (res, fenstr, move))
    
    import sys
    from System.ThreadPool import pool
    for fenstr, move, score in load(open(sys.argv[1])):
        pool.start(toDb,fenstr, move, resd[score])
    
    for fen, move, w, l, d in tsqlite.execSQL ("select * from openings"):
        print fen.ljust(65), move.ljust(7), w, "\t", l, "\t", d
    
    tsqlite.close()
Exemplo n.º 2
0
 def toDb (fenstr, move, res):
     if tsqlite.execSQL (sql1 % (fenstr, move)):
         tsqlite.execSQL (sql2 % (res, res, fenstr, move))
     else: tsqlite.execSQL (sql3 % (res, fenstr, move))
Exemplo n.º 3
0
def getOpenings (board):
    return tsqlite.execSQL (
        "select move,wins,draws,loses from openings where fen = '%s'" % \
                                                                 fen(board))