Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Version 11.06
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Feb 26, 2018
1 parent ba77b9a commit 779d655
Show file tree
Hide file tree
Showing 404 changed files with 23,154 additions and 10,686 deletions.
6 changes: 4 additions & 2 deletions Code/Analisis.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ def siElegido(self, posRM):
def ponPosRMactual(self, posRM):
self.posRMactual = posRM
self.rm = self.listaRM[self.posRMactual][0]
self.partida = Partida.Partida(self.jg.posicionBase).leerPV(self.rm.pv)
self.partida = Partida.Partida(self.jg.posicionBase)
self.partida.leerPV(self.rm.pv)
self.partida.siTerminada()
self.posMovActual = 0

Expand Down Expand Up @@ -817,7 +818,8 @@ def analizaJugada(self, jgNueva):
self.rm = self.xtutor.analizaVariante(jgNueva, secs * 1000, self.siBlancas)
me.final()

self.partidaTutor = Partida.Partida(jgNueva.posicion).leerPV(self.rm.pv)
self.partidaTutor = Partida.Partida(jgNueva.posicion)
self.partidaTutor.leerPV(self.rm.pv)

if len(self.partidaTutor):
self.w.tableroT.ponPosicion(self.partidaTutor.jugada(0).posicion)
Expand Down
2 changes: 1 addition & 1 deletion Code/AnalisisIndexes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LCEngine
import LCEngineV1 as LCEngine

from Code import VarGen
from Code import Partida
Expand Down
21 changes: 21 additions & 0 deletions Code/AperturasStd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import LCEngineV1 as LCEngine

from operator import attrgetter

from Code import TrListas
Expand Down Expand Up @@ -34,6 +36,7 @@ def __str__(self):
class ListaAperturasStd:
def __init__(self):
self.dic = None
self.dicFenM2 = None
self.hijos = None
self.lia1h8 = None

Expand All @@ -49,6 +52,14 @@ def reset(self, configuracion, siBasic, siEntrenar):
bl.trOrdena = ("A" if bl.siBasic else "B") + bl.trNombre.upper()
self.hijos = self.ordena(self.hijos, 0)

dfen = {}
makePV = LCEngine.makePV
fen2fenM2 = LCEngine.fen2fenM2
for pv, ap in self.dic.iteritems():
fen = makePV(pv)
dfen[fen2fenM2(fen)] = ap
self.dicFenM2 = dfen

def ordena(self, hijos, n):
if hijos:
hijos = sorted(hijos, key=attrgetter("trOrdena"))
Expand Down Expand Up @@ -132,6 +143,16 @@ def lee(self, ficheroPers, siEntrenar):
if n <= 0:
self.hijos.append(bloque)

def asignaTransposition(self, partida):
partida.transposition = None
if not (partida.apertura is None or partida.pendienteApertura):
for nj, jg in enumerate(partida.liJugadas):
if not jg.siApertura:
fenm2 = jg.posicion.fenM2()
if fenm2 in self.dicFenM2:
partida.transposition = self.dicFenM2[fenm2]
partida.jg_transposition = jg

def asignaApertura(self, partida):
partida.apertura = None
if not partida.siFenInicial():
Expand Down
2 changes: 1 addition & 1 deletion Code/CajonDesastre.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
import sqlite3

import LCEngine
import LCEngineV1 as LCEngine

from Code import BaseConfig
from Code import Util
Expand Down
45 changes: 27 additions & 18 deletions Code/Constantes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,46 @@

kSigueApertura, kSigueUsuario, kMalApertura = range(3)

kJugNueva, kJugEntPos, kJugPGN, kJugEntMaq, kJugGM, kJugRemoto, kJugSolo, kJug60, kJugElo, kJugMicElo, \
kJugBooks, kJugAperturas, kJugBoxing, kJugEntTac, kJugMvM, kJugAlbum, kJugFics, kJugFide, kJugLichess, \
kJugWorldMap, kJugRoute, kJugEntLight, kJugWashingCreate, kJugWashingTactics, kJugWashingReplay, kJugSingularMoves\
= range(26)
(
kJugNueva, kJugEntPos, kJugPGN, kJugEntMaq, kJugGM, kJugRemoto, kJugSolo, kJug60, kJugElo, kJugMicElo,
kJugBooks, kJugAperturas, kJugOpeningLines, kJugBoxing, kJugEntTac, kJugMvM, kJugAlbum, kJugFics, kJugFide,
kJugLichess, kJugWorldMap, kJugRoute, kJugEntLight, kJugWashingCreate, kJugWashingTactics, kJugWashingReplay,
kJugSingularMoves
) = range(27)

kFinNormal, kFinReinicio = range(2)

