yep
This commit is contained in:
106
Shogi.Domain/MoveSet.cs
Normal file
106
Shogi.Domain/MoveSet.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Shogi.Domain
|
||||
{
|
||||
public class MoveSet
|
||||
{
|
||||
|
||||
public static readonly MoveSet King = new(new List<Move>(8)
|
||||
{
|
||||
new Move(Direction.Up),
|
||||
new Move(Direction.Left),
|
||||
new Move(Direction.Right),
|
||||
new Move(Direction.Down),
|
||||
new Move(Direction.UpLeft),
|
||||
new Move(Direction.UpRight),
|
||||
new Move(Direction.DownLeft),
|
||||
new Move(Direction.DownRight)
|
||||
});
|
||||
|
||||
public static readonly MoveSet Bishop = new(new List<Move>(4)
|
||||
{
|
||||
new Move(Direction.UpLeft, Distance.MultiStep),
|
||||
new Move(Direction.UpRight, Distance.MultiStep),
|
||||
new Move(Direction.DownLeft, Distance.MultiStep),
|
||||
new Move(Direction.DownRight, Distance.MultiStep)
|
||||
});
|
||||
|
||||
public static readonly MoveSet PromotedBishop = new(new List<Move>(8)
|
||||
{
|
||||
new Move(Direction.Up),
|
||||
new Move(Direction.Left),
|
||||
new Move(Direction.Right),
|
||||
new Move(Direction.Down),
|
||||
new Move(Direction.UpLeft, Distance.MultiStep),
|
||||
new Move(Direction.UpRight, Distance.MultiStep),
|
||||
new Move(Direction.DownLeft, Distance.MultiStep),
|
||||
new Move(Direction.DownRight, Distance.MultiStep)
|
||||
});
|
||||
|
||||
public static readonly MoveSet GoldGeneral = new(new List<Move>(6)
|
||||
{
|
||||
new Move(Direction.Up),
|
||||
new Move(Direction.UpLeft),
|
||||
new Move(Direction.UpRight),
|
||||
new Move(Direction.Left),
|
||||
new Move(Direction.Right),
|
||||
new Move(Direction.Down)
|
||||
});
|
||||
|
||||
public static readonly MoveSet Knight = new(new List<Move>(2)
|
||||
{
|
||||
new Move(Direction.KnightLeft),
|
||||
new Move(Direction.KnightRight)
|
||||
});
|
||||
|
||||
public static readonly MoveSet Lance = new(new List<Move>(1)
|
||||
{
|
||||
new Move(Direction.Up, Distance.MultiStep),
|
||||
});
|
||||
|
||||
public static readonly MoveSet Pawn = new(new List<Move>(1)
|
||||
{
|
||||
new Move(Direction.Up)
|
||||
});
|
||||
|
||||
public static readonly MoveSet Rook = new(new List<Move>(4)
|
||||
{
|
||||
new Move(Direction.Up, Distance.MultiStep),
|
||||
new Move(Direction.Left, Distance.MultiStep),
|
||||
new Move(Direction.Right, Distance.MultiStep),
|
||||
new Move(Direction.Down, Distance.MultiStep)
|
||||
});
|
||||
|
||||
public static readonly MoveSet PromotedRook = new(new List<Move>(8)
|
||||
{
|
||||
new Move(Direction.Up, Distance.MultiStep),
|
||||
new Move(Direction.Left, Distance.MultiStep),
|
||||
new Move(Direction.Right, Distance.MultiStep),
|
||||
new Move(Direction.Down, Distance.MultiStep),
|
||||
new Move(Direction.UpLeft),
|
||||
new Move(Direction.UpRight),
|
||||
new Move(Direction.DownLeft),
|
||||
new Move(Direction.DownRight)
|
||||
});
|
||||
|
||||
public static readonly MoveSet SilverGeneral = new(new List<Move>(4)
|
||||
{
|
||||
new Move(Direction.Up),
|
||||
new Move(Direction.UpLeft),
|
||||
new Move(Direction.UpRight),
|
||||
new Move(Direction.DownLeft),
|
||||
new Move(Direction.DownRight)
|
||||
});
|
||||
|
||||
private readonly ICollection<Move> moves;
|
||||
private readonly ICollection<Move> upsidedownMoves;
|
||||
|
||||
private MoveSet(ICollection<Move> moves)
|
||||
{
|
||||
this.moves = moves;
|
||||
upsidedownMoves = moves.Select(m => new Move(Vector2.Negate(m.Direction), m.Distance)).ToList();
|
||||
}
|
||||
|
||||
public ICollection<Move> GetMoves(bool isUpsideDown) => isUpsideDown ? upsidedownMoves : moves;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user