UTests pass with Pathfinder2D
This commit is contained in:
@@ -75,7 +75,7 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
To = new Vector2(0, 3)
|
||||
}
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
shogi.Board[0, 2].Should().BeNull();
|
||||
shogi.Board[0, 3].WhichPiece.Should().Be(WhichPiece.Pawn);
|
||||
}
|
||||
@@ -99,9 +99,9 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
{
|
||||
var invalidLanceMove = new Move
|
||||
{
|
||||
// Lance moving adjacent
|
||||
From = new Vector2(0, 0),
|
||||
To = new Vector2(1, 5)
|
||||
// Bishop moving lateral
|
||||
From = new Vector2(1, 1),
|
||||
To = new Vector2(2, 1)
|
||||
};
|
||||
|
||||
var shogi = new ShogiBoard();
|
||||
@@ -177,16 +177,12 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
// P1 Bishop puts P2 in check
|
||||
new Move { From = new Vector2(1, 1), To = new Vector2(6, 6) }
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
//foreach(var m in moves)
|
||||
//{
|
||||
// shogi.Move(m);
|
||||
//}
|
||||
//var shogi = new ShogiBoard(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
|
||||
// Prerequisit
|
||||
shogi.InCheck.Should().Be(WhichPlayer.Player2);
|
||||
|
||||
|
||||
// Act - P2 moves Lance while remaining in check.
|
||||
var moveSuccess = shogi.Move(new Move { From = new Vector2(8, 8), To = new Vector2(8, 7) });
|
||||
|
||||
@@ -208,7 +204,8 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
// P2 Pawn
|
||||
new Move { From = new Vector2(6, 6), To = new Vector2(6, 5) },
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
shogi.PrintStateAsAscii();
|
||||
|
||||
|
||||
// Act - P1 Bishop, check
|
||||
@@ -229,7 +226,7 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
// P2 Pawn
|
||||
new Move { From = new Vector2(6, 6), To = new Vector2(6, 5) }
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
|
||||
// Act - P1 Bishop captures P2 Bishop
|
||||
var moveSuccess = shogi.Move(new Move { From = new Vector2(1, 1), To = new Vector2(7, 7) });
|
||||
@@ -275,7 +272,7 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
// P2 Pawn
|
||||
new Move { From = new Vector2(6, 6), To = new Vector2(6, 5) }
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
|
||||
// Act - P1 moves across promote threshold.
|
||||
var moveSuccess = shogi.Move(new Move { From = new Vector2(1, 1), To = new Vector2(6, 6), IsPromotion = true });
|
||||
@@ -313,7 +310,7 @@ namespace Gameboard.ShogiUI.UnitTests.BoardState
|
||||
// P2 King retreat
|
||||
new Move { From = new Vector2(4, 7), To = new Vector2(4, 8) },
|
||||
};
|
||||
var shogi = ShogiBoard.ConstructWithMoves(moves);
|
||||
var shogi = new ShogiBoard(moves);
|
||||
|
||||
// Act - P1 Pawn wins by checkmate.
|
||||
var moveSuccess = shogi.Move(new Move { From = new Vector2(4, 6), To = new Vector2(4, 7) });
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using FluentAssertions;
|
||||
using Gameboard.ShogiUI.BoardState;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PathFinding;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Gameboard.ShogiUI.UnitTests.PathFinding
|
||||
{
|
||||
[TestClass]
|
||||
public class PathFinder2DShould
|
||||
{
|
||||
class TestElement : IPlanarElement
|
||||
{
|
||||
public ICollection<Path> GetPaths() => throw new System.NotImplementedException();
|
||||
public bool IsUpsideDown => false;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Maths()
|
||||
{
|
||||
var finder = new PathFinder2D<TestElement>(new Array2D<TestElement>(5, 5));
|
||||
|
||||
var result = finder.IsPathable(
|
||||
new Vector2(2, 2),
|
||||
new Vector2(7, 7),
|
||||
new Vector2(3, 3)
|
||||
);
|
||||
result.Should().BeTrue();
|
||||
|
||||
result = finder.IsPathable(
|
||||
new Vector2(2, 2),
|
||||
new Vector2(7, 7),
|
||||
new Vector2(2, 2)
|
||||
);
|
||||
result.Should().BeFalse();
|
||||
|
||||
result = finder.IsPathable(
|
||||
new Vector2(2, 2),
|
||||
new Vector2(7, 7),
|
||||
new Vector2(-1, 1)
|
||||
);
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user