Fairy Stockfish

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Fairy Stockfish

Post by xr_a_y »

https://github.com/ianfab/Fairy-Stockfish

How does this work ? In evaluation, pst, material, bitboard, movegen, I see nothing obvious about board side, or pieces dropped on the board. Is there some explanation somewhere ?
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Fairy Stockfish

Post by xr_a_y »

ah got it !

Code: Select all

#ifdef LARGEBOARDS
#if defined(__GNUC__) && defined(IS_64BIT)
typedef unsigned __int128 Bitboard;
#else
struct Bitboard {
    uint64_t b64[2];
    // ...
Fabian Fichter
Posts: 50
Joined: Mon Dec 12, 2016 2:14 pm

Re: Fairy Stockfish

Post by Fabian Fichter »

As you already found out, I use bitboards with 128 bit for the large-board version that supports board sizes up to 12x10, and 8 bit remain unused. For variants that use smaller boards than the bitboard size of the respective version (128bit/64bit), a bitboard containing the actual squares of the board is &-ed to bitboards for move generation, attacks, etc.

Your question actually reminds me that it might a good idea to add a page to the wiki https://github.com/ianfab/Fairy-Stockfish/wiki to describe the engine from a more technical viewpoint, so that people who are more interested in those aspects or who would like to contribute can get an overview of the design of the engine.

As a very quick overview, if you want to find the code related to a certain rule/feature of a variant, you can start in variant.cpp where the rules of the variants are defined and then check position.h (which also wraps the access to those variant attributes), position.cpp, and movegen.cpp for usages of the respective attributes, because they basically contain all of the code related to variant rules. Bitboard.h/.cpp contain some code relevant for magic bitboards for fairy pieces and on the 12x10 board.

Leaving the variants themselves out of the core parts of the code and rather making individual rules/features of a game the central aspects of the engine was the fundamental design decision. In this way variants are just data (as a set of rules) and can easily be added as long as the individual rules of the variant (board size, piece types, move mechanisms, etc.) are already supported.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Fairy Stockfish

Post by xr_a_y »

Thanks for your answer !
Fabian Fichter
Posts: 50
Joined: Mon Dec 12, 2016 2:14 pm

Re: Fairy Stockfish

Post by Fabian Fichter »

I just put together a first version of the introduction to the code base, see https://github.com/ianfab/Fairy-Stockfi ... g-the-code.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Fairy Stockfish

Post by xr_a_y »

Fabian Fichter wrote: Fri Apr 03, 2020 1:06 pm I just put together a first version of the introduction to the code base, see https://github.com/ianfab/Fairy-Stockfi ... g-the-code.
great !