kGanamos, kGanaRival, kTablas, kTablasRepeticion, kTablas50, kTablasFaltaMaterial, kGanamosTiempo, kGanaRivalTiempo, kTablasAcuerdo, kDesconocido = range(10)
(
kGanamos, kGanaRival, kTablas, kTablasRepeticion, kTablas50, kTablasFaltaMaterial, kGanamosTiempo,
kGanaRivalTiempo, kTablasAcuerdo, kDesconocido
) = range(10)

kMoverAdelante, kMoverAtras, kMoverInicio, kMoverFinal, kMoverLibre, kMoverReloj = range(6)

k_terminar, k_play, k_mainmenu, k_competicion, k_competir, k_entrenamiento, k_opciones, \
k_informacion, k_grabar, k_grabarComo, k_file, k_recuperar, k_abandonar, k_reiniciar, k_atras, \
k_aplazar, k_finpartida, k_ent_empezar, k_ent_otro, k_pgnFin, k_pgnPaste, \
k_pgnFichero, k_pgnInformacion, k_pgnFicheroRepite, k_pgnNuestroFichero, k_jugadadia, k_pgnComandoExterno, \
k_rendirse, k_tablas, k_libros, \
k_peliculaTerminar, k_peliculaLento, k_peliculaPausa, k_peliculaSeguir, k_peliculaRapido, k_peliculaRepetir, \
k_peliculaPGN, k_jugar, k_anterior, k_siguiente, k_trasteros, \
k_ayuda, k_mateNivel, k_ayudaMover, \
k_aceptar, k_cancelar, \
k_configurar, k_utilidades, k_variantes, k_tools, k_elo, k_cambiar, k_libre, k_showtext, k_enviar = range(55)
(
k_terminar, k_play, k_mainmenu, k_competicion, k_competir, k_entrenamiento, k_opciones,
k_informacion, k_grabar, k_grabarComo, k_file, k_recuperar, k_abandonar, k_reiniciar, k_atras,
k_aplazar, k_finpartida, k_ent_empezar, k_ent_otro, k_pgnFin, k_pgnPaste,
k_pgnFichero, k_pgnInformacion, k_pgnFicheroRepite, k_pgnNuestroFichero, k_jugadadia, k_pgnComandoExterno,
k_rendirse, k_tablas, k_libros,
k_peliculaTerminar, k_peliculaLento, k_peliculaPausa, k_peliculaSeguir, k_peliculaRapido, k_peliculaRepetir,
k_peliculaPGN, k_jugar, k_anterior, k_siguiente, k_trasteros,
k_ayuda, k_mateNivel, k_ayudaMover,
k_aceptar, k_cancelar,
k_configurar, k_utilidades, k_variantes, k_tools, k_elo, k_cambiar, k_libre, k_showtext, k_enviar
) = range(55)

kMP_1, kMP_2, kMP_3, kMP_4, kMP_5, kMP_6, kMP_7 = range(7)

kZvalue_pieza, kZvalue_piezaMovimiento = 10, 20

kTutorH, kTutorH2_1, kTutorH1_2, kTutorV = range(4)

kAjustarMejor, kAjustarSuperior, kAjustarSimilar, kAjustarInferior, kAjustarPeor, kAjustarPlayer, \
kAjustarNivelAlto, kAjustarNivelMedio, kAjustarNivelBajo, kAjustarSuperiorM, kAjustarSuperiorMM, \
kAjustarInferiorM, kAjustarInferiorMM = range(13)
(
kAjustarMejor, kAjustarSuperior, kAjustarSimilar, kAjustarInferior, kAjustarPeor, kAjustarPlayer,
kAjustarNivelAlto, kAjustarNivelMedio, kAjustarNivelBajo, kAjustarSuperiorM, kAjustarSuperiorMM,
kAjustarInferiorM, kAjustarInferiorMM
) = range(13)

kControlTableroNo, kControlTableroGeneral, kControlTableroParticular = range(3)

Expand Down
5 changes: 4 additions & 1 deletion Code/ControlPosicion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LCEngine
import LCEngineV1 as LCEngine

from Code import TrListas

Expand Down Expand Up @@ -434,3 +434,6 @@ def siPeonCoronando(self, desdeA1H8, hastaA1H8):
return False

return True

def distancia(desde, hasta):
return ((ord(desde[0])-ord(hasta[0]))**2 + (ord(desde[1])-ord(hasta[1]))**2)**0.5
66 changes: 41 additions & 25 deletions Code/DBgames.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import random

import LCEngine
import LCEngineV1 as LCEngine

from Code import ControlPosicion
from Code import Partida
Expand Down Expand Up @@ -524,8 +524,9 @@ def getSummary(self, pvBase, dicAnalisis, siFigurinesPGN, allmoves=True):


class DBgames:
def __init__(self, nomFichero):
def __init__(self, nomFichero, with_dbSTAT=True):
self.nomFichero = Util.dirRelativo(nomFichero)
self.with_dbSTAT = with_dbSTAT
self.liCamposBase = ["EVENT", "SITE", "DATE", "WHITE", "BLACK", "RESULT", "ECO", "WHITEELO", "BLACKELO", "PLIES"]
self.liCamposWork = ["XPV", ]
self.liCamposBLOB = ["PGN", ]
Expand Down Expand Up @@ -556,7 +557,10 @@ def __init__(self, nomFichero):

self.liOrden = []

self.dbSTAT = TreeSTAT(self.nomFichero + "_s1")
if self.with_dbSTAT:
self.dbSTAT = TreeSTAT(self.nomFichero + "_s1")
else:
self.dbSTAT = None

self.liRowids = []

Expand Down Expand Up @@ -759,10 +763,12 @@ def borrarLista(self, lista):
for recno in lista:
pv = self.damePV(recno)
result = self.field(recno, "RESULT")
self.dbSTAT.append(pv, result, -1)
if self.with_dbSTAT:
self.dbSTAT.append(pv, result, -1)
self._cursor.execute(cSQL,(self.liRowids[recno],))
del self.liRowids[recno]
self.dbSTAT.commit()
if self.with_dbSTAT:
self.dbSTAT.commit()
self._conexion.commit()

def getSummary(self, pvBase, dicAnalisis, siFigurinesPGN, allmoves=True):
Expand Down Expand Up @@ -803,7 +809,8 @@ def leerPGNs(self, ficheros, dlTmp):

t1 = time.time()-0.7 # para que empiece enseguida

self.dbSTAT.massive_append_set(True)
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(True)

def write_logs(fich, pgn):
with open(fich, "ab") as ferr:
Expand Down Expand Up @@ -880,7 +887,8 @@ def write_logs(fich, pgn):
pgn = Util.var2blob(pgn)

reg = (xpv, event, site, date, white, black, result, eco, whiteelo, blackelo, pgn, plies)
self.dbSTAT.append_fen(pv, result, liFens)
if self.with_dbSTAT:
self.dbSTAT.append_fen(pv, result, liFens)
liRegs.append(reg)
nRegs += 1
importados += 1
Expand All @@ -890,9 +898,10 @@ def write_logs(fich, pgn):
liRegs = []
stRegs = set()
conexion.commit()
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
self.dbSTAT.massive_append_set(True)
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
self.dbSTAT.massive_append_set(True)
if n == next_n:
if time.time()-t1> 0.8:
if not dlTmp.actualiza(erroneos+duplicados+importados, erroneos, duplicados, importados):
Expand All @@ -906,15 +915,17 @@ def write_logs(fich, pgn):
dlTmp.actualiza(erroneos+duplicados+importados, erroneos, duplicados, importados)
dlTmp.ponSaving()

self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
conexion.commit()
dlTmp.ponContinuar()

def appendDB(self, db, liRecnos, dlTmp):
duplicados = importados = 0

self.dbSTAT.massive_append_set(True)
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(True)

t1 = time.time() - 0.7 # para que empiece enseguida

Expand All @@ -941,17 +952,19 @@ def appendDB(self, db, liRecnos, dlTmp):
pv = xpv2pv(xpv)
reg = (xpv, raw["EVENT"], raw["SITE"], raw["DATE"], raw["WHITE"], raw["BLACK"], raw["RESULT"], raw["ECO"], raw["WHITEELO"],
raw["BLACKELO"], raw["PGN"], raw["PLIES"])
self.dbSTAT.append(pv, raw["RESULT"])
if self.with_dbSTAT:
self.dbSTAT.append(pv, raw["RESULT"])
liRegs.append(reg)
nRegs += 1
importados += 1
if nRegs == 10000:
cursor.executemany(sql, liRegs)
liRegs = []
conexion.commit()
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
self.dbSTAT.massive_append_set(True)
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
self.dbSTAT.massive_append_set(True)

if pos == next_n:
if time.time() - t1 > 0.8:
Expand All @@ -967,8 +980,9 @@ def appendDB(self, db, liRecnos, dlTmp):
dlTmp.actualiza(duplicados + importados, duplicados, importados)
dlTmp.ponSaving()

self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
if self.with_dbSTAT:
self.dbSTAT.massive_append_set(False)
self.dbSTAT.commit()
conexion.commit()

dlTmp.ponContinuar()
Expand Down Expand Up @@ -1022,7 +1036,7 @@ def leePartidaRaw(self, raw):
litags.extend(rtags)

