-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
branching factor is slowly going down and we are getting faster cut-offs, we won't need to always sort the entire move list soon
- Loading branch information
Showing
5 changed files
with
54 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,42 @@ | ||
using Rudim.Board; | ||
using Rudim.Common; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Rudim.Test.UnitTest.Board | ||
{ | ||
public class MoveOrderingTest | ||
{ | ||
[Fact] | ||
public void ShouldOrderMovesByScore() | ||
public void ShouldSortMovesByScore() | ||
{ | ||
BoardState boardState = BoardState.ParseFEN(Helpers.KiwiPeteFEN); | ||
List<Move> moves = new() | ||
{ | ||
new Move(Square.e2, Square.e4, MoveTypes.Quiet) { Score = 100 }, | ||
new Move(Square.d2, Square.d4, MoveTypes.Quiet) { Score = 300 }, | ||
new Move(Square.g1, Square.f3, MoveTypes.Quiet) { Score = 200 } | ||
}; | ||
|
||
MoveOrdering.SortNextBestMove(moves, 0); | ||
|
||
Assert.Equal(300, moves[0].Score); | ||
} | ||
|
||
boardState.GenerateMoves(); | ||
foreach (Move move in boardState.Moves) | ||
[Fact] | ||
public void ShouldNotChangeOrderIfAlreadySorted() | ||
{ | ||
List<Move> moves = new() | ||
{ | ||
MoveOrdering.PopulateMoveScore(move, boardState); | ||
} | ||
MoveOrdering.SortMoves(boardState); | ||
new Move(Square.d2, Square.d4, MoveTypes.Quiet) { Score = 300 }, | ||
new Move(Square.g1, Square.f3, MoveTypes.Quiet) { Score = 200 }, | ||
new Move(Square.e2, Square.e4, MoveTypes.Quiet) { Score = 100 } | ||
}; | ||
|
||
MoveOrdering.SortNextBestMove(moves, 1); | ||
|
||
// TODO: Improve assertions, verify proper order as per MVV LVA | ||
Assert.True(boardState.Moves[0].IsCapture()); | ||
Assert.Equal(300, moves[0].Score); | ||
Assert.Equal(200, moves[1].Score); | ||
Assert.Equal(100, moves[2].Score); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters