Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃К Improve move generation: hardcode castling moves and a few calculated variables #541

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Lynx.Dev/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,12 @@ static void _23_Castling_Moves()
var position = new Position("rn2k2r/pppppppp/8/8/8/8/PPPPPPPP/RN2K2R w KQkq - 0 1");
position.Print();

var moves = MoveGenerator.GenerateCastlingMovesForReference(position, Utils.PieceOffset(position.Side)).ToList();
int index = 0;
var moves = new Move[Constants.MaxNumberOfPossibleMovesInAPosition];

foreach (var move in moves)
MoveGenerator.GenerateCastlingMoves(ref index, moves, position);

foreach (var move in moves[..index])
{
Console.WriteLine(move);
}
Expand Down Expand Up @@ -689,7 +692,7 @@ static void ZobristTable()
var pos = new Position(KillerPosition);
var zobristTable = InitializeZobristTable();
var hash = CalculatePositionHash(zobristTable, pos);
var updatedHash = UpdatePositionHash(zobristTable, hash, MoveGenerator.GenerateAllMoves(pos).First());
var updatedHash = UpdatePositionHash(zobristTable, hash, MoveGenerator.GenerateAllMoves(pos)[0]);

Console.WriteLine(updatedHash);
}
Expand Down Expand Up @@ -1098,7 +1101,6 @@ static void TestMoveGen(string fen)
Console.WriteLine($"Position\t{newPosition.FEN()}, Zobrist key {newPosition.UniqueIdentifier}");
Console.WriteLine($"Position\t{position.FEN()}, Zobrist key {position.UniqueIdentifier}");


Console.WriteLine($"Unmaking {move.ToEPDString()} in\t{position.FEN()}");

//position.UnmakeMove(move, savedState);
Expand Down