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

Commit 2afabbc

Browse files
committed
Version 11.04
1 parent b811043 commit 2afabbc

38 files changed

+652
-953
lines changed

Code/Analisis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def guiDispatch(rm):
506506
self.grabaBMT(False, fen, mrm, posAct, clpartida, txtPartida)
507507
self.siBMTbrilliancies = True
508508
else:
509-
nag, color = mrm.setNAG_Color(rm)
509+
nag, color = mrm.setNAG_Color(self.configuracion, rm)
510510
if nag:
511511
jg.masCritica1_4(str(nag))
512512

Code/AnalisisIndexes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def tp_gamestage(cp, mrm):
283283
return _("Game stage"), calc_gamestage(cp, mrm), get_gamestage(cp, mrm)
284284

285285

286-
def genIndexes(configuracion, partida, alm):
286+
def genIndexes(partida, elos, alm):
287287
average = {True: 0, False: 0}
288288
domination = {True: 0, False: 0}
289289
complexity = {True: 0.0, False: 0.0}
@@ -292,8 +292,6 @@ def genIndexes(configuracion, partida, alm):
292292
piecesactivity = {True: 0.0, False: 0.0}
293293
exchangetendency = {True: 0.0, False: 0.0}
294294

295-
elos = partida.calc_elos(configuracion)
296-
297295
n = {True: 0, False: 0}
298296
for jg in partida.liJugadas:
299297
if jg.analisis:

Code/Configuracion.py

+76
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,63 @@ def changeFolder(nueva):
5353
Util.borraFichero(LCFILEFOLDER)
5454

5555

56+
class Perfomance:
57+
def __init__(self):
58+
self.limit_max = 3500.0
59+
self.limit_min = 800.0
60+
self.lost_factor = 15.0
61+
self.lost_exp = 1.35
62+
63+
self.very_bad_lostp = 200
64+
self.bad_lostp = 90
65+
self.bad_limit_min = 1200.0
66+
self.very_bad_factor = 8
67+
self.bad_factor = 2
68+
69+
self.very_good_depth = 6
70+
self.good_depth = 3
71+
72+
def elo(self, xlost):
73+
return min(max(int(self.limit_max - self.lost_factor * (xlost ** self.lost_exp)), self.limit_min), self.limit_max)
74+
75+
def elo_bad_vbad(self, xlost):
76+
elo = self.elo(xlost)
77+
vbad = xlost > self.very_bad_lostp
78+
bad = False if vbad else xlost > self.bad_lostp
79+
return elo, bad, vbad
80+
81+
def limit(self, verybad, bad, nummoves):
82+
if verybad or bad:
83+
return int(max(self.limit_max - self.very_bad_factor*1000.0 * verybad / nummoves - self.bad_factor*1000.0 * bad / nummoves, self.bad_limit_min))
84+
else:
85+
return self.limit_max
86+
87+
def save_dic(self):
88+
dic = {}
89+
default = Perfomance()
90+
for x in dir(self):
91+
if not x.startswith("_"):
92+
atr = getattr(self, x)
93+
if not callable(atr):
94+
if atr != getattr(default, x):
95+
dic[x] = atr
96+
return dic
97+
98+
def restore_dic(self, dic):
99+
for x in dir(self):
100+
if x in dic:
101+
setattr(self, x, dic[x])
102+
103+
def save(self):
104+
dic = self.save_dic()
105+
return str(dic)
106+
107+
def restore(self, txt):
108+
if txt:
109+
dic = eval(txt)
110+
self.restore_dic(dic)
111+
112+
56113
class Configuracion:
57114
def __init__(self, user):
58115

@@ -175,6 +232,8 @@ def __init__(self, user):
175232

176233
self.palette = {}
177234

235+
self.perfomance = Perfomance()
236+
178237
self.grupos = BaseConfig.Grupos(self)
179238
self.grupos.nuevo("TarraschToy", 0, 1999, 0)
180239
self.grupos.nuevo("Bikjump", 2000, 2400, 600)
@@ -280,6 +339,10 @@ def ponCarpetas(self, user):
280339
self.ficheroExpeditions = "%s/Expeditions.db" % self.carpeta
281340
self.ficheroSingularMoves = "%s/SingularMoves.db" % self.carpeta
282341

342+
if not Util.existeFichero(self.ficheroRecursos):
343+
Util.copiaFichero("IntFiles/recursos.dbl", self.ficheroRecursos)
344+
345+
283346
def compruebaBMT(self):
284347
if not Util.existeFichero(self.ficheroBMT):
285348
self.ficheroBMT = "%s/lucas.bmt" % self.carpeta
@@ -321,6 +384,8 @@ def limpia(self, nombre):
321384

322385
self.rival = self.buscaRival(self.rivalInicial)
323386

387+
self.perfomance = Perfomance()
388+
324389
def buscaRival(self, clave, defecto=None):
325390
if clave in self.dicRivales:
326391
return self.dicRivales[clave]
@@ -546,6 +611,8 @@ def graba(self, aplazamiento=None):
546611
dic["CHECKFORUPDATE"] = self.checkforupdate
547612
dic["PALETTE"] = self.palette
548613

614+
dic["PERFOMANCE"] = self.perfomance.save()
615+
549616
for clave, rival in self.dicRivales.iteritems():
550617
dic["RIVAL_%s" % clave] = rival.graba()
551618
if aplazamiento:
@@ -682,6 +749,10 @@ def lee(self):
682749
self.checkforupdate = dg("CHECKFORUPDATE", self.checkforupdate)
683750
self.palette = dg("PALETTE", self.palette)
684751

752+
perf = dg("PERFOMANCE")
753+
if perf:
754+
self.perfomance.restore(perf)
755+
685756
for k in dic.keys():
686757
if k.startswith("RIVAL_"):
687758
claveK = k[6:]
@@ -790,6 +861,11 @@ def listaMotoresCompleta(self):
790861
li = sorted(li, key=operator.itemgetter(0))
791862
return li
792863

864+
def carpetaTemporal(self):
865+
dirTmp = os.path.join(self.carpeta, "tmp")
866+
Util.creaCarpeta(dirTmp)
867+
return dirTmp
868+
793869
def ficheroTemporal(self, extension):
794870
dirTmp = os.path.join(self.carpeta, "tmp")
795871
return Util.ficheroTemporal(dirTmp, extension)

