-
Notifications
You must be signed in to change notification settings - Fork 3
Trace
In the modern era of chess engines, where neural networks often function as inscrutable "black boxes," Alexander takes a distinctive philosophical stand. Derived from a classical version of Stockfish, Alexander employs a handcrafted evaluation function (HCE). Its true innovation, however, lies in the Evaluation Trace, accessible via the eval UCI command. This feature is the embodiment of the "glass box" philosophy: it does not just provide a final score, but presents a complete, hierarchical, and human-readable breakdown of its own strategic reasoning.
This document serves as the definitive technical guide to Alexander's Evaluation Trace. It will describe its syntax, rigorously define the semantics of each reported metric, and, most importantly, demonstrate its unparalleled utility for a chess player seeking not just the best move, but a deep, transferable understanding of the position.
The primary use-case for a player is differential analysis: by comparing the trace of a position before and after a candidate move, the player can see precisely how that move alters each strategic element (e.g., "This move improved my pawn structure but weakened my king safety"). This transforms the engine from a simple oracle into a powerful, interactive learning tool and analytical assistant.
The trace is generated by sending the eval command to the Alexander engine when a position is set. The output is a plain-text, structured report designed for readability. Its top-level structure is as follows:
text
=== GENERAL INFORMATION ===
Final evaluation: <score> (Win Probability: <X>%)
Shashin Zone: <zone>
Game Phase: <phase>
ELEMENT | MG EG Total
-------------+--------------------
<term_name> | <mg> <eg> <total> |
=== <ELEMENT> SUBELEMENTS ===
... (detailed analysis for Material, Pawns, Knights, etc.) ...
FINAL SUMMARY
Unit Ranking by static activity (Makogonov Principle) - Worst to Best:
White: <list_of_pieces_with_scores>
Black: <list_of_pieces_with_scores>
Legal moves sorted by static activity (Win Probability / CentiPawns: Best to Worst):
Moves: <move1>(X%/Y), <move2>(X%/Y), ...
The report is divided into four main sections:
- General Information: Provides a high-level overview of the position.
- Summary Table: A concise, tabular view of the main evaluation terms (Material, Mobility, King Safety, etc.) with their Middlegame (MG), Endgame (EG), and interpolated Total values.
- Sub-Element Analysis: The core of the trace. This section expands on each major term, providing the detailed, low-level metrics that comprise the scores seen in the summary table. These sub-elements are often only displayed when relevant (e.g., Dvoretsky's Rule analysis only appears in an opposite-colored bishop endgame).
- Final Summary: A synthesis of the position's dynamics, including the Makogonov ranking of piece activity and a list of all legal moves sorted by their immediate tactical and strategic promise.
This section defines the precise meaning of every key metric within the trace, explaining how it is calculated and its strategic significance.
- Final evaluation (to_cp): The engine's overall assessment of the position from White's perspective, expressed in centipawns (1/100th of a pawn). A positive value favors White, a negative value favors Black.
- Win Probability: A percentage (0-100) representing the likelihood of a win for the side to move, based on the engine's internal WDL (Win-Draw-Loss) model. It factors in both the evaluation and the game phase, providing a more intuitive measure of advantage.
-
Shashin Zone: A dynamic classification of the position based on the Win Probability, derived from the theories of Alexander Shashin. This is the cornerstone of Alexander's adaptive understanding. The zones are:
- Tal Zones (High/Middle/Low Tal): Winning or attacking positions. The engine prioritizes initiative, tactical opportunities, and king safety.
- Capablanca Zone: Balanced, strategic positions. The engine emphasizes long-term structural and spatial advantages.
- Petrosian Zones (High/Middle/Low Petrosian): Losing or defensive positions. The engine prioritizes solidification, prophylaxis, and counter-attack potential.
- Chaos Zones (Capablanca-Tal, Capablanca-Petrosian): Mixed zones where the engine balances dynamic and static considerations.
- Game Phase: A textual description of the phase (Opening, Middlegame, Transition to endgame, Endgame) derived from the material on the board. This context is crucial for interpreting the MG vs. EG values in the summary table.
This table presents the interpolated score for the main evaluation terms. For each term, three numbers are shown:
- MG (Middlegame): The contribution of this term in a full middlegame. King safety, for example, is heavily weighted here.
- EG (Endgame): The contribution of this term in a pure endgame. Passed pawns and king activity become much more significant here.
- Total: The current, phase-adjusted value of the term. This is the number that directly contributes to the final evaluation.
The primary terms are:
- Material: The raw material count (e.g., Queen = 9, Rook = 5) plus bonuses for combinations like the bishop pair.
- Imbalances: A score adjustment for specific material configurations (e.g., Rook vs. Knight + Pawn) that are not accurately reflected by simple piece values.
- Mobility: A measure of piece activity based on the number of squares each piece can safely move to.
- King Safety: A complex score reflecting the vulnerability of each king, considering the pawn shield, attacking enemy pieces, and potential checks.
- Threats: A bonus for attacking enemy pieces, particularly those that are undefended or poorly defended.
- Passed Pawns: A bonus for pawns with no opposing pawns on their path to promotion.
- Space: A bonus for controlling empty squares on the opponent's side of the board, typically in the center.
This section provides the granular data that forms the foundation of the summary scores.
-
Material Sub-Elements:
- Bishop Pair: Explicitly states if one or both sides possess the bishop pair and lists the advantages (control of both color complexes, enhanced mobility). This term is a component of the overall Material score.
-
Pawns Sub-Elements:
- Pawn Islands: Counts and lists the "islands" of pawns. Fewer islands generally indicate a healthier, less vulnerable structure.
-
Doubled, Isolated, Backward, Hanging Pawns: Identifies specific pawn weaknesses. For each, the trace lists the squares of these pawns. The definitions are rigorous:
- Doubled: Two pawns of the same color on the same file.
- Isolated: A pawn with no friendly pawns on adjacent files.
- Backward: A pawn on a semi-open file that cannot be safely advanced and is not defended by another pawn.
- Hanging: A pair of pawns on adjacent files with no friendly pawns on the files immediately to their left or right.
- Weak Squares: Identifies squares that are not defended by a player's own pawns, making them potential outposts for the opponent.
- Center Type Analysis: A powerful diagnostic tool that classifies the center as Open, Closed, Static, Mobile, or Dynamic. Each classification comes with a pre-defined set of strategic characteristics and recommendations, directly linking the engine's evaluation to classical chess theory.
-
Knights Sub-Elements:
-
Packing Density (Shashin Theory): A novel metric calculated as the number of short-range pieces (Knights, Pawns, King) divided by the area of the rectangle that bounds them.
- deltak = white_density - black_density. A high density suggests a closed, secure position where knights thrive. A low density suggests an open, airy position.
- The trace provides a recommendation based on the deltak and the current Shashin Zone, guiding the player on whether to seek or avoid exchanges.
-
Packing Density (Shashin Theory): A novel metric calculated as the number of short-range pieces (Knights, Pawns, King) divided by the area of the rectangle that bounds them.
-
Bishops Sub-Elements:
-
Dvoretsky's Rule for Opposite-Colored Bishops: When an opposite-colored bishop endgame is detected, the engine applies Dvoretsky's principle.
- It identifies the weaker side (based on evaluation).
- It analyzes the color of their bishop and the color of their pawns.
- It issues a clear WARNING if pawns are on the opposite color of their bishop (a violation of Dvoretsky's rule) and recommends trading them or moving them to the correct color. This is a classic example of the engine diagnosing a human-understandable strategic error.
-
Dvoretsky's Rule for Opposite-Colored Bishops: When an opposite-colored bishop endgame is detected, the engine applies Dvoretsky's principle.
-
Major Pieces (Rooks & Queens) Sub-Elements:
- Open & Semi-Open Files: Lists all files on the board, classifying them as Open (no pawns), Semi-open for White (no white pawns, at least one black pawn), and Semi-open for Black.
- Open & Semi-Open Diagonals: Performs the same classification for all major diagonals (A1-H8 and H1-A8 direction). This helps guide bishop and queen placement.
-
Mobility Sub-Elements:
- Mobility by Area (Kasparov Principle): Breaks down piece mobility into three zones: Queen Side, Center, and King Side.
- The trace calculates the total mobility for each side in each area and presents the differences.
- It then applies the Kasparov Principle: it identifies the stronger side and advises them to attack on the side where they have more mobility (e.g., "White has the initiative. Kasparov Principle: try to attack on the king side;"). Simultaneously, it advises the weaker side on the best area for a counterattack.
-
Space Sub-Elements:
- Space Detail by Area: Quantifies the space advantage by calculating "safe" squares behind the pawns in each area (Queen side, Center, King side) and presents them in a clear tabular format (White, Black, Difference).
- Expansion Factor (Shashin Theory): Calculates the "center of gravity" for each side's pieces-the average rank of all their pieces. The delta_expansion shows which side has advanced further into enemy territory. In "Capablanca" zones, it provides specific expansion recommendations (e.g., "Advance pawns to gain space," "Restrict opponent's piece mobility").
-
Makogonov Unit Ranking: This is a unique and powerful feature. It ranks every piece on the board (excluding kings) by a "static activity score." This score is based on factors like mobility, outpost placement, proximity to the enemy king, and pawn support.
- The ranking is presented from Worst to Best for each color.
- It concludes with a clear directive: "Makogonov White: Improve [Piece Type] on [Square] (activity: [score])". This gives the player a concrete, actionable goal for their next few moves: activate their worst piece.
-
Ordered Legal Moves List: This is another transformative feature. It generates a list of all legal moves in the position, sorted not by the result of a deep search, but by a "static activity score" derived from a 1-ply evaluation of the resulting position.
- For each move, it shows the move itself, the resulting Win Probability (%) , and the resulting Activity Score (cp) .
- The list is sorted from best to worst based on these metrics.
- Use Case: This allows a player to instantly survey all plausible moves and understand their immediate impact. A move that jumps to the top of the list is one that creates an immediate, statically verifiable threat or improvement. A move that falls significantly is one that blunders away an advantage or makes a positional concession. Comparing the activity score of a candidate move to the current evaluation is a form of zero-cost blunder checking.
The true power of Alexander's trace is unlocked through differential analysis. This is the process of comparing the full trace of the current position with the trace of a position after a candidate move. This allows a player to understand, in granular detail, the strategic consequences of a single move.
Workflow for Differential Analysis:
- Set the position in your UCI-compatible GUI.
- Run the eval command. Copy the entire trace output and paste it into a text editor or note-taking app.
- Play your candidate move on the board.
- Run the eval command again. Now, compare the new trace with the one you saved.
What to look for:
- In the Summary Table: Did the "Mobility" score go up or down? Did "King Safety" improve or deteriorate? A move that gains a pawn but makes your king a target will show a clear trade-off: Material increases, King Safety decreases.
- In the Pawns Sub-Elements: Did your pawn structure worsen? Did you create a new "isolated" or "backward" pawn for yourself? Or did you successfully trade off a weakness, making it disappear from the list?
- In the Knights/Bishops Sub-Elements: For a knight move, did your Packing Density (deltak) change favorably for the Shashin Zone? Did a bishop move successfully activate, increasing its mobility score?
- In the Makogonov Ranking: Did your worst piece improve its rank? Or did your move, by improving one piece, cause another to become the new worst piece?
- In the Legal Moves List: Compare the current position's list to the new position's list. Does the new list show a new, powerful threat for your opponent? If so, you know the move you just considered is likely bad.
Example: The Pin and the Pawn Break
Imagine a position where you are considering two moves: 1. Nf5 and 1. d5.
-
After analyzing 1. Nf5, you compare the traces. The new trace shows:
- Mobility: Slightly decreased for your knight (it moved to a more restricted square).
- King Safety: Unchanged.
- Threats: Significantly increased! The trace shows a new "ThreatByMinor" entry against the enemy queen, indicating the knight has created a pin.
- Makogonov Ranking: The knight is no longer your worst piece.
-
After analyzing 1. d5, the new trace shows:
- Pawns Sub-Elements: A new "passed pawn" appears for you! The analyze_passed_pawns sub-section shows it's supported and free.
- Space: Your space advantage in the center has increased.
- Mobility: Enemy piece mobility has decreased because their pawns are now blocked.
This analysis provides a concrete, chess-language rationale for why Nf5 is a tactical shot and d5 is a strong positional move, far beyond what a simple centipawn loss or gain can convey.
Alexander's Evaluation Trace is more than just a debugging tool; it is a fundamental re-imagining of the human-computer interface in chess. By adhering to a "glass box" design, it successfully bridges the gap between superhuman computational power and human strategic understanding.
For the first time, players have access to an engine that can explain why a move is good, how a plan changes the position, and what the worst piece on the board is. Through differential analysis, the engine becomes a collaborative partner in the learning process, transforming abstract numbers into concrete, actionable chess lessons. Alexander does not just provide the answer; it teaches the method.