Ok,
A recap, because I ran the test with Class / Array, and the result was very slow. I then ran the other tests and they ewre also slow, so I've lost fiath in my Laptop, and tested using my normal Dev computer.
To reduce the test time, I ran the nomal position as Black and White twice, four times in all, to depth 4 approx, 17m moves.
A quick recap of the results shows that something was amiss on the laptop:
Code: Select all
Array + class Move
3620 knps, 10.7MB Heap Allocations
Array + struct Move
2800 knps, 22.2MB Heap Allocations
List + class Move
3470 knps, 10.7MB Allocations
List + struct Move
2410 knps, 22.3MB Allocations
where with the List
Code: Select all
Perft has:
List<Move> moveArray = new List<Move>(Moves.MaxMoveListMoves);
MoveGenerator.GenerateMoves(tree.board, moveArray);
MoveGen is:
public static void GenerateMoves(Board board, List<Move> moveList);
adding moves with:
list.Add(new Move(Squares.E8, Squares.C8, Pieces.NoPiece, Pieces.NoPiece, Moves.FlagCastled));
and with the Array
Code: Select all
Perft has:
Move[] moveArray = new Move[Moves.MaxMoveListMoves];
int MoveCount = 0;
MoveGenerator.GenerateMoves(tree.board, moveArray, ref MoveCount);
MoveGen is:
public static void GenerateMoves(Board board, Move[] moveList, ref int moveCount)
adding moves with:
moveList[moveCount++] = new Move(from, toSq, Pieces.NoPiece, board.GetPiece(toSq), Moves.FlagNone);
I'm sorry for the confusion, but the Heap allocation still seems to be the problem.
I've also visited some of the links you posted today
I'll look at the IL DASM now, and report back.
Thanks
Richard
To Sven,
This thought also popped into my head - I think it could be a solution. I also think your piecelist suggestion will give an improvement, as the profile data clearly shows a good chunk of time is used in MovePieceOnList due to the loop.
I'd like first to understand the Boxing issue above, and then I will implement the changes you described. If I do it all at the same time, I loose track of which branch is which
danke dir
Richard