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

Commit

Permalink
Version 11.04
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Dec 7, 2017
1 parent b811043 commit 2afabbc
Show file tree
Hide file tree
Showing 38 changed files with 652 additions and 953 deletions.
2 changes: 1 addition & 1 deletion Code/Analisis.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def guiDispatch(rm):
self.grabaBMT(False, fen, mrm, posAct, clpartida, txtPartida)
self.siBMTbrilliancies = True
else:
nag, color = mrm.setNAG_Color(rm)
nag, color = mrm.setNAG_Color(self.configuracion, rm)
if nag:
jg.masCritica1_4(str(nag))

Expand Down
4 changes: 1 addition & 3 deletions Code/AnalisisIndexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def tp_gamestage(cp, mrm):
return _("Game stage"), calc_gamestage(cp, mrm), get_gamestage(cp, mrm)


def genIndexes(configuracion, partida, alm):
def genIndexes(partida, elos, alm):
average = {True: 0, False: 0}
domination = {True: 0, False: 0}
complexity = {True: 0.0, False: 0.0}
Expand All @@ -292,8 +292,6 @@ def genIndexes(configuracion, partida, alm):
piecesactivity = {True: 0.0, False: 0.0}
exchangetendency = {True: 0.0, False: 0.0}

elos = partida.calc_elos(configuracion)

n = {True: 0, False: 0}
for jg in partida.liJugadas:
if jg.analisis:
Expand Down
76 changes: 76 additions & 0 deletions Code/Configuracion.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,63 @@ def changeFolder(nueva):
Util.borraFichero(LCFILEFOLDER)


class Perfomance:
def __init__(self):
self.limit_max = 3500.0
self.limit_min = 800.0
self.lost_factor = 15.0
self.lost_exp = 1.35

self.very_bad_lostp = 200
self.bad_lostp = 90
self.bad_limit_min = 1200.0
self.very_bad_factor = 8
self.bad_factor = 2

self.very_good_depth = 6
self.good_depth = 3

def elo(self, xlost):
return min(max(int(self.limit_max - self.lost_factor * (xlost ** self.lost_exp)), self.limit_min), self.limit_max)

def elo_bad_vbad(self, xlost):
elo = self.elo(xlost)
vbad = xlost > self.very_bad_lostp
bad = False if vbad else xlost > self.bad_lostp
return elo, bad, vbad

def limit(self, verybad, bad, nummoves):
if verybad or bad:
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))
else:
return self.limit_max

def save_dic(self):
dic = {}
default = Perfomance()
for x in dir(self):
if not x.startswith("_"):
atr = getattr(self, x)
if not callable(atr):
if atr != getattr(default, x):
dic[x] = atr
return dic

def restore_dic(self, dic):
for x in dir(self):
if x in dic:
setattr(self, x, dic[x])

def save(self):
dic = self.save_dic()
return str(dic)

def restore(self, txt):
if txt:
dic = eval(txt)
self.restore_dic(dic)


class Configuracion:
def __init__(self, user):

Expand Down Expand Up @@ -175,6 +232,8 @@ def __init__(self, user):

self.palette = {}

self.perfomance = Perfomance()

self.grupos = BaseConfig.Grupos(self)
self.grupos.nuevo("TarraschToy", 0, 1999, 0)
self.grupos.nuevo("Bikjump", 2000, 2400, 600)
Expand Down Expand Up @@ -280,6 +339,10 @@ def ponCarpetas(self, user):
self.ficheroExpeditions = "%s/Expeditions.db" % self.carpeta
self.ficheroSingularMoves = "%s/SingularMoves.db" % self.carpeta

if not Util.existeFichero(self.ficheroRecursos):
Util.copiaFichero("IntFiles/recursos.dbl", self.ficheroRecursos)


def compruebaBMT(self):
if not Util.existeFichero(self.ficheroBMT):
self.ficheroBMT = "%s/lucas.bmt" % self.carpeta
Expand Down Expand Up @@ -321,6 +384,8 @@ def limpia(self, nombre):

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

self.perfomance = Perfomance()

def buscaRival(self, clave, defecto=None):
if clave in self.dicRivales:
return self.dicRivales[clave]
Expand Down Expand Up @@ -546,6 +611,8 @@ def graba(self, aplazamiento=None):
dic["CHECKFORUPDATE"] = self.checkforupdate
dic["PALETTE"] = self.palette

dic["PERFOMANCE"] = self.perfomance.save()

for clave, rival in self.dicRivales.iteritems():
dic["RIVAL_%s" % clave] = rival.graba()
if aplazamiento:
Expand Down Expand Up @@ -682,6 +749,10 @@ def lee(self):
self.checkforupdate = dg("CHECKFORUPDATE", self.checkforupdate)
self.palette = dg("PALETTE", self.palette)

perf = dg("PERFOMANCE")
if perf:
self.perfomance.restore(perf)

for k in dic.keys():
if k.startswith("RIVAL_"):
claveK = k[6:]
Expand Down Expand Up @@ -790,6 +861,11 @@ def listaMotoresCompleta(self):
li = sorted(li, key=operator.itemgetter(0))
return li

def carpetaTemporal(self):
dirTmp = os.path.join(self.carpeta, "tmp")
Util.creaCarpeta(dirTmp)
return dirTmp

def ficheroTemporal(self, extension):
dirTmp = os.path.join(self.carpeta, "tmp")
return Util.ficheroTemporal(dirTmp, extension)
Expand Down
25 changes: 21 additions & 4 deletions Code/Entrenamientos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from Code import GestorTurnOnLights
from Code import GestorGM
from Code import GestorMate
from Code import TurnOnLights
from Code import Memoria
from Code.QT import DatosNueva
from Code.QT import Iconos
Expand Down Expand Up @@ -242,9 +243,19 @@ def menuTacticas(tipo, carpetaBase):
# TOL
menu1.separador()
menu2 = menu1.submenu(_("Turn on the lights"), Iconos.TOL())
xopcion(menu2, "tol_uned", _("UNED chess school"), Iconos.Uned())
menu3 = menu2.submenu(_("Memory mode"), Iconos.TOL())
xopcion(menu3, "tol_uned", _("UNED chess school"), Iconos.Uned())
menu3.separador()
xopcion(menu3, "tol_uwe_easy", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe())
menu3.separador()
xopcion(menu3, "tol_uwe", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe())
menu2.separador()
xopcion(menu2, "tol_uwe", _("Uwe Auerswald"), Iconos.Uwe())
menu3 = menu2.submenu(_("Calculation mode"), Iconos.Calculo())
xopcion(menu3, "tol_uned_calc", _("UNED chess school"), Iconos.Uned())
menu3.separador()
xopcion(menu3, "tol_uwe_easy_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe())
menu3.separador()
xopcion(menu3, "tol_uwe_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe())
# Washing
menu1.separador()
xopcion(menu1, "washing_machine", _("The Washing Machine"), Iconos.WashingMachine())
Expand Down Expand Up @@ -625,12 +636,18 @@ def everest(self):
PantallaEverest.everest(self.procesador)

def turn_on_lights(self, name):
if name == "uned":
if name.startswith("uned"):
title = _("UNED chess school")
folder = "Trainings/Tactics by UNED chess school"
icono = Iconos.Uned()
li_tam_blocks = (6, 12, 20, 30, 60)
elif name == "uwe":
elif name.startswith("uwe_easy"):
title = "%s (%s)" % (_("Uwe Auerswald"), _("Initial"))
TurnOnLights.compruebaUweEasy(self.configuracion, name)
folder = self.configuracion.carpetaTemporal()
icono = Iconos.Uwe()
li_tam_blocks = (4, 6, 9, 18, 36)
elif name.startswith("uwe"):
title = _("Uwe Auerswald")
folder = "Trainings/Tactics by Uwe Auerswald"
icono = Iconos.Uwe()
Expand Down
3 changes: 2 additions & 1 deletion Code/Gestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,8 +1492,9 @@ def utilidades(self, liMasOpciones=None, siArbol=True):

def showAnalisis(self):
um = self.procesador.unMomento()
elos = self.partida.calc_elos(self.configuracion)
alm = Histogram.genHistograms(self.partida, self.configuracion.centipawns)
alm.indexesHTML, alm.indexesRAW, alm.eloW, alm.eloB, alm.eloT = AnalisisIndexes.genIndexes(self.procesador.configuracion, self.partida, alm)
alm.indexesHTML, alm.indexesRAW, alm.eloW, alm.eloB, alm.eloT = AnalisisIndexes.genIndexes(self.partida, elos, alm)
um.final()
PantallaAnalisis.showGraph(self.pantalla, self, alm, Analisis.muestraAnalisis)

Expand Down
56 changes: 39 additions & 17 deletions Code/GestorTurnOnLights.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def inicio(self, num_theme, num_block, tol):
self.block = self.tol.get_block(self.num_theme, self.num_block)
self.block.shuffle()

self.calculation_mode = self.tol.is_calculation_mode()
self.penaltyError = self.block.penaltyError(self.calculation_mode)
self.penaltyHelp = self.block.penaltyHelp(self.calculation_mode)

self.av_seconds = self.block.av_seconds()
if self.av_seconds:
cat, ico = self.block.cqualification()
cat, ico = self.block.cqualification(self.calculation_mode)
self.lb_previous = "%s - %0.2f\"" % (cat, self.av_seconds)
else:
self.lb_previous = None
self.num_line = 0
self.num_lines = len(self.block)
self.num_moves = 0

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

self.next_line_run()

def pon_rotulos(self):
r1 = self.line.label
def pon_rotulos(self, next):
r1 = _("Calculation mode") if self.calculation_mode else _("Memory mode")
r1 += "<br>%s" % self.line.label

if self.lb_previous:
r1 += "<br><b>%s</b>" % self.lb_previous
if self.num_line:
av_secs, txt = self.block.calc_current(self.num_line - 1, self.total_time_used, self.errores, self.ayudas)
r1 += "<br><b>%s: %s - %0.2f\"" % (_("Current"), txt, av_secs)
if self.num_line:
av_secs, txt = self.block.calc_current(self.num_line - 1, self.total_time_used, self.errores, self.ayudas, self.calculation_mode)
r1 += "<br><b>%s: %s - %0.2f\"" % (_("Current"), txt, av_secs)
self.ponRotulo1(r1)
if self.num_line < self.num_lines:
r2 = "<b>%d/%d</b>" % (self.num_line + 1, self.num_lines)
if next is not None:
r2 = "<b>%d/%d</b>" % (self.num_line + next, self.num_lines)
else:
r2 = None
self.ponRotulo2(r2)
Expand All @@ -71,7 +78,7 @@ def next_line(self):
if self.num_line < self.num_lines:
self.line = self.block.line(self.num_line)
self.num_move = -1
self.time_used = 0.0
self.ini_time = None

cp = ControlPosicion.ControlPosicion()
cp.leeFen(self.line.fen)
Expand All @@ -85,7 +92,7 @@ def next_line(self):
self.pgnRefresh(True)

self.partida.pendienteApertura = False
self.pon_rotulos()
self.pon_rotulos(1)

def next_line_run(self):
liOpciones = [k_mainmenu, k_ayuda, k_reiniciar]
Expand Down Expand Up @@ -121,6 +128,13 @@ def procesarAccion(self, clave):
self.next_line_run()

def reiniciar(self):
if self.estado == kJugando:
if self.ini_time:
self.total_time_used += time.time() - self.ini_time
if self.total_time_used:
self.block.new_reinit(self.total_time_used)
self.total_time_used = 0.0
TurnOnLights.write_tol(self.tol)
self.inicio(self.num_theme, self.num_block, self.tol)

def siguienteJugada(self):
Expand Down Expand Up @@ -152,8 +166,15 @@ def siguienteJugada(self):

else:
self.siJuegaHumano = True
self.ini_time = time.time()
if not (self.calculation_mode and self.ini_time is None): # Se inicia salvo que sea el principio de la linea
self.ini_time = time.time()
self.activaColor(siBlancas)
if self.calculation_mode:
self.tablero.setDispatchMove(self.dispatchMove)

def dispatchMove(self):
if self.ini_time is None:
self.ini_time = time.time()

def finLinea(self):
self.num_line += 1
Expand All @@ -167,11 +188,11 @@ def finLinea(self):
ant_cat_global = self.tol.cat_global()

num_moves = self.block.num_moves()
ta = self.total_time_used + self.errores*5.0 + self.ayudas*10.0
ta = self.total_time_used + self.errores*self.penaltyError + self.ayudas*self.penaltyHelp
tm = ta/num_moves
self.block.new_result(tm)
TurnOnLights.write_tol(self.tol)
cat_block, ico = TurnOnLights.qualification(tm)
cat_block, ico = TurnOnLights.qualification(tm, self.calculation_mode)
cat_level, ico = self.tol.cat_num_level()
cat_global = self.tol.cat_global()

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

cErrores = '<tr><td align=right> %s </td><td> %d (x5"=%d")</td></tr>' % (_('Errors'), self.errores, self.errores*5) if self.errores else ""
cAyudas = '<tr><td align=right> %s </td><td> %d (x10"=%d")</td></tr>' % (_('Hints'), self.ayudas, self.ayudas*10) if self.ayudas else ""
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 ""
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 ""
mens = ('<hr><center><big>'+_('You have finished this block of positions') +
'<hr><table>' +
'<tr><td align=right> %s </td><td> %0.2f"</td></tr>' % (_('Time used'), self.total_time_used) +
Expand All @@ -206,15 +227,16 @@ def finLinea(self):
'</table></center></big><hr>' +
txt_more_line
)
self.pon_rotulos()
self.pon_rotulos(None)
QTUtil2.mensaje(self.pantalla, mens, _("Result of training"))
self.total_time_used = 0

else:
if self.tol.go_fast:
self.next_line_run()
return
QTUtil2.mensajeTemporal(self.pantalla, _("This line training is completed."), 1.3)
self.pon_rotulos()
self.pon_rotulos(0)

self.estado = kFinJuego
self.desactivaTodas()
Expand Down
2 changes: 1 addition & 1 deletion Code/Init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from Code.Constantes import *

DEBUG = False
VERSION = "11.03"
VERSION = "11.04"

if DEBUG:
prlkn("DEBUG " * 20)
Expand Down
Loading

0 comments on commit 2afabbc

Please sign in to comment.