Skip to content

Conversation

@BronsonCarder
Copy link
Owner

No description provided.

incon-sc and others added 21 commits July 28, 2023 23:35
This function allows the length of code to be reduced, by allowing all piece attacks to be queried in the same loop without having to check which function needs to be checked.

For example a loop to check all piece attacks will now look like:
```
for (int square = 0; square < 64; ++square)
{
    for (int piece = 0; piece < 6; ++piece)
    {
        contention[square] += GetPieceAttacks((PieceType)piece, new Square(square), board, isWhiteFriendly);
        contention[square] -= GetPieceAttacks((PieceType)piece, new Square(square), board, !isWhiteFriendly);
    }
}
```

Instead of:
```
for (int square = 0; square < 64; ++square)
{
    for (int piece = 0; piece < 6; ++piece)
    {
        switch ((PieceType)piece)
        {
            PieceType.Pawn => ...,
            PieceType.Knight => ...,
            ...,
            ...,
        }
    }
}
```

This better suits the limits of the challenge by reducing the amount of lexemes required to fetch the same information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants