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

Commit ba77b9a

Browse files
committed
Version 11.05b
1 parent 39513ba commit ba77b9a

11 files changed

+1483
-62
lines changed

Code/EngineThread.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
from Code import VarGen
99
from Code.Constantes import *
1010

11-
DEBUG = False
11+
DEBUG_ENGINE = False
1212

1313

1414
def xpr(line):
15-
if DEBUG:
15+
if DEBUG_ENGINE:
1616
t = time.time()
1717
prlk("%0.04f %s" % (t - tdbg[0], line))
1818
tdbg[0] = t
1919
return True
2020

2121

2222
def xprli(li):
23-
if DEBUG:
23+
if DEBUG_ENGINE:
2424
t = time.time()
2525
dif = t - tdbg[0]
2626
for line in li:
2727
prlk("%0.04f %s" % (dif, line))
2828
tdbg[0] = t
2929
return True
3030

31-
if DEBUG:
31+
if DEBUG_ENGINE:
3232
tdbg = [time.time()]
3333
xpr("DEBUG XMOTOR")
3434

Code/GestorPGN.py

+21-36
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import os
44
import sys
5-
import anydbm
5+
import random
6+
67

78
from Code import Gestor
89
from Code import PGN
@@ -160,44 +161,28 @@ def paste(self):
160161
self.pgnPaste = texto
161162
self.mostrar(pgn, False)
162163

163-
# def jugadaDia(self):
164-
# self.pensando(True)
165-
# dia = Util.hoy().day
166-
# lid = Util.LIdisk("./IntFiles/31.pkl")
167-
# dic = lid[dia - 1]
168-
# lid.close()
169-
# txt = dic["PGN"]
170-
# pgn = PGN.UnPGN()
171-
# pgn.leeTexto(txt)
172-
# self.pensando(False)
173-
# if pgn.siError:
174-
# return
175-
# self.pgnPaste = txt
176-
# self.mostrar(pgn, False)
177-
178164
def miniatura(self):
179165
self.pensando(True)
180166

181-
db = anydbm.open("./IntFiles/miniaturas.dbm")
182-
h = hash(Util.hoy())
183-
grupo = str(h%7+1)
184-
li = db[grupo].split("{")
185-
db.close()
186-
n = len(li)
187-
pos = h % n
188-
linea = li[pos]
189-
lig = linea.split("|")
190-
liTags = []
191-
pv = lig[-1]
192-
for n in range(len(lig)-1):
193-
if "·" in lig[n]:
194-
k, v = lig[n].split("·")
195-
liTags.append((k, v))
196-
p = Partida.PartidaCompleta(liTags=liTags)
197-
p.leerPV(pv)
198-
txt = p.pgn()
199-
pgn = PGN.UnPGN()
200-
pgn.leeTexto(txt)
167+
fichero = "./IntFiles/miniaturas.gm"
168+
tam = Util.tamFichero(fichero)
169+
pos = random.randint(0, tam-600)
170+
with open(fichero) as fm:
171+
fm.seek(pos)
172+
fm.readline()
173+
linea = fm.readline()
174+
lig = linea.split("|")
175+
liTags = []
176+
pv = lig[-1]
177+
for n in range(len(lig)-1):
178+
if "·" in lig[n]:
179+
k, v = lig[n].split("·")
180+
liTags.append((k, v))
181+
p = Partida.PartidaCompleta(liTags=liTags)
182+
p.leerPV(pv)
183+
txt = p.pgn()
184+
pgn = PGN.UnPGN()
185+
pgn.leeTexto(txt)
201186
self.pensando(False)
202187
if pgn.siError:
203188
return

Code/Init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from Code.Constantes import *
1010

1111
DEBUG = False
12-
VERSION = "11.05a"
12+
VERSION = "11.05b"
1313

1414
if DEBUG:
1515
prlkn("DEBUG " * 20)

Code/OpeningLines.py

+46-17
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,12 @@ def grabarPGN(self, owner, ficheroPGN, maxDepth):
303303
cursor = self._conexion.cursor()
304304

305305
base = self.getconfig("BASEPV")
306+
partidabase = self.getpartidabase()
307+
njugbase = partidabase.numJugadas()
306308
n = 0
307309

310+
sql_insert = "INSERT INTO LINES( XPV, LINE ) VALUES( ?, ? )"
311+
sql_update = "UPDATE LINES SET XPV=?, LINE=? WHERE XPV=?"
308312
for n, g in enumerate(PGNreader.readGames(ficheroPGN), 1):
309313
if not dlTmp.actualiza(n, erroneos, duplicados, importados):
310314
break
@@ -322,19 +326,28 @@ def haz_partida(partida, liMoves):
322326
pv = " ".join([move.pv for move in liMoves])
323327
partida.leerPV(pv)
324328
pv = partida.pv()
325-
if base and not pv.startswith(base):
329+
if base and not pv.startswith(base) or partida.numJugadas() <= njugbase:
326330
return
327331
xpv = LCEngine.pv2xpv(pv)
328332
if xpv in self.li_xpv:
329333
return
330334
line_blob = partida.save2blob()
331-
cursor.execute(sql, (xpv, line_blob))
332-
self.li_xpv.append(xpv)
335+
updated = False
336+
for npos, xpv_ant in enumerate(self.li_xpv):
337+
if xpv.startswith(xpv_ant):
338+
cursor.execute(sql_update, (xpv, line_blob, xpv_ant))
339+
self.li_xpv[npos] = xpv
340+
updated = True
341+
break
342+
if not updated:
343+
cursor.execute(sql_insert, (xpv, line_blob))
344+
self.li_xpv.append(xpv)
345+
333346
for njug, move in enumerate(liMoves):
334347
if move.variantes:
335348
for lim in move.variantes:
336349
p = partida.copia(njug-1) if njug > 0 else Partida.Partida()
337-
haz_partida(p, lim)
350+
haz_partida(p, lim.liMoves)
338351

339352
partida = Partida.Partida()
340353
haz_partida(partida, g.moves.liMoves)
@@ -360,11 +373,16 @@ def grabarPolyglot(self, ventana, ficheroBIN, depth, whiteBest, blackBest):
360373

361374
stFenM2 = set() # para que no se produzca un circulo vicioso
362375

363-
p = self.getpartidabase()
364-
cp = p.ultPosicion
376+
partidabase = self.getpartidabase()
377+
cp = partidabase.ultPosicion
365378

366379
liPartidas = []
367380

381+
setFen = LCEngine.setFen
382+
makeMove = LCEngine.makeMove
383+
getFen = LCEngine.getFen
384+
fen2fenM2 = LCEngine.fen2fenM2
385+
368386
def hazFEN(fen, ply, lipv_ant):
369387
plyN = ply + 1
370388
siWhite = " w " in fen
@@ -378,14 +396,14 @@ def hazFEN(fen, ply, lipv_ant):
378396
if liPV:
379397
sigue = False
380398
for pv in liPV:
381-
cp.leeFen(fen)
382-
cp.mover(pv[:2], pv[2:4], pv[4:])
383-
fenN = cp.fen()
399+
setFen(fen)
400+
makeMove(pv)
401+
fenN = getFen()
384402

385403
lipv_nue = lipv_ant[:]
386404
lipv_nue.append(pv)
387405
if plyN < depth:
388-
fenM2 = cp.fenM2()
406+
fenM2 = fen2fenM2(fenN)
389407
if fenM2 not in stFenM2:
390408
stFenM2.add(fenM2)
391409
hazFEN(fenN, plyN, lipv_nue)
@@ -399,18 +417,29 @@ def hazFEN(fen, ply, lipv_ant):
399417
bp.ponTotal(len(liPartidas))
400418
bp.pon(len(liPartidas))
401419

402-
hazFEN(cp.fen(), 0, p.pv().split(" "))
420+
hazFEN(cp.fen(), 0, partidabase.lipv())
403421

404422
bp.ponRotulo(_("Writing..."))
405423

406-
sql = "INSERT INTO LINES( XPV, LINE ) VALUES( ?, ? )"
424+
sql_insert = "INSERT INTO LINES( XPV, LINE ) VALUES( ?, ? )"
425+
sql_update = "UPDATE LINES SET XPV=?, LINE=? WHERE XPV=?"
407426
cursor = self._conexion.cursor()
408427
for partida in liPartidas:
409-
xpv = LCEngine.pv2xpv(partida.pv())
410-
if xpv not in self.li_xpv:
411-
line_blob = partida.save2blob()
412-
cursor.execute(sql, (xpv, line_blob))
413-
self.li_xpv.append(xpv)
428+
if partida.numJugadas() > partidabase.numJugadas():
429+
xpv = LCEngine.pv2xpv(partida.pv())
430+
if xpv not in self.li_xpv:
431+
line_blob = partida.save2blob()
432+
updated = False
433+
for npos, xpv_ant in enumerate(self.li_xpv):
434+
if xpv.startswith(xpv_ant):
435+
cursor.execute(sql_update, (xpv, line_blob, xpv_ant))
436+
self.li_xpv[npos] = xpv
437+
updated = True
438+
break
439+
if not updated:
440+
cursor.execute(sql_insert, (xpv, line_blob))
441+
self.li_xpv.append(xpv)
442+
414443
cursor.close()
415444
self._conexion.commit()
416445
self.li_xpv.sort()

Code/Partida.py

+3
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ def siEstaTerminada(self):
296296
def pv(self):
297297
return " ".join([jg.movimiento() for jg in self.liJugadas])
298298

299+
def lipv(self):
300+
return [jg.movimiento() for jg in self.liJugadas]
301+
299302
def pv_hasta(self, njug):
300303
return " ".join([jg.movimiento() for jg in self.liJugadas[:njug+1]])
301304

Code/QT/PantallaConfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def d(num):
210210
lista.append((liT, _("Boards"), ""))
211211
lista.append((liEng, _("Engines"), ""))
212212
lista.append((liAsp, _("Appearance"), ""))
213-
lista.append((liPR, _("Perfomance"), ""))
213+
lista.append((liPR, _("Performance"), ""))
214214
lista.append((liSA, _("Autosave"), ""))
215215
lista.append((liNC, _("Non competitive mode"), ""))
216216

Code/RunKibitzer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ def guardarVideo(self):
684684

685685
dic["SITOP"] = self.siTop
686686

687-
Util.guardaDIC(dic, self.ficheroVideo)
688-
687+
self.cpu.save_video(dic)
689688

690689
def recuperarVideo(self):
691690
dic = self.cpu.dic_video

IntFiles/miniaturas.dbm

-608 KB
Binary file not shown.

0 commit comments

Comments
 (0)