Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Gavira authored Oct 10, 2021
1 parent 3dc3b8f commit e755936
Show file tree
Hide file tree
Showing 11 changed files with 1,177 additions and 94 deletions.
22 changes: 11 additions & 11 deletions src/coiled/AlphaBeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int AspirationWindows(int depth, int en_jaque, int PuntuacionAnterior)

while (1)
{
puntos = AlphaBeta(depth, alpha, beta, en_jaque, false, NO_MOVIMIENTO);
puntos = AlphaBeta(depth, alpha, beta, en_jaque, false);
if (TipoJuego.Interrumpir == true)
{
return puntos;
Expand All @@ -253,12 +253,12 @@ int AspirationWindows(int depth, int en_jaque, int PuntuacionAnterior)
windows += ASPIRATION;
}
#else
puntos = AlphaBeta(depth, -VALOR_MATE, VALOR_MATE, en_jaque, false, NO_MOVIMIENTO);
puntos = AlphaBeta(depth, -VALOR_MATE, VALOR_MATE, en_jaque, false);
return puntos;
#endif
}

int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int SingularMov)
int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo)
{
int i = 0;
_ST_Movimiento ListaMovimiento[MAX_JUGADAS];
Expand Down Expand Up @@ -405,7 +405,7 @@ int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int Sin
}
}
/* Root */
if (AccederTablasDeFinales == true && Ply == 1 && depth == 1 && depth == TipoJuego.DepthAct - 1) /* Hay que jugar una interacción. Para obtener el movimiento ganador. */
if (AccederTablasDeFinales == true && Ply == 1 && depth == 1 && depth == TipoJuego.DepthAct - 1) /* Hay que jugar una interaccion. Para obtener el movimiento ganador. */
{
puntos = 0;
if (Probar_gaviota(&puntos, &Ply) != TBUNKNOWN)
Expand Down Expand Up @@ -475,8 +475,8 @@ int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int Sin
NumeroFichas = Blancas.PeonTotales + Blancas.CaballosTotales + Blancas.AlfilTotales + Blancas.TorresTotales + Blancas.DamasTotales
+ Negras.PeonTotales + Negras.CaballosTotales + Negras.AlfilTotales + Negras.TorresTotales + Negras.DamasTotales + 2; /* + 2 son los reyes */

//if (NumeroFichas > Egbb.EGBB_man || NumeroFichas > Egbb.Limite)
// AccederTablasDeFinales = false;
if (NumeroFichas > TablaDeFinales.Limite)
AccederTablasDeFinales = false;

/* Busqueda. Acceso en depth 1 */
if (AccederTablasDeFinales == true && Ply > 1 && depth <= 1)
Expand Down Expand Up @@ -534,7 +534,7 @@ int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int Sin
{
nuevo_depth = depth - (4 + depth / 6 + MIN(3, (Ev - beta) / 200));
HacerMovimientoNull();
puntos = -AlphaBeta(nuevo_depth, -beta, -beta + 1, en_jaque, true, NO_MOVIMIENTO);
puntos = -AlphaBeta(nuevo_depth, -beta, -beta + 1, en_jaque, true);
DeshacerMovimientoNull();

if (puntos >= beta) return beta;
Expand Down Expand Up @@ -643,17 +643,17 @@ int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int Sin

if (MovimientosLegales == 1)
{
puntos = -AlphaBeta(nuevo_depth - 1, -beta, -alpha, da_jaque, false, NO_MOVIMIENTO);
puntos = -AlphaBeta(nuevo_depth - 1, -beta, -alpha, da_jaque, false);
}
else
{
puntos = -AlphaBeta(nuevo_depth - reducciones, -alpha-1, -alpha, da_jaque, false, NO_MOVIMIENTO);
puntos = -AlphaBeta(nuevo_depth - reducciones, -alpha-1, -alpha, da_jaque, false);

if (puntos > alpha && reducciones != 1)
puntos = -AlphaBeta(nuevo_depth - 1, -alpha - 1, -alpha, da_jaque, false, NO_MOVIMIENTO);
puntos = -AlphaBeta(nuevo_depth - 1, -alpha - 1, -alpha, da_jaque, false);

if (puntos > alpha && puntos < beta)
puntos = -AlphaBeta(nuevo_depth - 1, -beta, -alpha, da_jaque, false, NO_MOVIMIENTO);
puntos = -AlphaBeta(nuevo_depth - 1, -beta, -alpha, da_jaque, false);
}

DeshacerMovimiento();
Expand Down
2 changes: 1 addition & 1 deletion src/coiled/AlphaBeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Metodos
******************************************************************************/
int AspirationWindows(int depth, int en_jaque, int PuntuacionAnterior); /* Rutina Aspiration Windows */
int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo, int SingularMov); /* Rutina AlphaBeta Vp */
int AlphaBeta(int depth, int alpha, int beta, int en_jaque, int Es_Nulo); /* Rutina AlphaBeta Vp */
int AlphaBetaQs(int alpha, int beta); /* Rutina AlphaBeta Quiescence */
void ActualizarVp(int M); /* Actualiza la variante principal triangular durante la busqueda. */
void ActualizarVpRoot(); /* Actualiza la variante principal de una busqueda terminada de root */
Expand Down
141 changes: 141 additions & 0 deletions src/coiled/Coiled_Windows_x86.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Coiled" />
<Option platforms="Windows;" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option platforms="Windows;" />
<Option output="bin/Release/Coiled_10_x86" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-Wnon-virtual-dtor" />
<Add option="-Wshadow" />
<Add option="-Winit-self" />
<Add option="-Wredundant-decls" />
<Add option="-Wcast-align" />
<Add option="-Wundef" />
<Add option="-Wfloat-equal" />
<Add option="-Winline" />
<Add option="-Wunreachable-code" />
<Add option="-Wmissing-declarations" />
<Add option="-Wmissing-include-dirs" />
<Add option="-Wswitch-enum" />
<Add option="-Wswitch-default" />
<Add option="-Wmain" />
<Add option="-Wextra" />
<Add option="-Wall" />
<Add option="-Wold-style-cast" />
<Add option="-m32" />
<Add option="-march=i686" />
<Add option="-mtune=generic" />
</Compiler>
<Linker>
<Add option="-lm" />
</Linker>
</Target>
<Target title="Release">
<Option platforms="Windows;" />
<Option output="bin/Release/Coiled_10_x86" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add option="-march=i686" />
<Add option="-mtune=generic" />
<Add option="-m32" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="-lm" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="AlphaBeta.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="AlphaBeta.h" />
<Unit filename="Cpu.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Cpu.h" />
<Unit filename="Definiciones.h" />
<Unit filename="Estructuras.h" />
<Unit filename="Evaluacion.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Evaluacion.h" />
<Unit filename="Externo.h" />
<Unit filename="Fen.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Fen.h" />
<Unit filename="GeneradorDeMovimientos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="GeneradorDeMovimientos.h" />
<Unit filename="Hash.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Hash.h" />
<Unit filename="Historico.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Historico.h" />
<Unit filename="Inicio.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="LibroAperturas.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="LibroAperturas.h" />
<Unit filename="OrdenarMovimientos.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="OrdenarMovimientos.h" />
<Unit filename="Perft.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Perft.h" />
<Unit filename="See.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="See.h" />
<Unit filename="Utilidades.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="Utilidades.h" />
<Unit filename="egbb.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="egbb.h" />
<Unit filename="nnue.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="nnue.h" />
<Unit filename="syzygy.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="syzygy.h" />
<Unit filename="tbprobe.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tbprobe.h" />
<Unit filename="ver.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
114 changes: 57 additions & 57 deletions src/coiled/Cpu.c
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
#include "Cpu.h"

#ifdef USAR_NNUE

#ifdef _WIN32
void ObtenerCpu(_ST_Cpu *Cpu)
{
int cpuinfo[4];
unsigned int ids = 0;

__cpuid(cpuinfo, 0);
ids = cpuinfo[0];

__cpuid(cpuinfo, 1);
Cpu->SSE2 = cpuinfo[3] >> 26 & 1;
Cpu->SSE3 = cpuinfo[2] & 1;
Cpu->SSE41 = cpuinfo[2] >> 19 & 1;

if (ids >= 7)
{
__cpuid(cpuinfo, 7);
Cpu->AVX2 = cpuinfo[1] >> 5 & 1;
}
}

#else
void ObtenerCpu(_ST_Cpu* Cpu)
{
int regs[4] = { 0, 0, 0, 0 };
unsigned int ids = 0;

#if (defined __clang__ || defined __GNUC__)
regs[0] = 0x00000001;
__asm__ __volatile__(
"cpuid;"
: "+a" (regs[0]),
"=b" (regs[1]),
"=c" (regs[2]),
"=d" (regs[3]));
#else
__cpuid(regs, 0);
ids = regs[0];

__cpuid(regs, 1);
Cpu->SSE2 = regs[3] >> 26 & 1;
Cpu->SSE3 = regs[2] & 1;
Cpu->SSE41 = regs[2] >> 19 & 1;

if (ids >= 7)
{
__cpuid(regs, 7);
Cpu->AVX2 = regs[1] >> 5 & 1;
}
#endif
}
#endif
#endif
#include "Cpu.h"

#ifdef USAR_NNUE

#ifdef _WIN32
void ObtenerCpu(_ST_Cpu *Cpu)
{
int cpuinfo[4];
unsigned int ids = 0;

__cpuid(cpuinfo, 0);
ids = cpuinfo[0];

__cpuid(cpuinfo, 1);
Cpu->SSE2 = cpuinfo[3] >> 26 & 1;
Cpu->SSE3 = cpuinfo[2] & 1;
Cpu->SSE41 = cpuinfo[2] >> 19 & 1;

if (ids >= 7)
{
__cpuid(cpuinfo, 7);
Cpu->AVX2 = cpuinfo[1] >> 5 & 1;
}
}

#else
void ObtenerCpu(_ST_Cpu* Cpu)
{
int regs[4] = { 0, 0, 0, 0 };
unsigned int ids = 0;

#if (defined __clang__ || defined __GNUC__)
regs[0] = 0x00000001;
__asm__ __volatile__(
"cpuid;"
: "+a" (regs[0]),
"=b" (regs[1]),
"=c" (regs[2]),
"=d" (regs[3]));
#else
__cpuid(regs, 0);
ids = regs[0];

__cpuid(regs, 1);
Cpu->SSE2 = regs[3] >> 26 & 1;
Cpu->SSE3 = regs[2] & 1;
Cpu->SSE41 = regs[2] >> 19 & 1;

if (ids >= 7)
{
__cpuid(regs, 7);
Cpu->AVX2 = regs[1] >> 5 & 1;
}
#endif
}
#endif
#endif
8 changes: 7 additions & 1 deletion src/coiled/Definiciones.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define USAR_NNUE /* En version de 64 bit activamos la opcion de evaluacion NNUE */
#endif

//#define DEBUG
//#define DEBUG /* Activa/desactiva los mensajes en formato debug "info string ....." */
#ifdef DEBUG
#define INFO_STRING "info string "
#else
Expand All @@ -60,6 +60,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h> /* log(x) */
#include <unistd.h> /* Necesario para vincular librerias, SqliIte y TbProbe y EntradaStdIn() */
#include <sys/time.h> /* Tiempo */
#include <dlfcn.h>
#define CDECL
#define HMODULE void*
#define LoadLibrary(x) dlopen(x,RTLD_LAZY)
#define FreeLibrary(x) dlclose(x)
#define GetProcAddress dlsym
#endif

#ifdef _MSC_VER
Expand Down
Loading

0 comments on commit e755936

Please sign in to comment.