Skip to content

Commit

Permalink
Version 2.11g
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Feb 23, 2024
1 parent a2a4650 commit ff2a78f
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 55 deletions.
14 changes: 8 additions & 6 deletions bin/Code/Analysis/RunAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def __init__(self, filebase):
self.alm = None
self.ag = None
self.num_worker = None
# self.game = None
# self.recno = None

def xreceive(self):
if self.is_closed:
Expand Down Expand Up @@ -160,6 +158,8 @@ def analyze(self, game, recno):

def progress(self, npos, n_moves):
self.window.progress(npos, n_moves)
QTUtil.refresh_gui()
return not self.is_closed


def run(filebase):
Expand Down Expand Up @@ -190,7 +190,7 @@ def __init__(self, cpu: CPU):

self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.xreceive)
self.timer.start(1000)
self.timer.start(200)
self.is_closed = False

def xreceive(self):
Expand All @@ -199,7 +199,7 @@ def xreceive(self):
self.cpu.procesa()

def init_game(self, num_game, num_moves):
self.lb_game.set_text("%s %d" % (_("Game"), num_game))
self.lb_game.set_text("%s %d" % (_("Game"), num_game+1))
QTUtil.refresh_gui()

def closeEvent(self, event):
Expand All @@ -208,6 +208,7 @@ def closeEvent(self, event):
def finalizar(self):
if not self.is_closed:
self.is_closed = True
self.cpu.is_closed = True
self.timer.stop()
self.accept()

Expand Down Expand Up @@ -548,7 +549,6 @@ def gui_dispatch(xrm):
if self.bmtbrilliancies and self.bmt_listaBrilliancies is None:
self.bmt_listaBrilliancies = BMT.BMTLista()


xlibro_aperturas = self.book

is_white = self.white
Expand Down Expand Up @@ -615,7 +615,9 @@ def gui_dispatch(xrm):
n_moves = len(li_pos_moves)

for npos, pos_move in enumerate(li_pos_moves, 1):
self.cpu.progress(npos, n_moves)
if not self.cpu.progress(npos, n_moves):
return

if pos_move in st_borrar:
continue

Expand Down
11 changes: 7 additions & 4 deletions bin/Code/Analysis/RunAnalysisControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ def processing(self):

if actives == 0:
self.close()
else:
QtCore.QTimer.singleShot(1000, self.processing)
QTUtil.refresh_gui()

def save_bmt(self, bmt):
if bmt is None:
Expand Down Expand Up @@ -265,12 +262,18 @@ def __init__(self, w_parent, amww: AnalysisMassiveWithWorkers, nregs: int):
self.restore_video(anchoDefecto=400, altoDefecto=40)
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.xreceive)
self.timer.start(1000)
self.timer.start(200)

self.restore_video()
self.working = False

def xreceive(self):
QTUtil.refresh_gui()
if self.working:
return
self.working = True
self.amww.processing()
self.working = False

def xcancel(self):
self._is_canceled = True
Expand Down
8 changes: 4 additions & 4 deletions bin/Code/CompetitionWithTutor/ManagerCompeticion.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def analyze_begin(self):

def analyze_end(self):
if self.if_analyzing:
self.mrmTutor = self.xtutor.ac_final(-1)
self.mrm_tutor = self.xtutor.ac_final(-1)
self.is_analyzed_by_tutor = True
self.if_analyzing = False

Expand All @@ -348,13 +348,13 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):

if siMirarTutor:
if not self.is_analyzed_by_tutor:
self.mrmTutor = self.analizaTutor()
self.mrm_tutor = self.analizaTutor()

if self.mrmTutor is None:
if self.mrm_tutor is None:
self.sigueHumano()
return False
if not self.tutor_book.si_esta(self.last_fen(), movimiento):
if Tutor.launch_tutor_movimiento(self.mrmTutor, movimiento):
if Tutor.launch_tutor_movimiento(self.mrm_tutor, movimiento):
self.refresh()
if not move.is_mate:
tutor = Tutor.Tutor(self, move, from_sq, to_sq, False)
Expand Down
4 changes: 2 additions & 2 deletions bin/Code/GM/ManagerGM.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def analyze_end(self):
if self.if_analyzing:
self.if_analyzing = False
if self.continueTt:
self.mrmTutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
self.mrm_tutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
else:
self.mrmTutor = self.xtutor.ac_final_limit()
self.mrm_tutor = self.xtutor.ac_final_limit()

