You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/AlphaDeepChess/Capitulos/AnalysisOfImprovements.tex
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ \subsection*{Profiler}
31
31
32
32
\noindent Our profiling goal is to identify which parts of the code consume the most execution time. We run the engine under \texttt{perf} using the following commands:
33
33
34
-
\begin{lstlisting}[language=bash, caption={Profiling AlphaDeepChess with perf}, frame=single, breaklines=true]
34
+
\begin{lstlisting}[language=bash, caption={Profiling \textit{AlphaDeepChess} with perf}, frame=single, breaklines=true]
35
35
# Record performance data with function stack traces
36
36
sudo perf record -g ./build/release/AlphaDeepChess
37
37
@@ -54,7 +54,7 @@ \subsection*{Profiler}
54
54
55
55
All of these improvements have been compared with each other using \textit{CuteChess}, and the best version was also evaluated against \textit{Stockfish}. These comparisons were conducted on machines provided by GitHub Actions.
56
56
57
-
\subsection*{Cutechess}
57
+
\subsection*{\textit{Cutechess}}
58
58
59
59
\noindent After considering different options, \textit{Cutechess} proved to be the best fit for our needs.
60
60
@@ -68,7 +68,7 @@ \subsection*{Cutechess}
68
68
69
69
\vspace{1em}
70
70
71
-
\noindent Mainly, this tool is responsible for sending commands to both selected engines. For example, when both Stockfish and our engine implement UCI, \textit{Cutechess} knows in advance the commands to send, as well as parameters such as the search time and depth for each engine, the number of games to play, the time control, or even specific openings to use. Providing specific openings introduces randomization between games, which is beneficial for later evaluation.
71
+
\noindent Mainly, this tool is responsible for sending commands to both selected engines. For example, when both \textit{Stockfish} and our engine implement UCI, \textit{Cutechess} knows in advance the commands to send, as well as parameters such as the search time and depth for each engine, the number of games to play, the time control, or even specific openings to use. Providing specific openings introduces randomization between games, which is beneficial for later evaluation.
\noindent In~\cref{fig:gui}, the engine evaluation is enabled and displays the current evaluation value, the best move found, and the calculated search depth. In this way, we also ensure a more user-friendly experience.
@@ -277,22 +277,22 @@ \subsection*{Analysis}
277
277
278
278
\newpage
279
279
280
-
\section{Evaluation versus stockfish}
280
+
\section{Evaluation versus \textit{Stockfish}}
281
281
282
282
\begin{center}
283
283
\ResultBar{15cm}{0.5cm}{0}{0}{100}
284
284
\medskip
285
285
\end{center}
286
286
287
-
\noindent AlphaDeepChess lost all games against Stockfish. This outcome was expected, as Stockfish has an estimated Elo rating of around 3644~\cite{StockfishElo}, making it orders of magnitude stronger than the best human players. In contrast, as we will show in the next section, AlphaDeepChess plays at a level comparable to a strong human player.
287
+
\noindent\textit{AlphaDeepChess} lost all games against \textit{Stockfish}. This outcome was expected, as \textit{Stockfish} has an estimated Elo rating of around 3644~\cite{StockfishElo}, making it orders of magnitude stronger than the best human players. In contrast, as we will show in the next section, \textit{AlphaDeepChess} plays at a level comparable to a strong human player.
288
288
289
289
\section{Engine final evaluation}
290
290
291
291
\noindent Figure~\cref{fig:eloDistribution} shows the Elo rating distribution of players on Lichess, where the median rating is approximately 1500.
292
292
293
293
\vspace{1em}
294
294
295
-
\noindent AlphaDeepChess has achieved a rating of 1900 on Lichess~\cite{AlphaDeepChessElo}, placing it well above the median and within the top percentiles of the player base. For comparison, the highest-rated human player on the platform has reached 3000 Elo in 2025~\cite{LichessBestPlayer}.
295
+
\noindent\textit{AlphaDeepChess} has achieved a rating of 1900 on Lichess~\cite{AlphaDeepChessElo}, placing it well above the median and within the top percentiles of the player base. For comparison, the highest-rated human player on the platform has reached 3000 Elo in 2025~\cite{LichessBestPlayer}.
The following section details the individual contributions made by each team member, Juan and Yi, throughout the development of the AlphaDeepChess project. Each contribution is listed to provide transparency regarding the division of work, highlight specific areas of responsibility, and acknowledge the expertise and effort invested by each author.
3
+
The following section details the individual contributions made by each team member, Juan and Yi, throughout the development of the \textit{AlphaDeepChess} project. Each contribution is listed to provide transparency regarding the division of work, highlight specific areas of responsibility, and acknowledge the expertise and effort invested by each author.
\noindent A list of twelve bitboards is used, one for each type of chess piece.~\cref{fig:bitboardPositionExample} illustrates this concept with a chess position example.
31
31
32
+
\vspace{1em}
33
+
32
34
\begin{figure}
33
35
\centering
34
36
\newchessgame
@@ -87,7 +89,7 @@ \subsection*{Game state}
87
89
88
90
\begin{enumerate}
89
91
\item Total number of moves played in the game (bit 0-19).
90
-
\item En passant target square (if applicable) (bits 20-26).
\noindent The following events happen at each node of the tree:
114
116
115
117
\begin{enumerate}
116
-
\item Terminal node verification: Check for game termination conditions including checkmate, threefold repetition, the fifty-move rule, or reaching maximum search depth.
117
-
\item Position evaluation: A positive value indicates White's advantage, while a negative value favors Black. We establish 3,200,000 as the mate-in-one threshold value.
118
-
\item Legal move generation: create a list of every possible legal move in the position.
119
-
\item Move ordering: Sort moves by estimated quality (best to worst). The sooner we explore the best move, the more branches of the tree will be pruned.
120
-
\item Move exploration: Iterate through each of the legal moves from the position in order, update the position evaluation, the value of alpha and beta, and performing pruning when possible.
118
+
\item\textit{Terminal node verification}: Check for game termination conditions including checkmate, threefold repetition, the fifty-move rule, or reaching maximum search depth.
119
+
\item\text{Position evaluation}: A positive value indicates white's advantage, while a negative value favors black. We establish $3,200,000$ as the mate-in-one threshold value. The value is $3,200,000$ because it is much larger than any possible material or positional evaluation, ensuring that a checkmate is always prioritized over any other advantage.
120
+
\item\textit{Legal move generation}: create a list of every possible legal move in the position.
121
+
\item\textit{Move ordering}: Sort moves by estimated quality (best to worst). The sooner we explore the best move, the more branches of the tree will be pruned.
122
+
\item\textit{Move exploration}: Iterate through each of the legal moves from the position in order, update the position evaluation, the value of alpha and beta, and performing pruning when possible.
@@ -469,7 +471,7 @@ \subsection*{Bitboard of danger squares}
469
471
470
472
\vspace{1em}
471
473
472
-
\noindent However, sliding pieces as rooks, bishops, and queens require additional handling. Their attacks depend on the presence of blockers in their movement paths.~\cref{fig:blockerExample} shows an example where the attacks of sliding pieces are limited due to blocking pawns.
474
+
\noindent However, sliding pieces as rooks, bishops, and queens require additional handling. Their attacks depend on the presence of blockers in their movement paths.~\cref{fig:blockerExample} shows an example where the attacks of sliding pieces are limited due to blocking pawns. In this case, the rook sliding attack is being blocked by the pawns.
473
475
474
476
\vspace{1em}
475
477
@@ -491,10 +493,6 @@ \subsection*{Bitboard of danger squares}
491
493
492
494
\end{figure}
493
495
494
-
\noindent In~\cref{fig:blockerExample}, the rook sliding attack is being blocked by the pawns.
495
-
496
-
\vspace{1em}
497
-
498
496
\noindent Currently, calculating legal attacks for sliding pieces involves iterating along orthogonal and diagonal directions until a blocking piece is encountered. This approach is relatively inefficient. In subsequent sections, we present optimization techniques that address this issue.
\item\textit{Double check}: If there are two or more checkers, the only legal option is to move the king to a square that is not under attack, outside the danger bitboard. No other piece can legally move in this case.
566
564
\item\textit{No check}: In the absence of any checks, we iterate through all the pieces belonging to the side to move and generate their legal moves. If a piece is pinned (inside pinned piece bitboard), its movement is constrained to the direction of the pin.
567
-
\item\textit{Single check}: If exactly one checker is present, we again iterate over all pieces, but the only moves available are to capture the checker (captures inside the capture mask) or to block the check (moves inside the push mask).
565
+
\item\textit{Single check}: If exactly one checker is present, we again iterate over all pieces. The moves available are to capture the checker (captures inside the capture mask), to block the check (moves inside the push mask), or to move the king to a legal square.
568
566
\end{itemize}
569
567
570
568
\noindent Finally, the special moves of castling and \textit{en passant} are handled explicitly by looking for the castling rights and the \textit{en passant} target square in the game state.
@@ -575,11 +573,11 @@ \subsection*{Testing the move generator: perft test}
575
573
576
574
\vspace{1em}
577
575
578
-
\noindent Perft is a debugging function in which we generate the entire game tree for a specific position up to a given depth and count all the resulting nodes. We can then compare our results with those of other engines, such as Stockfish. Since Stockfish is widely regarded as highly accurate, it serves as a reliable reference for validating move generation.
576
+
\noindent Perft is a debugging function in which we generate the entire game tree for a specific position up to a given depth and count all the resulting nodes. We can then compare our results with those of other engines, such as \textit{Stockfish}. Since \textit{Stockfish} is widely regarded as highly accurate, it serves as a reliable reference for validating move generation.
579
577
580
578
\vspace{1em}
581
579
582
-
\noindent In~\cref{tab:perftResults}, we present our Perft results alongside those of Stockfish for seven well-known test positions at depth 6. The identical node counts in all cases confirm the correctness of our move generator.
580
+
\noindent In~\cref{tab:perftResults}, we present our Perft results alongside those of \textit{Stockfish} for seven well-known test positions at depth 6. The identical node counts in all cases confirm the correctness of our move generator.
583
581
584
582
\begin{table}
585
583
\centering
@@ -596,7 +594,7 @@ \subsection*{Testing the move generator: perft test}
596
594
\texttt{FEN START POS} & 119060324 & 119060324 \\
597
595
\hline
598
596
\end{tabular}
599
-
\caption{Perft results at depth 6: comparison between Stockfish and AlphaDeepChess~\cite{PerftResults}.}\label{tab:perftResults}
597
+
\caption{Perft results at depth 6: comparison between \textit{Stockfish} and \textit{AlphaDeepChess}~\cite{PerftResults}.}\label{tab:perftResults}
600
598
\end{table}
601
599
602
600
\section{Move ordering}
@@ -613,26 +611,30 @@ \section{Move ordering}
613
611
614
612
\subsection*{Most valuable victim - least valuable aggressor}
615
613
616
-
The heuristic we implemented is the Most Valuable Victim - Least Valuable Aggressor (MVV-LVA). In this approach, a move receives a high score if it captures a valuable piece using a less valuable one. For example, capturing a queen with a pawn is considered a very strong move~\cite{MVVLVA}.
614
+
The heuristic we implemented is the \textit{Most Valuable Victim - Least Valuable Aggressor (MVV-LVA)}. In this approach, a move receives a high score if it captures a valuable piece using a less valuable one. For example, capturing a queen with a pawn is considered a very strong move~\cite{MVVLVA}.
617
615
618
616
\vspace{1em}
619
617
620
618
\noindent We implemented this heuristic using a look-up table indexed by the moving piece and the captured piece, as shown in~\cref{tab:mvv-lva-table}. Capturing a queen with a pawn receives a score of 55, while doing the opposite receives 11 points.
\noindent In~\cref{fig:killer_move_example}, the queen moves to h5, threatening checkmate on f7. This quiet move prunes all other moves that do not respond to the threat.
670
672
673
+
\vspace{1em}
674
+
671
675
\noindent These moves are remembered and prioritized during move ordering, as they have proven effective in position at the same depth in the search tree. We implemented a table where we store two moves that causes a cutoff per search depth. There could be more than two killer moves, our replacement policy is to always maintain the older killer move found in one slot, and in the other slot store the least recently found.
672
676
673
677
\vspace{1em}
674
678
675
-
\noindent If a quiet move being evaluated matches one of the killer moves stored at the current search depth, we increase its score by 70 points.
679
+
\noindent If a quiet move being evaluated matches one of the killer moves stored at the current search depth, we increase its score by 70 points. The value 70 is chosen empirically to ensure that killer moves are prioritized above most quiet moves, but still allow the most valuable captures (according to the MVV-LVA heuristic) to take precedence when appropriate. This balance helps improve pruning efficiency without overlooking critical tactical opportunities.
0 commit comments