Skip to content

Instantly share code, notes, and snippets.

@main--
Created June 21, 2013 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save main--/5832713 to your computer and use it in GitHub Desktop.
Save main--/5832713 to your computer and use it in GitHub Desktop.
public override System.Collections.Generic.IEnumerable<FigurePosition> GetPossibleTargets(BoardState state)
{
for (FigurePosition pos = Position; pos.IsValid() && !state.IsPositionOccupied(pos, false); pos += new Vector(1, 1))
yield return pos;
for (FigurePosition pos = Position; pos.IsValid() && !state.IsPositionOccupied(pos, false); pos += new Vector(-1, 1))
yield return pos;
for (FigurePosition pos = Position; pos.IsValid() && !state.IsPositionOccupied(pos, false); pos += new Vector(1, -1))
yield return pos;
for (FigurePosition pos = Position; pos.IsValid() && !state.IsPositionOccupied(pos, false); pos += new Vector(-1, -1))
yield return pos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment