...
public PawnSquareDirectionMovesBuilder(IMoveFactory mvFactory, ISquares<ISquareMoveGen> boardSquares)
{
MVFactory = mvFactory;
BoardSquares = boardSquares;
}
public IImmutableList<IMoveBase> BuildPawnSquareDirectionMoves(
ICoord coord, IPieceColor color,PawnDirection dir)
{
var lastRow = color == White() ? LASTROW : 0;
var square = BoardSquares[coord];
int rowNr = square.RowNr;
if (rowNr == 0 || rowNr == lastRow)
return null;
switch (dir)
{
case LEFT:
case RIGHT:
return BuildNonEPCaptures(color, square, dir);
case EP_LEFT:
case EP_RIGHT:
return BuildEPCaptures(color, square, dir);
case FRONT:
return BuildPawnFrontMoves(color, square);
default:
return null;
}
}
...
Might as well have used ISquares<ISquare> BoardSquares. But strangely C# does not see that ISquares<ISquareMoveGen> is an ISquares<ISquare> while my code contains public interface ISquareMoveGen: ISquare
...
public PawnSquareDirectionMovesBuilder(IMoveFactory mvFactory, ISquares<ISquareMoveGen> boardSquares)
{
MVFactory = mvFactory;
BoardSquares = boardSquares;
}
public IImmutableList<IMoveBase> BuildPawnSquareDirectionMoves(
ICoord coord, IPieceColor color,PawnDirection dir)
{
var lastRow = color == White() ? LASTROW : 0;
var square = BoardSquares[coord];
int rowNr = square.RowNr;
if (rowNr == 0 || rowNr == lastRow)
return null;
switch (dir)
{
case LEFT:
case RIGHT:
return BuildNonEPCaptures(color, square, dir);
case EP_LEFT:
case EP_RIGHT:
return BuildEPCaptures(color, square, dir);
case FRONT:
return BuildPawnFrontMoves(color, square);
default:
return null;
}
}
...
Might as well have used ISquares<ISquare> BoardSquares. But strangely C# does not see that ISquares<ISquareMoveGen> is an ISquares<ISquare> while my code contains public interface ISquareMoveGen: ISquare
C<Derived> is not automatically a derived class of C<Base>. That is not specific for C#.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
...
public PawnSquareDirectionMovesBuilder(IMoveFactory mvFactory, ISquares<ISquareMoveGen> boardSquares)
{
MVFactory = mvFactory;
BoardSquares = boardSquares;
}
public IImmutableList<IMoveBase> BuildPawnSquareDirectionMoves(
ICoord coord, IPieceColor color,PawnDirection dir)
{
var lastRow = color == White() ? LASTROW : 0;
var square = BoardSquares[coord];
int rowNr = square.RowNr;
if (rowNr == 0 || rowNr == lastRow)
return null;
switch (dir)
{
case LEFT:
case RIGHT:
return BuildNonEPCaptures(color, square, dir);
case EP_LEFT:
case EP_RIGHT:
return BuildEPCaptures(color, square, dir);
case FRONT:
return BuildPawnFrontMoves(color, square);
default:
return null;
}
}
...
Might as well have used ISquares<ISquare> BoardSquares. But strangely C# does not see that ISquares<ISquareMoveGen> is an ISquares<ISquare> while my code contains public interface ISquareMoveGen: ISquare
C<Derived> is not automatically a derived class of C<Base>. That is not specific for C#.
No I had never heard of covariant. I changed it, Only had to add 'out'. That's all to make it work.
Don't understand why compiler or intellisense does not give a hint.
Square64MoveGen:
Should have two magic numbers + keyLengths (that is number of bits). One for diagonal and one for straight moves.
Has two hastables: one for diagonal and one for straight moves
Number of buckets of each hash table = Pow(2, keyLength)
hastable returns the coords of the diagonal/vertical moves for a given occupancy for a bishop/rook/queen on this square.
By the way I don't understand that code or formula for computing the hashkey.
But I am trying to rewrite it and implement it this way and see if it still works.
I forgot how the magic numbers were created. So If I would change the number of squares I first have to implement code to generate magic numbers or not use magic bitboard movegeneration at all.