Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Created January 23, 2011 04:43
Show Gist options
  • Save juanplopes/791827 to your computer and use it in GitHub Desktop.
Save juanplopes/791827 to your computer and use it in GitHub Desktop.
namespace StrongChess.Model.Pieces
{
public struct Bishop : IPieceRule
{
public Bitboard GetMoveBoard(Square from)
{
return GetMoveBoard(from, 0);
}
public Bitboard GetMoveBoard(Square from, Bitboard friends)
{
return GetMoveBoard(from, friends, 0);
}
public Bitboard GetMoveBoard(Square from, Bitboard friends, Bitboard enemies)
{
var allpieces = friends.And(enemies);
var result = Bitboard.Empty.And(from.DiagonalNW, from.DiagonalNE).Except(from);
return result.Except(friends,
from.RayTo.NE.Intersect(allpieces).LowestSquare.RayTo.NE,
from.RayTo.NW.Intersect(allpieces).LowestSquare.RayTo.NW,
from.RayTo.SE.Intersect(allpieces).HighestSquare.RayTo.SE,
from.RayTo.SW.Intersect(allpieces).HighestSquare.RayTo.SW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment