Created
January 20, 2011 10:57
-
-
Save ElemarJR/787729 to your computer and use it in GitHub Desktop.
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
using System.Collections.Generic; | |
using StrongChess.Model.Pieces; | |
namespace StrongChess.Model.Sets | |
{ | |
struct PieceSet<TPieceRule> | |
where TPieceRule : IPieceRule, new() | |
{ | |
Bitboard _Positions; | |
public PieceSet(Bitboard positions) : this() | |
{ this._Positions = positions; } | |
public IEnumerable<Move> GetMoves(Bitboard friends, Bitboard enemies, bool onlyAttacks = false) | |
{ | |
foreach (var from in _Positions.GetSettedSquares()) | |
{ | |
Bitboard destinations = Rules.For<TPieceRule>().GetMoveBoard(from, friends, enemies); | |
if (onlyAttacks) destinations &= enemies; | |
foreach (var to in destinations.GetSettedSquares()) | |
yield return new Move(from, to); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment