public void ScanNewRules() { IsSimulationStable = true; var rowsCount = SeatLayout.Count; var columnsCount = SeatLayout[0].Count; for (var rowIndex = 0; rowIndex < rowsCount; rowIndex++) { for (var columnIndex = 0; columnIndex < columnsCount; columnIndex++) { var currentTile = SeatLayout[rowIndex][columnIndex]; var visibleOccupiedSeatsCount = SeatSimulationUtility.CountAllVisibleOccupiedSeats(rowIndex, columnIndex, SeatLayout); if (currentTile.TileStatus == TileStatus.SeatEmpty && visibleOccupiedSeatsCount == 0 || currentTile.TileStatus == TileStatus.SeatOccupied && visibleOccupiedSeatsCount >= 5) { SeatLayout[rowIndex][columnIndex].ToBeSwapped = true; IsSimulationStable = false; } } } }
public void Scan() { IsSimulationStable = true; var rowsCount = SeatLayout.Count; var columnsCount = SeatLayout[0].Count; for (var rowIndex = 0; rowIndex < rowsCount; rowIndex++) { for (var columnIndex = 0; columnIndex < columnsCount; columnIndex++) { var currentTile = SeatLayout[rowIndex][columnIndex]; var neighbourOccupiedSeats = SeatSimulationUtility.CountAdjacentOccupiedSeat(rowIndex, columnIndex, SeatLayout); if (currentTile.TileStatus == TileStatus.SeatEmpty && neighbourOccupiedSeats == 0 || currentTile.TileStatus == TileStatus.SeatOccupied && neighbourOccupiedSeats >= 4) { SeatLayout[rowIndex][columnIndex].ToBeSwapped = true; IsSimulationStable = false; } } } }
public void Update() { SeatSimulationUtility.UpdateSeatLayout(SeatLayout); }