I made a Conway's game of life on C# recently and now I'm trying to get off the console flickering. Is there any way to do that??
void GameOn(int [,] grid, int [,] nextgrid ){
Thread.Sleep(150);
Console.Clear();
// Compute Next Gen
for (int i =0;i<rows;i++){
for (int j=0;j<cols;j++){
int state = grid[i,j];
int neighbors = CountNeighbors(grid,i,j);
if(state == 1 && (neighbors<2 || neighbors>3)){
nextgrid[i,j] = 0;
}
else if (state == 1 && (neighbors==3 || neighbors == 2)){
nextgrid[i,j] = 1;
}
else if (state == 0 && neighbors==3){
nextgrid[i,j] = 1;
}
}
}
grid = nextgrid;
// Print On Screen
for(int i =0;i<rows;i++){
for(int j =0;j<cols;j++){
if(grid[i,j]==1){
Console.Write("#");
}
else{
Console.Write(" ");
}
}
Console.WriteLine();
}
GameOn(grid,nextgrid); }