a XiangQi (Chinese Chess) Engine for XQWizard with Strong AI
Chinese chess game program ElephantEye (Elephant Eye) version: 3.15
Xiangqi Encyclopedia Network* March 2008
(* Email: [email protected])
1. Introduction
ElephantEye is a free Chinese chess program. Under the premise of following the GNU Lesser General Public License, chess enthusiasts and programmers can freely use ElephantEye and its source program.
The Chinese name of ElephantEye is "Elephant Eye", which together with the "horse legs" and "cannon frame" constitute the "third dimension on the chessboard" of Chinese chess. ElephantEye is usually used in conjunction with ElephantBoard, a chess record editing software, which means having a clear plan (Board in English means "board"). (Note: ElephantBoard has now been renamed "Chess Wizard".)
2. Engine Agreement
ElephantEye supports UCCI 3.0. Light Red Xiangqi users can call the ElephantEye engine through the UCCI engine adapter (UCCI2QH).
(1) The supported UCCI commands are:
ucci
setoption...
position {fen <fen_str> | startpos} [moves <move_list>]
banmoves <move_list>
go [ponder | draw] ...
ponderhit [draw] | stop
probe {fen <fen_str> | startpos} [moves <move_list>]
quit
(2) The UCCI information that can be returned is:
id {name <engine_name> | version <version_name> | copyright <copyright_info> | author <author_name> | user <user_name>}
option...
ucciok
info...
{nobestmove | bestmove <best_move> [ponder <ponder_move>] [draw | resign]}
pophash [bestmove <best_move>] [lowerbound <value> depth <depth>] [upperbound <value> depth <depth>]
bye
3. Parameter settings
As a UCCI engine, ElephantEye has several parameters that can be set (can be set directly in <Chess Wizard>).
(1) Starting library:
The default opening library is BOOK.DAT in the current directory of the ElephantEye program (ELEEYE.EXE), which contains 10,000 symmetrical positions.
(2) Thinking time:
Limiting the depth of thinking is usually not a good choice. It is recommended to set a time limit and let the program automatically allocate time. When solving a killing game or analyzing a situation, the program can think without limit and can stop thinking at any time.
(3) Replacement table size:
Although the size of the replacement table has little impact on the running speed of the program, and the default setting of 16MB is sufficient, ElephantEye still provides the function of setting the size of the replacement table. If memory allows, you can appropriately increase the size of the substitution table when playing slow chess, but it is recommended not to exceed half of the physical memory.
(3) Degree of tailoring:
To speed up the program's operations, ElephantEye uses empty clipping by default, and the possibility of negative effects is minimal. Only the lowest level disables blank cropping.
(4) Amount of knowledge:
The amount of knowledge is related to the accuracy of situation evaluation. Among the knowledge levels of ElephantEye, only the lowest level does not use the situation evaluation function (only the value of the sub-power is considered). There is no need to rely on the knowledge of the review to analyze the position, etc. In this situation, you can try this setting.
(5) Randomness:
ElephantEye features 4 levels of randomness. The greater the randomness, the more likely the program will come up with a move that it thinks is not the best move, but "not the best move" is not without any benefits, especially when the opening library is not enabled, appropriately increasing the randomness can avoid The program makes the same move in the same situation.
4. Rules
Starting from version 2.0, ElephantEye not only supports the rule of "unilateral long-term decision to lose", but also supports "long-term decision to lose". "Hit" includes "check" and "catch". Due to limitations in program complexity, only the following three situations are recognized as "catch":
A. Horses and chariots or artillerymen (pawns) with roots;
B. Carts and horse artillerymen (pawns) with roots;
C. Cannon captures chariots or rooted cavalry (pawns).
Although ElephantEye may not be able to correctly identify long moves in complex situations, since it supports the UCCI command banmoves..., once the user thinks that the engine has banned "long moves", they can use the "set ban" function of <Chess Wizard> Let the engine change forcefully.
5. Game Algorithm
ElephantEye is a brute force chess program that uses rigorous and effective game algorithms:
(1) Move generator using bit rows and bit columns:
Bit rows (BitRanks) and bit columns (BitFiles) are conducive to the generation of moves of sliding chess pieces (cars and cannons) (especially capture moves). Bit rows and bit columns can use lookup tables instead of loops on rays. Operation. In ElephantEye, the technology of bit rows and bit columns is not only used in the move generator, but also in the determination of pinning.
(2) Static situation search:
When doing a static search, ElephantEye searched for moves to capture or remove generals. When searching for moves to capture, ElephantEye filtered out unimportant captures, such as pawns that cannot capture the river, or soldiers that capture the bishop that is not on defense. Waiting methods are not within the scope of static search.
(3) Cycle moves and long-range detection:
ElephantEye can identify looping moves. When looping moves occur, it can determine which side is the leader, and will take advantage of the rules prohibiting captains. However, currently ElephantEye cannot identify long grabs.
(4) Replacement table:
ElephantEye refers to the design idea of the Chinese chess program "Running Horses", uses depth-first and always-covered double-layer replacement tables, and adopts a low-out (high-out) boundary correction replacement table update strategy.
(5) Blank cutting with inspection:
ElephantEye uses empty clipping with R=2 and uses checked empty clipping in the endgame stage.
(6) Iterative deepening/child-eating moves/killer moves/history table inspiration:
ElephantEye's move sorting is very simple and clear, followed by iterative deepening moves, good capture moves, killer moves and generative moves sorted by the history table.
(7) The general/sole shall extend:
For selective extensions, ElephantEye uses general and only general extensions.
(8) Alpha-Beta main variant search:
ElephantEye uses traditional recursive Alpha-Beta primary variant search.
(9) Starting library:
ElephantEye's opening library contains a total of 10,000 symmetrical moves, extracted from 8,000 top games in national chess individual competitions, team competitions, Wuyang Cup, leagues and other games from 1990 to 2005.
(10) Backstage thinking and time allocation strategies:
ElephantEye supports background thinking function, and provides two time allocation strategies, period-based and overtime, which will automatically allocate time reasonably.
6. Opening library
ElephantEye's opening library can be produced by the "ElephantEye Opening Library Maker". After running the production tool, you must first select the folder where the PGN game record is located, and then save it as an opening library file (usually BOOK.DAT). Generally, the greater the number of chess records used to generate the opening library, the larger the generated opening library file will be.
In order to make the opening library produced effective for ElephantEye, you only need to replace BOOK.DAT in the ElephantEye directory with the generated opening library file. You can also specify the opening library file in the "Engine Settings" dialog box of <Chess Wizard>.
7. Situation evaluation function library
ElephantEye Starting from version 2.1, the search part and the situation evaluation part of the program have been separated. The search part is coupled with the situation evaluation part by calling API functions.
Other chess programmers can play more freely on the basis of ElephantEye. According to the LGPL agreement, the two parts of search and situation evaluation are treated as independent program libraries. To use any part of it, you only need to disclose the source program of that part. In other words, if the situation evaluation part does not use any open code, then the programmer has no obligation to disclose the source program of this part, and the same is true for the search part.
ElephantEye's situation evaluation API function interface is defined as follows:
A. Situation evaluation engine name: const char *GetEngineName(void);
B. Position pre-evaluation function interface: void PreEvaluate(PositionStruct *lppos, PreEvalStruct *lpPreEval);
C. Position evaluation function interface: int Evaluate(const PositionStruct *lppos, int vlAlpha, int vlBeta);
Among them, PositionStruct and PreEvalStruct must conform to the structures defined in position.h and pregen.h respectively.
8. Source program
The source program of ElephantEye includes 9 modules, the contents are roughly as follows:
(1) ucci.h/ucci.cpp
UCCI command interpretation module, including line input receiving programs under Windows and Unix;
(2) pregen.h/pregen.cpp
Module for generating Zobrist arrays and move preset tables. ElephantEye's preset table is divided into two parts. One is the preset table for sliding chess pieces (including no pieces, rooks, cannons and every other piece). It implements position row and position column technology. The second is the preset table of moves of other chess pieces, which avoids cumbersome boundary judgments when generating moves.
(3) position.h/position.cpp
Mainly describes the data structure and functions of moves and situations. The processing of the situation is the focus of this module. The processing content includes situation initialization, FEN string import, chess piece movement, rationality judgment of the killer's move, general judgment, leader and cycle detection, adjustment of the value of the pieces, etc. It also includes 5 Sub-force position value table.
(4)genmoves.cpp
The move generator includes two types that generate moves that capture pieces and moves that don't capture pieces, but cannot only generate moves that remove generals. While generating the child-eating moves, each move is assigned a corresponding MVV (LVA) (or quasi-SEE) value. This module also has a function that specifically determines whether the chess pieces are protected to calculate the MVV (LVA) value. For protected chess pieces, calculate the MVV-LVA value (not counting if it is less than zero). For unprotected chess pieces, only calculate the MVV. value. Therefore, the program to determine whether a chess piece has a root is also included in this module.
(5) hash.h/hash.cpp
The substitution table, history table and move list management module includes the allocation and access of substitution tables, acquisition of major variations and other operations.
(6) book.h/book.cpp
Opening library reading module.
(7) movesort.h/movesort.cpp
Move list sorting module.
(8) search.h/search.cpp
In addition to the three main processes of static search, complete search and root node search, the search module also includes iterative deepening control, background thinking, time allocation, search parameter statistics and search information output. This module is the core module of the entire program.
(9) eleeye.cpp
Main program (i.e. main function).
(10) preeval.h/preeval.cpp
Sub-power position array pre-generator, ElephantEye linearly adjusts the sub-power position array based on the two parameters of "offensive/defense" and "opening/middle game/end game".
(11) evaluate.cpp
As for the situation evaluation function, ElephantEye adopts a four-level lazy evaluation mechanism. The roughest level only evaluates special chess patterns, a further level evaluates containment, a further level evaluates the flexibility of the rook, and the highest level also evaluates the obstruction of the knight.
9. Program performance
The design of ElephantEye focuses on search algorithms, but it is relatively lacking in knowledge. On a 2.8GHz processor, approximately 1,000,000 nodes can be searched per second (including regular search and static search), and approximately 11 layers can be searched in a typical middle game situation within 1 minute.
In terms of chess power, ElephantEye is at the same level as programs such as "Qiyin" and SaoLa (Chess Challenger). However, due to flaws in the position evaluation function, ElephantEye is far from the top commercial chess software (Xie Master, Xiangqi Family, Xiangqi Qibing, Qi). There is still a certain gap.
ElephantEye has been tested on chess game websites such as Lianzhong and Yitian. Measured by grade points, Lianzhong.com's record is around 2,500 points, Yitian's fast chess record is around 2,000 points, and slow chess is around 1,500 points.
In September 2005, with the help of Mr. Shi Jinshan, a Taiwanese chess software enthusiast, ElephantEye participated in the Chinese chess group competition of the 10th ICGA Computer Olympiad held in Taipei, with a record of 7 wins, 5 losses and 14 losses among 14 programs. Ranked 11th; August 2006 ElephantEye Participated in the first national computer game championship held in Beijing, with a record of 7 wins, 2 losses and 11 losses, ranking 7th among 18 programs.
10. Related resources
The source program of ElephantEye is released in the XiangQi Wizard project of SourceForge, and its page is:
http://sourceforge.net/projects/xqwizard/
The version improvement of ElephantEye is released synchronously in real time on the SourceForge SVN site. The access address is:
https://xqwizard.svn.sourceforge.net/svnroot/xqwizard/
You can use SVN client programs such as TortoiseSVN to obtain the latest code (completely synchronized with developers). The introduction and download address of TortoiseSVN is:
http://sourceforge.net/projects/tortoisesvn/
ElephantEye must be run under a chess program that supports UCCI (such as <Chess Wizard>). The <Chess Wizard> installation program contains the latest version of ElephantEye.
<Chess Wizard> can be downloaded from the following website:
http://www.skycn.com/soft/24665.html (Sky Software Station)
http://www.onlinedown.net/soft/38287.htm (Huajun Software Park)
In addition to the source program of ElephantEye itself, the source program package of ElephantEye also includes the following additional modules:
(1) Base code (base): Provides assembly instructions, system function calls and other functions;
(2) Chinese chess rules module (ccess): provides an interface for other software to use ElephantEye code;
(3) Opening library production module (BOOK): the code to create the opening library BOOK.DAT;
(4) UCCI Engine League Simulator (LEAGUE): Provides an automatic batch match platform for UCCI engine testing and competition;
(5) UCCI Engine Search Tree Analyzer (TREE): a search route analysis tool for UCCI engine (supporting UCCI 2.2+);
(6) XQF chess record tools (XQFTOOLS): Provides tools for converting XQF and other chess records into PGN;
(7) Light Red Chess Adapter (UCCI2QH): Provides an interface for Light Red Chess to call the UCCI engine;
(8) The light red chess engine supports UCCI adapter (QH2UCCI): provides an interface for the "Dream Egg" light red chess to join the UCCI engine test;
(9) BBS Chess (BBSCHESS): A chess position setting tool made with Visual Basic, which can paste colored chess positions on the BBS of various universities;
(10) Chessboard image generator (FEN2BMP): a practical tool that can convert FEN files of chess and Chinese chess into BMP files;
(11) Coding conversion (codec), including Simplified and Traditional transcoding, UNIX text transcoding, Base64 transcoding, etc.;
(12) Other tools (MISC): including simple network communication, pipeline testing and other tools;
(13) Documentation Document (DOC): namely the "Exploration of Chinese Chess Programming" series;
(14) Participating chess records (CCGC): All chess records of ElephantEye participating in the first National Computer Gaming Championship (CCGC).
If you want to get more detailed information about ElephantEye, you can log in to the Xiangqi Encyclopedia website:
http://www.xqbase.com/