Skip to content

Commit

Permalink
Fixed double captures
Browse files Browse the repository at this point in the history
  • Loading branch information
skotz committed Dec 17, 2016
1 parent 5507913 commit 2ad96ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Chase.Engine/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void MakeMove(Move move, bool firstLevel, int basePieceCount)
if ((sourcePiece > 0 && Board[move.ToIndex] < 0) || (sourcePiece < 0 && Board[move.ToIndex] > 0))
{
// Keep track of how many points the enemy will need to distribute to other die
PointsToDistribute = Math.Abs(Board[move.ToIndex]);
PointsToDistribute += Math.Abs(Board[move.ToIndex]);
}

// Are we landing on the chamber?
Expand Down
10 changes: 9 additions & 1 deletion Chase.Tests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ public class SearchTests
public void TestGetBestMove()
{
Search search = new Search();
SearchResult result = search.GetBestMove(Position.FromStringNotation("1bcdedcba/9/9/9/9/9/9/4a4/BBBDEDBBB b"), new SearchArgs(1, -1));
SearchResult result;

// The only sensible move is to capture on A5
result = search.GetBestMove(Position.FromStringNotation("1bcdedcba/9/9/9/9/9/9/4a4/BBBDEDBBB b"), new SearchArgs(1, -1));
Assert.AreEqual(76, result.BestMove.ToIndex);

// Splitting on the chamber captures two pieces, so we need to make sure pieces to distribute is 2
Position position = Position.FromStringNotation("1bcdedcb1/9/9/9/5a3/4a4/5B3/9/A1CDEDCBA r");
result = search.GetBestMove(position, new SearchArgs(1, -1));
Assert.AreEqual("C6-CH", result.BestMove.ToString());
position.MakeMove(result.BestMove);
Assert.AreEqual(2, position.PointsToDistribute);
}
}
}

0 comments on commit 2ad96ed

Please sign in to comment.