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

Commit

Permalink
Version 11.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Jul 29, 2018
1 parent 5c53141 commit 0603bef
Show file tree
Hide file tree
Showing 84 changed files with 2,055 additions and 678 deletions.
2 changes: 1 addition & 1 deletion Code/AnalisisIndexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def genIndexes(partida, elos, elosFORM, alm):
# for std, tit in ((Partida.OPENING, _("Opening")), (Partida.MIDDLEGAME, _("Middle game")), (Partida.ENDGAME, _("End game"))):
# if elos[None][std]:
# txt += plantillaC % ( tit, int(elos[True][std]), int(elos[False][std]), int(elos[None][std]))
#

# txt += plantillaC % ("Elo WITH FORMULA", elosFORM[True][Partida.ALLGAME], elosFORM[False][Partida.ALLGAME], elosFORM[None][Partida.ALLGAME])
# for std, tit in ((Partida.OPENING, _("Opening")), (Partida.MIDDLEGAME, _("Middle game")), (Partida.ENDGAME, _("End game"))):
# if elos[None][std]:
Expand Down
13 changes: 9 additions & 4 deletions Code/Books.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def porDefecto(self, book=None):
return book
return self.lista[0]

def buscaLibro(self, nombre):
for book in self.lista:
if book.nombre == nombre:
return book
return None

def cambiaModo(self, apli):
if apli in self._modoAnalisis:
self._modoAnalisis = self._modoAnalisis.replace(apli, "")
Expand Down Expand Up @@ -231,7 +237,6 @@ def almListaJugadas(self, fen):

return listaJugadas


def eligeJugadaTipo(self, fen, tipo):
maxim = 0
liMax = []
Expand Down Expand Up @@ -276,7 +281,7 @@ def eligeJugadaTipo(self, fen, tipo):

return pv.lower()

def miraListaPV(self, fen, siMax):
def miraListaPV(self, fen, siMax, onlyone=True):
li = self.book.lista(self.path, fen)

liResp = []
Expand All @@ -287,8 +292,8 @@ def miraListaPV(self, fen, siMax):
if w > maxim:
maxim = w
liResp = [entry.pv()]
# elif w == maxim:
# liResp.append(entry.pv())
elif w == maxim and not onlyone:
liResp.append(entry.pv())
else:
for entry in li:
liResp.append(entry.pv())
Expand Down
1 change: 0 additions & 1 deletion Code/Configuracion.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,6 @@ def lee(self):
if not os.path.isdir(self.folderOpenings):
self.folderOpenings = self.folderBaseOpenings


for k in dic.keys():
if k.startswith("RIVAL_"):
claveK = k[6:]
Expand Down
71 changes: 71 additions & 0 deletions Code/ControlPosicion.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ def siFaltaMaterial(self):

return False

def siFaltaMaterialColor(self, siBlancas):
piezas = ""
nb = "nb"
prq = "prq"
if siBlancas:
nb = nb.upper()
prq = prq.upper()
for v in self.casillas.itervalues():
if v:
if v in prq:
return False
if v in nb:
if piezas:
return False
else:
piezas = v
return False

def numPiezas(self, pieza):
if not self.siBlancas:
pieza = pieza.lower()
Expand Down Expand Up @@ -435,5 +453,58 @@ def siPeonCoronando(self, desdeA1H8, hastaA1H8):

return True

def aura(self):
lista = []

def add(lipos):
for pos in lipos:
lista.append(LCEngine.posA1(pos))

def liBR(npos, fi, ci):
fil, col = LCEngine.posFC(npos)
liM = []
ft = fil + fi
ct = col + ci
while True:
if ft < 0 or ft > 7 or ct < 0 or ct > 7:
break
t = LCEngine.FCpos(ft, ct)
liM.append(t)

pz = self.casillas[LCEngine.posA1(t)]
if pz:
break
ft += fi
ct += ci
add(liM)

pzs = "KQRBNP" if self.siBlancas else "kqrbnp"

for i in range(8):
for j in range(8):
a1 = chr(i + 97) + chr(j + 49)
pz = self.casillas[a1]
if pz and pz in pzs:
pz = pz.upper()
npos = LCEngine.a1Pos(a1)
if pz == "K":
add(LCEngine.liK(npos))
elif pz == "Q":
for f_i, c_i in ((1, 1), (1, -1), (-1, 1), (-1, -1), (1, 0), (-1, 0), (0, 1), (0, -1)):
liBR(npos, f_i, c_i)
elif pz == "R":
for f_i, c_i in ((1, 0), (-1, 0), (0, 1), (0, -1)):
liBR(npos, f_i, c_i)
elif pz == "B":
for f_i, c_i in ((1, 1), (1, -1), (-1, 1), (-1, -1)):
liBR(npos, f_i, c_i)
elif pz == "N":
add(LCEngine.liN(npos))
elif pz == "P":
lim, lix = LCEngine.liP(npos, self.siBlancas)
add(lix)
return lista


