juegos

Juegos de terminal de Pancho: Catan (TUI, GUI, web, servidor, PicoCalc), ajedrez, calculadora y minijuegos
git clone https://git.lu3dhn.xyz/juegos.git
Log | Files | Refs

uci.h (1213B)


      1 /* uci.h - UCI en las dos direcciones: cliente para un motor externo (Stockfish,
      2  * opcional) y servidor para que el motor propio lo usen otros programas
      3  * (`ajedrez --uci`: cutechess, fastchess, python-chess, interfaces graficas). */
      4 #ifndef UCI_H
      5 #define UCI_H
      6 
      7 #include <stdbool.h>
      8 #include <sys/types.h>
      9 #include "../core/chess.h"
     10 
     11 /* Nivel extra solo de Linux: juega Stockfish si esta instalado (si no, Maximo). */
     12 #define LEVEL_STOCKFISH LEVEL_COUNT
     13 #define STOCKFISH_MS    1000
     14 
     15 /* Binario de Stockfish o NULL. Se busca en $CHESS_STOCKFISH, en engine/stockfish
     16  * (al lado del ejecutable o del ajedrez en bash) y en el PATH. */
     17 const char *stockfish_path(void);
     18 
     19 typedef struct {
     20     pid_t pid;
     21     int   in, out;            /* le escribimos a in, leemos de out */
     22     char  buf[4096];
     23     int   blen;
     24 } Uci;
     25 
     26 bool uci_open(Uci *u, const char *path);
     27 void uci_close(Uci *u);
     28 /* Busca la jugada de la posicion actual de g con movetime ms. Si *stop se pone
     29  * en 1 le manda "stop" y devuelve lo que tenga. false si el motor fallo. */
     30 bool uci_search(Uci *u, const Game *g, int movetime, volatile int *stop, SearchResult *r);
     31 
     32 /* el motor propio como motor UCI por stdin/stdout */
     33 int app_uci(void);
     34 
     35 #endif