Code/Entrenamientos.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from Code import GestorTurnOnLights
1212
from Code import GestorGM
1313
from Code import GestorMate
14+
from Code import TurnOnLights
1415
from Code import Memoria
1516
from Code.QT import DatosNueva
1617
from Code.QT import Iconos
@@ -242,9 +243,19 @@ def menuTacticas(tipo, carpetaBase):
242243
# TOL
243244
menu1.separador()
244245
menu2 = menu1.submenu(_("Turn on the lights"), Iconos.TOL())
245-
xopcion(menu2, "tol_uned", _("UNED chess school"), Iconos.Uned())
246+
menu3 = menu2.submenu(_("Memory mode"), Iconos.TOL())
247+
xopcion(menu3, "tol_uned", _("UNED chess school"), Iconos.Uned())
248+
menu3.separador()
249+
xopcion(menu3, "tol_uwe_easy", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe())
250+
menu3.separador()
251+
xopcion(menu3, "tol_uwe", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe())
246252
menu2.separador()
247-
xopcion(menu2, "tol_uwe", _("Uwe Auerswald"), Iconos.Uwe())
253+
menu3 = menu2.submenu(_("Calculation mode"), Iconos.Calculo())
254+
xopcion(menu3, "tol_uned_calc", _("UNED chess school"), Iconos.Uned())
255+
menu3.separador()
256+
xopcion(menu3, "tol_uwe_easy_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe())
257+
menu3.separador()
258+
xopcion(menu3, "tol_uwe_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe())
248259
# Washing
249260
menu1.separador()
250261
xopcion(menu1, "washing_machine", _("The Washing Machine"), Iconos.WashingMachine())
@@ -625,12 +636,18 @@ def everest(self):
625636
PantallaEverest.everest(self.procesador)
626637

627638
def turn_on_lights(self, name):
628-
if name == "uned":
639+
if name.startswith("uned"):
629640
title = _("UNED chess school")
630641
folder = "Trainings/Tactics by UNED chess school"
631642
icono = Iconos.Uned()
632643
li_tam_blocks = (6, 12, 20, 30, 60)
633-
elif name == "uwe":
644+
elif name.startswith("uwe_easy"):
645+
title = "%s (%s)" % (_("Uwe Auerswald"), _("Initial"))
646+
TurnOnLights.compruebaUweEasy(self.configuracion, name)
647+
folder = self.configuracion.carpetaTemporal()
648+
icono = Iconos.Uwe()
649+
li_tam_blocks = (4, 6, 9, 18, 36)
650+
elif name.startswith("uwe"):
634651
title = _("Uwe Auerswald")
635652
folder = "Trainings/Tactics by Uwe Auerswald"
636653
icono = Iconos.Uwe()

Code/Gestor.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,9 @@ def utilidades(self, liMasOpciones=None, siArbol=True):
14921492

14931493
def showAnalisis(self):
14941494
um = self.procesador.unMomento()
1495+
elos = self.partida.calc_elos(self.configuracion)
14951496
alm = Histogram.genHistograms(self.partida, self.configuracion.centipawns)
1496-
alm.indexesHTML, alm.indexesRAW, alm.eloW, alm.eloB, alm.eloT = AnalisisIndexes.genIndexes(self.procesador.configuracion, self.partida, alm)
1497+
alm.indexesHTML, alm.indexesRAW, alm.eloW, alm.eloB, alm.eloT = AnalisisIndexes.genIndexes(self.partida, elos, alm)
14971498
um.final()
14981499
PantallaAnalisis.showGraph(self.pantalla, self, alm, Analisis.muestraAnalisis)
14991500

Code/GestorTurnOnLights.py

+39-17
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@ def inicio(self, num_theme, num_block, tol):
2323
self.block = self.tol.get_block(self.num_theme, self.num_block)
2424
self.block.shuffle()
2525

26+
self.calculation_mode = self.tol.is_calculation_mode()
27+
self.penaltyError = self.block.penaltyError(self.calculation_mode)
28+
self.penaltyHelp = self.block.penaltyHelp(self.calculation_mode)
29+
2630
self.av_seconds = self.block.av_seconds()
2731
if self.av_seconds:
28-
cat, ico = self.block.cqualification()
32+
cat, ico = self.block.cqualification(self.calculation_mode)
2933
self.lb_previous = "%s - %0.2f\"" % (cat, self.av_seconds)
3034
else:
3135
self.lb_previous = None
3236
self.num_line = 0
3337
self.num_lines = len(self.block)
38+
self.num_moves = 0
3439

3540
self.total_time_used = 0.0
3641
self.ayudas = 0
@@ -53,16 +58,18 @@ def inicio(self, num_theme, num_block, tol):
5358

5459
self.next_line_run()
5560

56-
def pon_rotulos(self):
57-
r1 = self.line.label
61+
def pon_rotulos(self, next):
62+
r1 = _("Calculation mode") if self.calculation_mode else _("Memory mode")
63+
r1 += "<br>%s" % self.line.label
64+
5865
if self.lb_previous:
5966
r1 += "<br><b>%s</b>" % self.lb_previous
60-
if self.num_line:
61-
av_secs, txt = self.block.calc_current(self.num_line - 1, self.total_time_used, self.errores, self.ayudas)
62-
r1 += "<br><b>%s: %s - %0.2f\"" % (_("Current"), txt, av_secs)
67+
if self.num_line:
68+
av_secs, txt = self.block.calc_current(self.num_line - 1, self.total_time_used, self.errores, self.ayudas, self.calculation_mode)
69+
r1 += "<br><b>%s: %s - %0.2f\"" % (_("Current"), txt, av_secs)
6370
self.ponRotulo1(r1)
64-
if self.num_line < self.num_lines:
65-
r2 = "<b>%d/%d</b>" % (self.num_line + 1, self.num_lines)
71+
if next is not None:
72+
r2 = "<b>%d/%d</b>" % (self.num_line + next, self.num_lines)
6673
else:
6774
r2 = None
6875
self.ponRotulo2(r2)
@@ -71,7 +78,7 @@ def next_line(self):
7178
if self.num_line < self.num_lines:
7279
self.line = self.block.line(self.num_line)
7380
self.num_move = -1
74-
self.time_used = 0.0
81+
self.ini_time = None
7582

7683
cp = ControlPosicion.ControlPosicion()
7784
cp.leeFen(self.line.fen)
@@ -85,7 +92,7 @@ def next_line(self):
8592
self.pgnRefresh(True)
8693

8794
self.partida.pendienteApertura = False
88-
self.pon_rotulos()
95+
self.pon_rotulos(1)
8996

9097
def next_line_run(self):
9198
liOpciones = [k_mainmenu, k_ayuda, k_reiniciar]
@@ -121,6 +128,13 @@ def procesarAccion(self, clave):
121128
self.next_line_run()
122129

123130
def reiniciar(self):
131+
if self.estado == kJugando:
132+
if self.ini_time:
133+
self.total_time_used += time.time() - self.ini_time
134+
if self.total_time_used:
135+
self.block.new_reinit(self.total_time_used)
136+
self.total_time_used = 0.0
137+
TurnOnLights.write_tol(self.tol)
124138
self.inicio(self.num_theme, self.num_block, self.tol)
125139

126140
def siguienteJugada(self):
@@ -152,8 +166,15 @@ def siguienteJugada(self):
152166

153167
else:
154168
self.siJuegaHumano = True
155-
self.ini_time = time.time()
169+
if not (self.calculation_mode and self.ini_time is None): # Se inicia salvo que sea el principio de la linea
170+
self.ini_time = time.time()
156171
self.activaColor(siBlancas)
172+
if self.calculation_mode:
173+
self.tablero.setDispatchMove(self.dispatchMove)
174+
175+
def dispatchMove(self):
176+
if self.ini_time is None:
177+
self.ini_time = time.time()
157178

158179
def finLinea(self):
159180
self.num_line += 1
@@ -167,11 +188,11 @@ def finLinea(self):
167188
ant_cat_global = self.tol.cat_global()
168189

169190
num_moves = self.block.num_moves()
170-
ta = self.total_time_used + self.errores*5.0 + self.ayudas*10.0
191+
ta = self.total_time_used + self.errores*self.penaltyError + self.ayudas*self.penaltyHelp
171192
tm = ta/num_moves
172193
self.block.new_result(tm)
173194
TurnOnLights.write_tol(self.tol)
174-
cat_block, ico = TurnOnLights.qualification(tm)
195+
cat_block, ico = TurnOnLights.qualification(tm, self.calculation_mode)
175196
cat_level, ico = self.tol.cat_num_level()
176197
cat_global = self.tol.cat_global()
177198

@@ -190,8 +211,8 @@ def finLinea(self):
190211
if cat_global != ant_cat_global:
191212
txt_more_global = '<span style="color:red">%s</span>' % _("New")
192213

193-
cErrores = '<tr><td align=right> %s </td><td> %d (x5"=%d")</td></tr>' % (_('Errors'), self.errores, self.errores*5) if self.errores else ""
194-
cAyudas = '<tr><td align=right> %s </td><td> %d (x10"=%d")</td></tr>' % (_('Hints'), self.ayudas, self.ayudas*10) if self.ayudas else ""
214+
cErrores = '<tr><td align=right> %s </td><td> %d (x%d"=%d")</td></tr>' % (_('Errors'), self.errores, self.penaltyError, self.errores*self.penaltyError) if self.errores else ""
215+
cAyudas = '<tr><td align=right> %s </td><td> %d (x%d"=%d")</td></tr>' % (_('Hints'), self.ayudas, self.penaltyHelp, self.ayudas*self.penaltyHelp) if self.ayudas else ""
195216
mens = ('<hr><center><big>'+_('You have finished this block of positions') +
196217
'<hr><table>' +
197218
'<tr><td align=right> %s </td><td> %0.2f"</td></tr>' % (_('Time used'), self.total_time_used) +
@@ -206,15 +227,16 @@ def finLinea(self):
206227
'</table></center></big><hr>' +
207228
txt_more_line
208229
)
209-
self.pon_rotulos()
230+
self.pon_rotulos(None)
210231
QTUtil2.mensaje(self.pantalla, mens, _("Result of training"))
232+
self.total_time_used = 0
211233

212234
else:
213235
if self.tol.go_fast:
214236
self.next_line_run()
215237
return
216238
QTUtil2.mensajeTemporal(self.pantalla, _("This line training is completed."), 1.3)
217-
self.pon_rotulos()
239+
self.pon_rotulos(0)
218240

219241
self.estado = kFinJuego
220242
self.desactivaTodas()

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.03"
12+
VERSION = "11.04"
1313

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

0 commit comments

Comments
 (0)