Winglet

From Chessprogramming wiki
Jump to: navigation, search

Home * Engines * Winglet

Winglet [1]

Winglet,
a didactic open source chess engine by Stef Luijten, written in C++ and licensed under the GNU General Public License. The development of Winglet was documented on the website tutorial Winglet, Writing a Chess Program in 99 Steps, started in 2011, now hosted by the Wayback Machine [2]. Winglet is intended as bitboard version of TSCP with WinBoard support [3], and is loosely derived from Wing, Stef Luijten's former private engine [4], in the meantime also open source [5].

Description

Board Representation

Winglet applies a mixture of Kindergarten Bitboards and Magic Bitboards [6] to determine sliding piece attacks with 32 KiB precalculated lookup tables[64][64] each on ranks, files, diagonals and anti-diagonals, indexed by square and hashed line occupancy - the inner six bits multiplied by a magic factor and shifted right by the strange looking 57, while 58 is more natural to ensure a six bit index range, using a constant factor (b-File) for all squares of a diagonal or anti-diagonal, ...

U64 arrDiagonalAttacks[64][64]] /* requires initialization */

U64 diagonalKindergartenAttacks(U64 occ, enumSquare sq) {
   occ = (diagonalMaskEx[sq] & occ) * C64(0x0202020202020202) >> 58;
   return arrDiagonalAttacks[sq][occ];
}

... but "magic" Winglet factors are designed such that the most significant bit of the 64-bit product will always be clear, that is positive if interpreted as signed 64-bit integer. It seems, Winglet's occupied index calculations emulate Wing's rotated bitboard indices for same attack table layout:

/*                 Winglet's occupancy state             ==            Wing's occupancy state */
(occ & MG_DIAGA8H1MASK[sq]) * MG_DIAGA8H1MAGIC[sq] >> 57 == (occ045 >> DIAGA8H1_ATTACK_SHIFT[sq]) & 63
(occ & MG_DIAGA1H8MASK[sq]) * MG_DIAGA1H8MAGIC[sq] >> 57 == (occ315 >> DIAGA1H8_ATTACK_SHIFT[sq]) & 63
(occ & MG_FILEMASK[sq])     * MG_FILEMAGIC[sq])    >> 57 == (occ090 >> FILE_ATTACK_SHIFT[sq])     & 63

Search

Evaluation

Passed Pawn
Backward Pawn
Doubled Pawn
Isolated Pawn
Pawn Shield
King Tropism

See also

Forum Posts

External Links

Chess Engine

Tutorial Archive

01 Introduction - 05 First steps with Visual Studio C++
06 Reading user commands
07 Internal representation of the chess board - bitboards » Board Representation, Bitboards
08 Displaying the position » Chess Position
09 Reading a FEN string » Forsyth-Edwards Notation
10 Setting up the board manually
11 The move generator » Move Generation
12 Making the moves » Make Move
13 The evaluation function » Evaluation
14 Search » Search, Minimax, Alpha-Beta, PVS
15 Mate and draw detection » Checkmate, Stalemate
16 Repetition detection - Zobrist keys » Repetitions, Zobrist Keys
17 Iterative deepening and move ordering » Iterative Deepening, Move Ordering
18 Quiescence search and SEE » Quiescence Search, MVV-LVA, SEE
19 Null move pruning » Null Move Pruning
20 Time control and running test suites » Time Management
21 Connecting to Winboard » CECP, WinBoard

Misc

References

Up one Level