def play_next_move(self):
self.analyze_end()
Expand Down
6 changes: 3 additions & 3 deletions bin/Code/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,13 @@ def analizaTutor(self, with_cursor=False):
# self.thinking(True)
fen = self.game.last_position.fen()
if not self.is_finished():
self.mrmTutor = self.xtutor.analiza(fen)
self.mrm_tutor = self.xtutor.analiza(fen)
else:
self.mrmTutor = None
self.mrm_tutor = None
# self.thinking(False)
if with_cursor:
self.main_window.pensando_tutor(False)
return self.mrmTutor
return self.mrm_tutor

def conf_engines(self):
w = WConfEngines.WConfEngines(self.main_window)
Expand Down
6 changes: 3 additions & 3 deletions bin/Code/ManagerEntPos.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def analyze_end(self, is_mate=False):
if self.is_analyzed_by_tutor:
return
self.main_window.pensando_tutor(True)
self.mrmTutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
self.mrm_tutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
self.main_window.pensando_tutor(False)

def analiza_stop(self):
Expand Down Expand Up @@ -511,7 +511,7 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):
if self.is_tutor_enabled:
if not self.is_analyzed_by_tutor:
self.analizaTutor(True)
if self.mrmTutor.mejorMovQue(a1h8):
if self.mrm_tutor.mejorMovQue(a1h8):
if not move.is_mate:
self.beepError()
tutor = Tutor.Tutor(self, move, from_sq, to_sq, False)
Expand All @@ -528,7 +528,7 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):
move = move_tutor

del tutor
self.mrmTutor = None
self.mrm_tutor = None

self.move_the_pieces(move.liMovs)
self.add_move(move, True)
Expand Down
40 changes: 21 additions & 19 deletions bin/Code/PlayAgainstEngine/ManagerPlayAgainstEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class ManagerPlayAgainstEngine(Manager.Manager):
cache_analysis = {}
with_takeback = True
seconds_per_move = 0
mrm_tutor = None

def start(self, dic_var):
self.base_inicio(dic_var)
Expand Down Expand Up @@ -825,7 +826,7 @@ def analyze_begin(self):
return

if self.game.last_position.fenm2() in self.cache_analysis:
self.mrmTutor = self.cache_analysis[self.game.last_position.fenm2()]
self.mrm_tutor = self.cache_analysis[self.game.last_position.fenm2()]
self.is_analyzed_by_tutor = True
self.is_analyzing = False
return
Expand All @@ -849,7 +850,7 @@ def analyze_end(self, is_mate=False):
return

if self.game.last_position.fenm2() in self.cache_analysis:
self.mrmTutor = self.cache_analysis[self.game.last_position.fenm2()]
self.mrm_tutor = self.cache_analysis[self.game.last_position.fenm2()]
self.is_analyzed_by_tutor = True
self.is_analyzing = False
return
Expand Down Expand Up @@ -880,9 +881,9 @@ def analyze_end(self, is_mate=False):

self.main_window.pensando_tutor(True)
if self.continueTt:
self.mrmTutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
self.mrm_tutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
else:
self.mrmTutor = self.xtutor.ac_final_limit()
self.mrm_tutor = self.xtutor.ac_final_limit()
self.main_window.pensando_tutor(False)
self.is_analyzed_by_tutor = True

Expand Down Expand Up @@ -1125,7 +1126,8 @@ def help_to_move(self):
move = Move.Move(self.game, position_before=self.game.last_position.copia())
if self.is_tutor_enabled:
self.analyze_end()
move.analysis = self.mrmTutor, 0
if self.mrm_tutor:
move.analysis = self.mrm_tutor, 0
Analysis.show_analysis(self.procesador, self.xtutor, move, self.board.is_white_bottom, 0, must_save=False)
if self.hints:
self.hints -= 1
Expand Down Expand Up @@ -1164,7 +1166,7 @@ def play_instead_of_me(self):

if self.is_tutor_enabled:
self.analyze_end()
rm = self.mrmTutor.mejorMov()
rm = self.mrm_tutor.mejorMov()
return self.player_has_moved_base(rm.from_sq, rm.to_sq, rm.promotion)

if self.if_analyzing:
Expand All @@ -1185,7 +1187,7 @@ def pww_centipawns_lost(self, rm_best: EngineResponse.EngineResponse, rm_user: E
rm_best1: EngineResponse.EngineResponse = mrm.rmBest()
rm_user1: EngineResponse.EngineResponse = mrm.li_rm[pos]
cps += rm_best1.puntosABS_5() - rm_user1.puntosABS_5()
rm_best = self.mrmTutor.rmBest()
rm_best = self.mrm_tutor.rmBest()
cps += rm_best.puntosABS_5() - rm_user.puntosABS_5()

return cps
Expand Down Expand Up @@ -1297,7 +1299,7 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):
self.analyze_end(is_mate) # tiene que acabar siempre
if not is_mate and not is_choosed and self.is_tutor_enabled:
if not self.tutor_book.si_esta(fen_base, a1h8):
rm_user, n = self.mrmTutor.buscaRM(a1h8)
rm_user, n = self.mrm_tutor.buscaRM(a1h8)
if not rm_user:
self.main_window.pensando_tutor(True)
rm_user = self.xtutor.valora(self.game.last_position, from_sq, to_sq, move.promotion)
Expand All @@ -1307,36 +1309,36 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):
self.tc_player.restart()
self.enable_toolbar()
return False
self.mrmTutor.add_rm(rm_user)
self.cache_analysis[fen_basem2] = self.mrmTutor
self.mrm_tutor.add_rm(rm_user)
self.cache_analysis[fen_basem2] = self.mrm_tutor

si_analisis = True
points_best, points_user = self.mrmTutor.difPointsBest(a1h8)
points_best, points_user = self.mrm_tutor.difPointsBest(a1h8)
self.set_summary("POINTSBEST", points_best)
self.set_summary("POINTSUSER", points_user)

if self.play_while_win:
if Tutor.launch_tutor(self.mrmTutor, rm_user, tp=MISTAKE):
if Tutor.launch_tutor(self.mrm_tutor, rm_user, tp=MISTAKE):
game_over_message_pww = _("You have made a bad move.")
else:
cpws_lost = self.pww_centipawns_lost(self.mrmTutor.rmBest, rm_user)
cpws_lost = self.pww_centipawns_lost(self.mrm_tutor.rmBest, rm_user)
if cpws_lost > self.limit_pww:
game_over_message_pww = "%s<br>%s" % (
_("You have exceeded the limit of lost centipawns."),
_("Lost centipawns %d") % cpws_lost,
)
if game_over_message_pww:
rm0 = self.mrmTutor.mejorMov()
rm0 = self.mrm_tutor.mejorMov()
self.board.put_arrow_scvar([(rm0.from_sq, rm0.to_sq)])

elif Tutor.launch_tutor(self.mrmTutor, rm_user):
elif Tutor.launch_tutor(self.mrm_tutor, rm_user):
if not move.is_mate:
si_tutor = True
self.beepError()
if self.chance:
num = self.mrmTutor.numMejorMovQue(a1h8)
num = self.mrm_tutor.numMejorMovQue(a1h8)
if num:
rm_tutor = self.mrmTutor.rmBest()
rm_tutor = self.mrm_tutor.rmBest()
menu = QTVarios.LCMenu(self.main_window)
menu.opcion("None", _("There are %d best movements") % num, Iconos.Engine())
menu.separador()
Expand Down Expand Up @@ -1400,9 +1402,9 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):
self.set_summary("TIMEUSER", time_s)

if si_analisis:
rm, nPos = self.mrmTutor.buscaRM(move.movimiento())
rm, nPos = self.mrm_tutor.buscaRM(move.movimiento())
if rm:
move.analysis = self.mrmTutor, nPos
move.analysis = self.mrm_tutor, nPos

if game_over_message_pww:
game_over_message_pww = '<span style="font-size:14pts">%s<br>%s<br><br><b>%s</b>' % (
Expand Down
10 changes: 5 additions & 5 deletions bin/Code/Tutor/Tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, manager, move, from_sq, to_sq, siEntrenando):
self.move = move
self.from_sq = from_sq
self.to_sq = to_sq
self.mrmTutor = manager.mrmTutor
self.mrm_tutor = manager.mrm_tutor
self.rm_rival = manager.rm_rival
self.is_white = manager.is_human_side_white
self.siEntrenando = siEntrenando
Expand All @@ -30,7 +30,7 @@ def __init__(self, manager, move, from_sq, to_sq, siEntrenando):

def elegir(self, has_hints, li_ap_posibles=None):

self.rmUsuario, posUsuario = self.mrmTutor.buscaRM(self.move.movimiento())
self.rmUsuario, posUsuario = self.mrm_tutor.buscaRM(self.move.movimiento())
if self.rmUsuario is None:
# Elegimos si la opcion del tutor es mejor que la del usuario
# Ponemos un mensaje mientras piensa
Expand All @@ -39,7 +39,7 @@ def elegir(self, has_hints, li_ap_posibles=None):
fen = self.move.position.fen()
mrm_usuario = self.managerTutor.analiza(fen)
if len(mrm_usuario.li_rm) == 0:
self.rmUsuario = self.mrmTutor.li_rm[0].copia()
self.rmUsuario = self.mrm_tutor.li_rm[0].copia()
self.rmUsuario.from_sq = self.move.from_sq
self.rmUsuario.to_sq = self.move.to_sq
self.rmUsuario.promotion = self.move.promotion
Expand All @@ -52,7 +52,7 @@ def elegir(self, has_hints, li_ap_posibles=None):
me.final()

# Comparamos la puntuacion del usuario con la del tutor
if not launch_tutor(self.mrmTutor, self.rmUsuario):
if not launch_tutor(self.mrm_tutor, self.rmUsuario):
return False

# Creamos la lista de movimientos analizados por el tutor
Expand Down Expand Up @@ -149,7 +149,7 @@ def do_lirm(self, posUsuario):
li = []
pb = self.move.position_before

for n, rm in enumerate(self.mrmTutor.li_rm):
for n, rm in enumerate(self.mrm_tutor.li_rm):
if n != posUsuario:
pv1 = rm.getPV().split(" ")[0]
from_sq = pv1[:2]
Expand Down
14 changes: 7 additions & 7 deletions bin/Code/Washing/ManagerWashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ def analyze_end(self, is_mate=False):
self.is_analyzing = False
self.thinking(True)
if self.continueTt:
self.mrmTutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
self.mrm_tutor = self.xtutor.ac_final(self.xtutor.mstime_engine)
else:
self.mrmTutor = self.xtutor.ac_final_limit()
self.mrm_tutor = self.xtutor.ac_final_limit()
self.thinking(False)
self.is_analyzed_by_tutor = True

Expand Down Expand Up @@ -690,15 +690,15 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):

self.analyze_end() # tiene que acabar siempre
if not is_selected:
rm_user, n = self.mrmTutor.buscaRM(movimiento)
rm_user, n = self.mrm_tutor.buscaRM(movimiento)
if not rm_user:
rm_user = self.xtutor.valora(self.game.last_position, from_sq, to_sq, move.promotion)
if not rm_user:
self.continue_analysis_human_move()
return False
self.mrmTutor.add_rm(rm_user)
self.mrm_tutor.add_rm(rm_user)
siAnalisis = True
pointsBest, pointsUser = self.mrmTutor.difPointsBest(movimiento)
pointsBest, pointsUser = self.mrm_tutor.difPointsBest(movimiento)
if (pointsBest - pointsUser) > 0:
if not move.is_mate:
tutor = Tutor.Tutor(self, move, from_sq, to_sq, False)
Expand All @@ -721,9 +721,9 @@ def player_has_moved(self, from_sq, to_sq, promotion=""):


if siAnalisis:
rm, nPos = self.mrmTutor.buscaRM(move.movimiento())
rm, nPos = self.mrm_tutor.buscaRM(move.movimiento())
if rm:
move.analysis = self.mrmTutor, nPos
move.analysis = self.mrm_tutor, nPos

self.add_move(move, True)
self.error = ""
Expand Down
Loading

0 comments on commit ff2a78f

Please sign in to comment.