def distancia(desde, hasta):
return ((ord(desde[0])-ord(hasta[0]))**2 + (ord(desde[1])-ord(hasta[1]))**2)**0.5
9 changes: 5 additions & 4 deletions Code/EngineThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

DEBUG_ENGINE = False

def xpr(line):

def xpr(exe, line):
if DEBUG_ENGINE:
t = time.time()
prlk("%0.04f %s" % (t - tdbg[0], line))
Expand All @@ -29,7 +30,7 @@ def xprli(li):

if DEBUG_ENGINE:
tdbg = [time.time()]
xpr("DEBUG XMOTOR")
xpr("", "DEBUG XMOTOR")


class Priorities:
Expand Down Expand Up @@ -87,7 +88,7 @@ def cerrar(self):
self.working = False

def put_line(self, line):
assert xpr("put>>> %s\n" % line)
assert xpr(self.exe, "put>>> %s\n" % line)
self.stdin_lock.acquire()
self.stdin.write(line + "\n")
self.stdin_lock.release()
Expand All @@ -109,7 +110,7 @@ def xstdout_thread(self, stdout, lock):
try:
while self.working:
line = stdout.readline()
assert xpr(line)
assert xpr(self.exe, line)
if not line:
break
lock.acquire()
Expand Down
10 changes: 5 additions & 5 deletions Code/EnginesWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def mas(cm):
cm.ponMultiPV(1, 4)
mas(cm)

cm = ConfigMotor("cheng", "Martin Sedlák", "4 0.39", "http://www.vlasak.biz/cheng")
cm = ConfigMotor("cheng", "Martin Sedlák".decode("utf-8"), "4 0.39", "http://www.vlasak.biz/cheng")
cm.path = "cheng4.exe"
cm.elo = 2750
cm.ponMultiPV(20, 256)
Expand Down Expand Up @@ -200,7 +200,7 @@ def mas(cm):
cm.ponMultiPV(20, 100)
mas(cm)

cm = ConfigMotor("texel", "Peter Österlund", "1.07 32bit", "http://hem.bredband.net/petero2b/javachess/index.html#texel")
cm = ConfigMotor("texel", "Peter Österlund".decode("utf-8"), "1.07 32bit", "http://hem.bredband.net/petero2b/javachess/index.html#texel")
cm.path = "texel32old.exe"
cm.elo = 3100
cm.ordenUCI("Hash", "32")
Expand Down Expand Up @@ -288,7 +288,7 @@ def mas(cm):
cm.elo = 2100
mas(cm)

cm = ConfigMotor("andscacs", "Daniel José Queraltó", "0.9032n", "http://www.andscacs.com/")
cm = ConfigMotor("andscacs", "Daniel José Queraltó".decode("utf-8"), "0.9032n", "http://www.andscacs.com/")
cm.path = "andscacs32.exe"
cm.elo = 3150
mas(cm)
Expand All @@ -308,12 +308,12 @@ def mas(cm):
cm.elo = 2627
mas(cm)

cm = ConfigMotor("spike", "Volker Böhm and Ralf Schäfer", "1.4", "http://spike.lazypics.de/index_en.html")
cm = ConfigMotor("spike", "Volker Böhm and Ralf Schäfer".decode("utf-8"), "1.4", "http://spike.lazypics.de/index_en.html")
cm.path = "Spike1.4.exe"
cm.elo = 2921
mas(cm)

cm = ConfigMotor("zappa", "Anthony Cozzie", "1.1", "http://www.acoz.net/zappa/")
cm = ConfigMotor("zappa", "Anthony Cozzie", "1.1", "http://www.acoz.net/zappa/")
cm.path = "zappa.exe"
cm.elo = 2581
cm.removeLog("zappa_log.txt")
Expand Down
4 changes: 1 addition & 3 deletions Code/Entrenamientos.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def xopcion(menu, clave, texto, icono, siDeshabilitado=False):
xopcion(menu, "wgm", _("Play like a Woman Grandmaster"), Iconos.WGranMaestro())
menu.separador()


# Mate --------------------------------------------------------------------------------------------------
menu1 = menu.submenu(_("Training mates"), Iconos.Mate())
for mate in range(1, 5):
Expand Down Expand Up @@ -190,7 +189,6 @@ def menuTacticas(submenu, tipo, carpetaBase, lista):
menuTacticas(submenu1, tipo, carpeta, lista)
return lista


menuTacticas(menu1, "B", "Tactics", [])
lista = []
carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining, "Tactics")
Expand Down Expand Up @@ -718,4 +716,4 @@ def xopcion(menu, clave, texto, icono, siDeshabilitado=False):
td.reduce()
td.menu(menu, xopcion)
resp = menu.lanza()
return resp if resp is None else resp[3:]
return resp if resp is None else resp[3:]
63 changes: 55 additions & 8 deletions Code/Gestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Code import AnalisisIndexes
from Code import AperturasStd
from Code import ControlPGN
from Code import ControlPosicion
from Code import DGT
from Code import Jugada
from Code import Partida
Expand All @@ -28,6 +29,7 @@
from Code.QT import QTUtil2
from Code.QT import QTVarios
from Code.QT import WOpeningGuide
from Code.QT import TabTipos
from Code import Util
from Code import VarGen
from Code import Kibitzers
Expand Down Expand Up @@ -285,18 +287,20 @@ def showCandidates():
if not self.configuracion.siAtajosRaton:
if li_destinos:
self.atajosRatonOrigen = a1h8
if self.atajosRatonDestino and self.atajosRatonDestino in li_destinos:
mueve()
else:
self.atajosRatonDestino = None
showCandidates()
self.atajosRatonDestino = None
# if self.atajosRatonDestino and self.atajosRatonDestino in li_destinos:
# mueve()
# else:
# self.atajosRatonDestino = None
showCandidates()
return
elif li_origenes:
self.atajosRatonDestino = a1h8
if self.atajosRatonOrigen and self.atajosRatonOrigen in li_origenes:
mueve()
else:
self.atajosRatonOrigen = None
self.atajosRatonDestino = None
showCandidates()
return

Expand Down Expand Up @@ -520,6 +524,8 @@ def miraKibitzers(self, jg, columnaClave, soloNuevo=False):
def paraKibitzers(self):
for n, xkibitzer in enumerate(self.liKibitzersActivas):
xkibitzer.terminar() #ponFen(None)
self.procesador.quitaKibitzers()
self.liKibitzersActivas = []

def ponPiezasAbajo(self, siBlancas):
self.tablero.ponerPiezasAbajo(siBlancas)
Expand Down Expand Up @@ -829,7 +835,6 @@ def gridRightMouse(self, siShift, siControl, siAlt):
self.pgnInformacion()
self.pantalla.ajustaTam()


def listado(self, tipo):
if tipo == "pgn":
return self.pgn.actual()
Expand Down Expand Up @@ -899,7 +904,7 @@ def cambioTutor(self):
self.siAnalizadoTutor = False

if self.tipoJuego == kJugEntMaq:
self.analizaTutorInicio()
self.analizaInicio()

def siTerminada(self):
return self.partida.ultPosicion.siTerminada()
Expand Down Expand Up @@ -1054,6 +1059,44 @@ def exePulsadoNum(self, siActivar, numero):
if self.tablero.flechaSC:
self.tablero.flechaSC.show()

elif numero in [2, 7]:
if siActivar:
# Que jugada esta en el tablero
fen = self.fenActivoConInicio()
siBlancas = " w " in fen
if numero == 2:
siMB = siBlancas
else:
siMB = not siBlancas
if siMB != siBlancas:
fen = LCEngine.fenOB(fen)
cp = ControlPosicion.ControlPosicion()
cp.leeFen(fen)
liMovs = cp.aura()

self.liMarcosTmp = []
regMarco = TabTipos.Marco()
color = self.tablero.confTablero.flechaActivoDefecto().colorinterior
if color == -1:
color = self.tablero.confTablero.flechaActivoDefecto().color

st = set()
for h8 in liMovs:
if h8 not in st:
regMarco.a1h8 = h8 + h8
regMarco.siMovible = True
regMarco.color = color
regMarco.colorinterior = color
regMarco.opacidad = 0.5
marco = self.tablero.creaMarco(regMarco)
self.liMarcosTmp.append(marco)
st.add(h8)

else:
for marco in self.liMarcosTmp:
self.tablero.xremoveItem(marco)
self.liMarcosTmp = []

def exePulsadaLetra(self, siActivar, letra):
if siActivar:
dic = { 'a':kMoverInicio,
Expand Down Expand Up @@ -1296,7 +1339,6 @@ def configurar(self, liMasOpciones=None, siCambioTutor=False, siSonidos=False, s
modoPosicionBlind = True
self.tablero.blindfoldChange(modoPosicionBlind)


elif orden == "conf":
self.tablero.blindfoldConfig()

Expand Down Expand Up @@ -1505,6 +1547,11 @@ def utilidades(self, liMasOpciones=None, siArbol=True):

return None

def mensajeEnPGN(self, mens, titulo=None):
p0 = self.pantalla.base.pgn.pos()
p = self.pantalla.mapToGlobal(p0)
QTUtil2.mensajeEnPunto(self.pantalla, mens, titulo, p)

def showAnalisis(self):
um = self.procesador.unMomento()
elos = self.partida.calc_elos(self.configuracion)
Expand Down
2 changes: 1 addition & 1 deletion Code/GestorAlbum.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def ponResultado(self, quien):
self.resultado = kTablas

self.guardarGanados(quien == kGanamos)
QTUtil2.mensaje(self.pantalla, mensaje)
self.mensajeEnPGN(mensaje)
self.ponFinJuego()
self.xrival.cerrar()
self.pantalla.ponToolBar((k_mainmenu, k_configurar, k_utilidades))
Loading

0 comments on commit 0603bef

Please sign in to comment.