Skip to content

Commit

Permalink
🧬 Improve move generation: hardcode castling moves and a few calculat…
Browse files Browse the repository at this point in the history
…ed variables (#541)
  • Loading branch information
eduherminio committed Dec 21, 2023
1 parent 15fadcc commit 8ab4999
Show file tree
Hide file tree
Showing 6 changed files with 546 additions and 193 deletions.
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

0 comments on commit 8ab4999

Please sign in to comment.