IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Voir le flux RSS

tondeurh

Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess

Noter ce billet
par , 22/05/2016 à 15h27 (2035 Affichages)
API UCIChess a https://github.com/tondeur-h/UCIChess

Nom : chessplay.png
Affichages : 1689
Taille : 11,3 Ko
Vu d’un test de l’UCIChess API

C’est pour le logiciel Shredder que Rudolf Huber et Stefan Meyer-Kahlen ont créé le protocole Universal Chess Interface (UCI) entre un moteur d’Echecs qui calcule les coups et une interface graphique (GUI) comme Arena qui les affiche sur l’échiquier.
Ce protocole est maintenant devenu le standard par rapport Winboard.

Le protocole UCI ( UCI = interface d’échecs universel ) décrit la communication d’un moteur d’échecs et une interface utilisateur d’échecs . Le protocole est ouvert et peut être utilisé par tout le monde sans frais de licence . Aujourd’hui, presque tous les programmes d’échecs modernes supportent UCI de sorte que vous pouvez inter-changer l’interface utilisateur et le moteur d’échecs . UCI permet de brancher tous les moteurs d’échecs compatible UCI.

L’API UCIChess apporte la plupart des méthodes permettant de piloter un moteur d’échecs via le protocole UCI.
vous trouverez accompagnant cette API, la documentation des commandes UCI.

Cette API permet de démarrer le moteur d’échec et de dialoguer avec celui ci grâce aux méthodes ci dessous :

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
public class UCIChess {
final public static String UCI="uci";
final public static String GOTHINK="go";
final public static String MOVEFROMSTART="position startpos moves ";
final public static String ISREADY="isready";
final public static String STOP="stop";
final public static String QUIT="quit";
final public static String PONDERHIT="ponderhit";
final public static String UCINEWGAME="ucinewgame";
 
public UCIChess(String engine)
public void stop_Engine()
public final void move_FromFEN(String fen, String moves, boolean trace)
public final void move_FromSTART(String moves,boolean trace)
public void send_ponderhit()
public void send_uciNewGame()
public final void send_uci_cmd(String cmd)
public final boolean get_ReadyOk(boolean trace)
public final boolean get_UciOk(boolean trace)
public String getEngineName()
public String get_EngineAuthor()
public int get_Number_Options()
public OptionName get_Option(int Number)
public boolean send_Option_Name_NoValue(String id)
public boolean send_Option_Name_WithValue(String id, String values)
public void go_Think()
public void go_Think_Nodes(long nodes)
public void go_Think_Mate_In(int mateIn)
public void go_Think_MoveTime(long miliSec)
public void go_Think_Infinite()
public void go_Think_Ponder()
public final String get_BestMove(boolean trace)
public boolean is_opponent_Mated(boolean trace)
public boolean is_engine_Mated(boolean trace)
public String get_Ponder()
public int get_Number_SimpleInfo()
public InfoSimple get_SimpleInfo(int Number)
public int get_Number_DetailedInfo()
public InfoDetailed get_DetailedInfo(int Number)
 
public final class OptionName{
public OptionName(String id, String type, String values)
public String getId()
public String getType()
public String getValues()
}
 
public class InfoDetailed{
public InfoDetailed()
public String getDepth()
public String getSelDepth()
public String getTime()
public String getNodes()
public String getPv()
public String getMultiPV()
public String getScoreCP()
public String getScoreMate()
public String getScoreLowerBound()
public String getScoreUpperBound()
public String getCurrmove()
public String getCurrmoveNumber()
public String getHashfull()
public String getNps()
public String getTbhits()
public String getSbhits()
public String getCpuLoad()
public String getStr()
public String getRefutation()
public String getCurrLine()
}
 
public final class InfoSimple {
public String getInfo()
public InfoSimple(String info)
}
}

Pour une aide sur chacune de ces méthodes, vous trouverez un document au format api java doc, ainsi qu’un fichier texte accompagnant le source de l’api et plusieurs exemples de mise en œuvre dans le dossier testUCIChess.

L’API ChessBoard qui accompagne l’api UCIChess, vous permettra de très facilement gérer les règles du jeu d’échecs et de tester les situations particulière. Cette Api est également accompagné d’un fichier d’aide et d’une documentation java doc et de nombreux exemples de mise en œuvre.


Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
public final class ChessBoard {
public static final String STARTPOSITION="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
public static String moveFromFEN(String startFEN,String move)
public static void show_chessboard()
public static void show_wide_chessboard()
public static boolean square_is_black(int c,int r)
public static String[][] assign_chessboard(String lineFEN)
public static void moveToCoord (String move)
public static String coordToMove(int cFrom, int rFrom, int cTo, int rTo, String promotion)
public static int getRowFrom()
public static int getColFrom()
public static int getRowTo()
public static int getColTo()
public static String getPromote()
public static ArrayList get_list_of_valid_moves(String fen,int colPiece,int rowPiece)
public static boolean square_is_Empty(int c,int r)
public static boolean pieceIsWhite(int c, int r)
public static boolean pieceIsBlack(int c, int r)
public static boolean whiteKingIsThreat(int c,int r)
public static boolean pieceIN(int c,int r,String pieces)
public static boolean blackKingIsThreat(int c,int r)
 
public static class Position{
public int getCol()
public int getRow()
public Position(int col, int row)
}
}

A propos des exemples :

Il vous sera nécessaire de télécharger un moteur de jeu d’échecs, je peut vous conseiller les excellents stockFish version 6 32bits et 64bits ou protector 1.6, ces moteurs sont fournis en openSource avec leur code source, pour les curieux c’est le moments de s’intéresser à cette techno.

Télécharger Stockfish 6


Télécharger Protector 1.6


Vous trouverez l’api UCIChess et ChessBoard sur GitHub à l’adresse suivante https://github.com/tondeur-h/UCIChess

FIN

Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Viadeo Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Twitter Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Google Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Facebook Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Digg Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Delicious Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog MySpace Envoyer le billet « Piloter un moteur de jeu d’échecs avec le protocole UCI, l’API UCIChess » dans le blog Yahoo

Mis à jour 23/05/2016 à 13h50 par kolodz ([Blog]Ajout langage à la balise code)

Catégories
Java , Programmation , 2D / 3D / Jeux

Commentaires