Changes

Jump to: navigation, search

Hiding the Implementation

2,033 bytes added, 16:49, 18 May 2018
Created page with "'''Home * Board Representation * Bitboards * Sliding Piece Attacks * Hiding the Implementation''' None rotated approaches as mentioned in * Classi..."
'''[[Main Page|Home]] * [[Board Representation]] * [[Bitboards]] * [[Sliding Piece Attacks]] * Hiding the Implementation'''

None rotated approaches as mentioned in
* [[Classical Approach#Wrapper|Classical Approach]]
* [[First Rank Attacks#AttacksOnAllRanks|Rank Attacks]]
* [[Hyperbola Quintessence]]
* [[Obstruction Difference]]
* [[Kindergarten Bitboards]]
* [[Magic Bitboards]]
* [[The Switch Approach]]
* [[SIMD Techniques]]

can hide the implementation details behind a stateless interface:
<pre>
U64 diagonalAttacks(U64 occ, enumSquare sq);
U64 antiDiagAttacks(U64 occ, enumSquare sq);
U64 fileAttacks (U64 occ, enumSquare sq);
U64 rankAttacks (U64 occ, enumSquare sq);

U64 rookAttacks (U64 occ, enumSquare sq);
U64 bishopAttacks (U64 occ, enumSquare sq);

U64 queenAttacks (U64 occ, enumSquare sq);
</pre>

In [[C]] / [[Cpp|C++]] one may use [https://en.wikipedia.org/wiki/Header_file header files] with exclusive, conditional compiled inlined routines, as combinations and variations of the mentioned approaches. Initialization should be implemented by conditional compile switches in various implementation files (c, cpp). Favorite should be '''bishopAttack''' by [[Magic Bitboards|magic bitboards]] due to the relative small table less than 38KByte, while magic '''rookattacks''' takes more than 20 times the space so far.

As always with [[Space-Time Tradeoff|space-time tradeoff]] - it depends on the cache- and [[Memory|memory]] using and [https://en.wikipedia.org/wiki/Memory_footprint footprint] of a individual chess program - on a particular hardware architecture - which solution is preferable and faster. [[Perft]] frameworks likely prefer larger tables but less computation. So far L1 [https://en.wikipedia.org/wiki/Cache Cache] is a rare resource, [https://en.wikipedia.org/wiki/Translation_Lookaside_Buffer Translation Lookaside Buffer] als well.

=External Links=
* [https://en.wikipedia.org/wiki/Information_hiding Information hiding from Wikipedia]

'''[[Sliding Piece Attacks|Up one Level]]'''

Navigation menu