yep
This commit is contained in:
@@ -81,5 +81,15 @@ namespace Shogi.Domain.Pieces
|
||||
|
||||
return Array.Empty<Vector2>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all positions this piece could move to from the currentPosition, respecting the move-set of this piece.
|
||||
/// </summary>
|
||||
/// <param name="currentPosition"></param>
|
||||
/// <returns>A list of positions the piece could move to.</returns>
|
||||
public IEnumerable<Vector2> GetPossiblePositions(Vector2 currentPosition)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BoardTile = System.Collections.Generic.KeyValuePair<System.Numerics.Vector2, Shogi.Domain.Pieces.Piece>;
|
||||
using Shogi.Domain.Pathing;
|
||||
using BoardTile = System.Collections.Generic.KeyValuePair<System.Numerics.Vector2, Shogi.Domain.Pieces.Piece>;
|
||||
|
||||
namespace Shogi.Domain
|
||||
{
|
||||
@@ -206,27 +207,34 @@ namespace Shogi.Domain
|
||||
.Where(tile => PieceHasLineOfSight(tile, threatBlockingPosition))
|
||||
.ToList();
|
||||
|
||||
if (tilesThatCouldBlockTheThreat.Any())
|
||||
if (tilesThatDoBlockThreat.Any())
|
||||
{
|
||||
return false; // Cannot be check-mate if a piece can intercept the threat.
|
||||
}
|
||||
}
|
||||
//var line = Vector2.Subtract(kingPosition, threat.Position);
|
||||
//var slope = line.Y / line.X;
|
||||
//foreach (var tile in tilesThatCouldBlockTheThreat)
|
||||
//{
|
||||
// // y = mx + b; slope intercept
|
||||
// // b = -mx + y;
|
||||
// var b = -slope * tile.Position.X + tile.Position.Y;
|
||||
// //if (tile.Position.Y = slope * tile.Position.X + )
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If no ability to block the check, maybe the king can evade check by moving.
|
||||
*/
|
||||
|
||||
|
||||
// TODO: Implement this in the Piece class instead.
|
||||
var possibleSafePositions = new[]
|
||||
{
|
||||
Direction.Up, Direction.Down, Direction.Left, Direction.Right, Direction.UpLeft, Direction.UpRight, Direction.DownLeft, Direction.DownRight
|
||||
}
|
||||
.Select(direction => kingPosition + direction);
|
||||
|
||||
foreach (var maybeSafePosition in possibleSafePositions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* If no ability to block the check, maybe the king can evade check by moving.
|
||||
*
|
||||
* Foreach position the king can reach
|
||||
* Foreach piece owned by "other player", check if piece threatens king position.
|
||||
*/
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user