p.setTags(litags)
p.asignaApertura(VarGen.configuracion)
p.asignaApertura()
return p

def leePGNRecno(self, recno):
Expand Down Expand Up @@ -1102,9 +1116,10 @@ def modifica(self, recno, partidaCompleta):
self._conexion.commit()
pvAnt = xpv2pv(reg_ant["XPV"])
resNue = dTags.get("RESULT", "*")
self.dbSTAT.append(pvAnt, resAnt, -1)
self.dbSTAT.append(pvNue, resNue, +1)
self.dbSTAT.commit()
if self.with_dbSTAT:
self.dbSTAT.append(pvAnt, resAnt, -1)
self.dbSTAT.append(pvNue, resNue, +1)
self.dbSTAT.commit()

del self.cache[rowid]

Expand Down Expand Up @@ -1136,8 +1151,9 @@ def inserta(self, partidaCompleta):
sql = "insert into games (XPV,EVENT,SITE,DATE,WHITE,BLACK,RESULT,ECO,WHITEELO,BLACKELO,PLIES,PGN) values (?,?,?,?,?,?,?,?,?,?,?,?);"
self._cursor.execute(sql, data)
self._conexion.commit()
self.dbSTAT.append(pv, dTags.get("RESULT", "*"), +1)
self.dbSTAT.commit()
if self.with_dbSTAT:
self.dbSTAT.append(pv, dTags.get("RESULT", "*"), +1)
self.dbSTAT.commit()

self.liRowids.append(self._cursor.lastrowid)

Expand Down
2 changes: 1 addition & 1 deletion Code/DBgamesFEN.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import random

import LCEngine
import LCEngineV1 as LCEngine

from Code import Partida
from Code import Util
Expand Down
5 changes: 4 additions & 1 deletion Code/EngineThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

DEBUG_ENGINE = False


def xpr(line):
if DEBUG_ENGINE:
t = time.time()
Expand Down Expand Up @@ -130,6 +129,10 @@ def start(self):
startupinfo = None
curdir = os.path.abspath(os.curdir) # problem with "." as curdir
os.chdir(self.direxe) # to fix problems with non ascii folders
if VarGen.isLinux:
argv0 = self.args[0]
if "/" not in argv0:
self.args[0] = os.path.join(self.direxe, argv0)
self.process = subprocess.Popen(self.args, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
startupinfo=startupinfo, shell=False)
os.chdir(curdir)
Expand Down
6 changes: 3 additions & 3 deletions Code/EnginesLinux32.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ def mas(cm):
cm.ordenUCI("Hash", "64")
mas(cm)

cm = ConfigMotor("mcbrain", "Michael Byrne (based on stockfish)", "4.0", "https://github.com/MichaelB7/Stockfish/releases")
cm.path = "SF-McBrain-v40_x32_linux"
cm = ConfigMotor("mcbrain", "Michael Byrne", "9", "https://github.com/MichaelB7/Stockfish/releases")
cm.path = "McBrain-9_x32_linux"
cm.elo = 3200
cm.ordenUCI("Tactical", "3")
cm.ordenUCI("Contempt", "0")
cm.ordenUCI("Hash", "64")
cm.ponMultiPV(20, 500)
mas(cm)
Expand Down
10 changes: 5 additions & 5 deletions Code/EnginesLinux64.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def mas(cm):
cm.ponMultiPV(20, 218)
mas(cm)

cm = ConfigMotor("stockfish", "Tord Romstad, Marco Costalba, Joona Kiiski", "8", "http://stockfishchess.org/")
cm.path = "Linux/stockfish_8_x64"
cm = ConfigMotor("stockfish", "Tord Romstad, Marco Costalba, Joona Kiiski", "9", "http://stockfishchess.org/")
cm.path = "Linux/stockfish-9-64"
cm.elo = 3300
cm.ordenUCI("Ponder", "false")
cm.ordenUCI("Hash", "64")
Expand Down Expand Up @@ -138,10 +138,10 @@ def mas(cm):
cm.ordenUCI("Hash", "64")
mas(cm)

cm = ConfigMotor("mcbrain", "Michael Byrne (based on stockfish)", "4.0", "https://github.com/MichaelB7/Stockfish/releases")
cm.path = "SSF-McBrain-v40_x64_linux"
cm = ConfigMotor("mcbrain", "Michael Byrne", "9", "https://github.com/MichaelB7/Stockfish/releases")
cm.path = "McBrain-9_x64_linux"
cm.elo = 3200
cm.ordenUCI("Tactical", "3")
cm.ordenUCI("Contempt", "0")
cm.ordenUCI("Hash", "64")
cm.ponMultiPV(20, 500)
mas(cm)
Expand Down
Loading

0 comments on commit 779d655

Please sign in to comment.