public List <Panel> GetNeighbors(Panel panel) { var row = panel.Row; var column = panel.Column; var panels = new List <Panel>(); if (column > 1) { panels.Add(Panels.At(row, column - 1)); } if (row > 1) { panels.Add(Panels.At(row - 1, column)); } if (row < 10) { panels.Add(Panels.At(row + 1, column)); } if (column < 10) { panels.Add(Panels.At(row, column + 1)); } return(panels); }
/// <summary> /// Return the maximum of 4 Panels - unless the coordinates are already at the edge of the board. /// </summary> /// <param name="coordinates"></param> /// <returns></returns> /// public List <Panel> GetNeighbors(Coordinates coordinates) { int row = coordinates.Row; int column = coordinates.Column; List <Panel> panels = new List <Panel>(); if (column > 1) { panels.Add(Panels.At(row, column - 1)); } if (row > 1) { panels.Add(Panels.At(row - 1, column)); } if (row < Constants.MAXROW) { panels.Add(Panels.At(row + 1, column)); } if (column < Constants.MAXCOL) { panels.Add(Panels.At(row, column + 1)); } return(panels); }
public List <BotPanels> GetNeighbors(BotCoordinates coordinates) { int row = coordinates.Row; int column = coordinates.Column; List <BotPanels> panels = new List <BotPanels>(); if (column > 1) { panels.Add(Panels.At(row, column - 1)); } if (row > 1) { panels.Add(Panels.At(row - 1, column)); } if (row < 10) { panels.Add(Panels.At(row + 1, column)); } if (column < 10) { panels.Add(Panels.At(row, column + 1)); } return(panels); }