public static IEnumerable <Loc> _TilesCovered(Board currentBoard, byte row, byte col) { var covered = new List <Loc>(); for (int i = 1; i < 8; i++) { var loc = new Loc(row + i, col + i); if (!Board.InsideBoard(loc)) { break; } covered.Add(loc); if (currentBoard.IsOccupied(loc)) { break; } } for (int i = 1; i < 8; i++) { var loc = new Loc(row + i, col - i); if (!Board.InsideBoard(loc)) { break; } covered.Add(loc); if (currentBoard.IsOccupied(loc)) { break; } } for (int i = 1; i < 8; i++) { var loc = new Loc(row - i, col + i); if (!Board.InsideBoard(loc)) { break; } covered.Add(loc); if (currentBoard.IsOccupied(loc)) { break; } } for (int i = 1; i < 8; i++) { var loc = new Loc(row - i, col - i); if (!Board.InsideBoard(loc)) { break; } covered.Add(loc); if (currentBoard.IsOccupied(loc)) { break; } } return(covered); }
public override IEnumerable <Loc> TilesCovered(Board currentBoard, byte row, byte col) { var locs = new[] { new Loc(row + 2, col + 1), new Loc(row + 2, col - 1), new Loc(row - 2, col + 1), new Loc(row - 2, col - 1), new Loc(row + 1, col + 2), new Loc(row + 1, col - 2), new Loc(row - 1, col + 2), new Loc(row - 1, col - 2), }; foreach (var loc in locs) { if (Board.InsideBoard(loc)) { yield return(loc); } } }