The only thing that bugs me (pun intended!) is code. It is ugly. It is bloated. It basically looks like a copy-paste of a flow chart diagram - a decision tree that works right now, but may quickly become unmanageable. Below I show one section, two chains and 4 bonuses only. sd is side for which we evaluate, op is the other side, RelSqBb returns a bitboard of a single square relative for the side (i.e. D4,BLACK -> D5).

Code: Select all

```
if (RelSqBb(E4, sd) & bbPc(p, op, P)) {
if (RelSqBb(D5, sd) & bbPc(p, op, P) // c6-d5-e4 triad
&& RelSqBb(C6, sd) & bbPc(p, op, P)) {
if (RelSqBb(D4, sd) & bbPc(p, sd, P)
&& RelSqBb(E3, sd) & bbPc(p, sd, P))
mgResult -= bigChainScore;
else
mgResult -= smallChainScore;
}
if (RelSqBb(F3, sd) & bbPc(p, op, P) // d5-e4-f3 triad
&& RelSqBb(D5, sd) & bbPc(p, op, P)) {
if (RelSqBb(E3, sd) & bbPc(p, sd, P))
mgResult -= bigChainScore;
else
mgResult -= smallChainScore;
}
}
```