void WritePlayingField(RegularCandies[,] playingField, string filename) { Random rnd = new Random(); StreamWriter writer = new StreamWriter(filename); int row; int colomn; writer.WriteLine(playingField.GetLength(0)); writer.WriteLine(playingField.GetLength(1)); for (row = 0; row < playingField.GetLength(0); row++) { List <int> candyvalues = new List <int>(); for (colomn = 0; colomn < playingField.GetLength(1); colomn++) { int value = rnd.Next(1, 7); RegularCandies candyvalue = (RegularCandies)value; playingField[row, colomn] = candyvalue; candyvalues.Add(value); writer.Write(value + " "); } writer.WriteLine(); } writer.Close(); }
private bool ScoreColumnCheck(RegularCandies[,] field) { for (int r = 0; r < field.GetLength(0); r++) { int curr = 1; RegularCandies currcan = field[r, 0]; for (int c = 1; c < field.GetLength(1); c++) { if (currcan == field[r, c]) { curr++; if (curr == POINTSCORE) { Console.WriteLine("On column {0} there {1} next to eachother.", r + 1, curr); return(true); } } else { curr = 1; } currcan = field[r, c]; } } return(false); }
private void WritePlayfield(RegularCandies[,] field, string filename) { StreamWriter sw = new StreamWriter(@"..\\..\\" + filename + ".txt"); try { sw.WriteLine(field.GetLength(0)); sw.WriteLine(field.GetLength(1)); int w = field.GetLength(0); int h = field.GetLength(1); for (int i = 0; i < h; i++) { string temp = ""; for (int b = 0; b < w; b++) { temp += (int)field[b, i] + " "; } sw.WriteLine(temp); } } finally { sw.Close(); } }
void DisplayCandies(RegularCandies[,] PlayingField) { for (int row = 0; row < PlayingField.GetLength(0); row++) { for (int col = 0; col < PlayingField.GetLength(1); col++) { int number = (int)PlayingField[row, col]; switch (number) { case 0: Console.ForegroundColor = ConsoleColor.Yellow; break; case 1: Console.ForegroundColor = ConsoleColor.Green; break; case 2: Console.ForegroundColor = ConsoleColor.Blue; break; case 3: Console.ForegroundColor = ConsoleColor.Magenta; break; case 4: Console.ForegroundColor = ConsoleColor.Red; break; case 5: Console.ForegroundColor = ConsoleColor.DarkYellow; break; } Console.Write("# "); } Console.WriteLine(); } Console.ResetColor(); }
public bool ScoreColumnPresent(RegularCandies[,] matrix) { RegularCandies regularCandies = new RegularCandies(); int count = 1; for (int col = 0; col < matrix.GetLength(1); col++) { for (int row = 0; row < matrix.GetLength(0); row++) { if (regularCandies == matrix[row, col]) { count++; regularCandies = matrix[row, col]; } else { count = 1; } if (count >= 3) { return(true); } } } return(false); }
public static bool ScoreKolomAanwezig(RegularCandies[,] candies) { int teller = 1; for (int r = 0; r < candies.GetLength(0); r++) { for (int k = 0; k < candies.GetLength(1); k++) { if (r + 1 < candies.GetLength(0) && candies[r, k] == candies[r + 1, k]) { teller++; r++; if (r + 1 < candies.GetLength(0) && candies[r, k] == candies[r + 1, k]) { teller++; } else { r--; teller = 1; } if (teller >= 3) { return(true); } } } } return(false); }
bool ScoreColumnnPresent(RegularCandies[,] matrix) // i need to try and make foreach version of this { RegularCandies MainCandy = RegularCandies.JellyBean; //variable not sure.. int count = 1; //this is for the counter if there is a row found. for (int column = 0; column < matrix.GetLength(0); column++) { for (int row = 0; row < matrix.GetLength(1); row++) { if (row + column != 0) { if (matrix[row, column] == MainCandy) { count++; } else if (count >= 3) { //Console.WriteLine("column score") return(true); } else// this doesnt make sense, i need to understand and see how this works, shown by jurek { count = 1; } } MainCandy = matrix[row, column];// i need some explanation for this } } //Console.WriteLine("no colunn score") return(false); }
bool ScoreColumnPresent(RegularCandies[,] matrix) { //this will be use as a counter. int count = 1; //the current candy RegularCandies currentCandy = RegularCandies.JellyBean; for (int col = 0; col < matrix.GetLength(1); col++) { for (int row = 0; row < matrix.GetLength(0); row++) { if (row + col != 0) { //if the candy is the same as in the matrix add 1 to counter if (currentCandy == matrix[row, col]) { count++; } else if (count >= 3) { //to check if the counter reaches 3; return(true); } else { //if its the same candies, set the counter to 1; count = 1; } } //set a new current candy currentCandy = matrix[row, col]; } } return(false); }
public static bool ScoreRijAanwezig(RegularCandies[,] candies) { // Standaard benodigde waardes int teller = 1; for (int r = 0; r < candies.GetLength(0); r++) { for (int k = 0; k < candies.GetLength(1); k++) { if (k + 1 < candies.GetLength(1) && candies[r, k] == candies[r, k + 1]) { teller++; if (teller >= 3) { return(true); } } else { teller = 1; } } } return(false); }
bool ScoreRowPresent(RegularCandies[,] PlayingField) { for (int row = 0; row < PlayingField.GetLength(0); row++) { int candyCounter = 1; for (int col = 1; col < PlayingField.GetLength(1); col++) { if ((int)PlayingField[row, col] == (int)PlayingField[row, col - 1]) { candyCounter++; } else { candyCounter = 1; } if (candyCounter >= 4) { return(true); } } } return(false); }
bool ScoreColomnPresent(RegularCandies[,] candies) { int currentcandy = 0; int scorecombo = 1; for (int colomn = 0; colomn < candies.GetLength(1); colomn++) { for (int row = 0; row < candies.GetLength(0); row++) { if (currentcandy != 0) { if (currentcandy == (int)candies[row, colomn]) { scorecombo++; } else { scorecombo = 1; currentcandy = (int)candies[row, colomn]; } if (scorecombo >= 3) { return(true); } } else if (currentcandy == 0) { currentcandy = (int)candies[row, colomn]; } } } return(false); }
public static bool ScoreKolomAanwezig(RegularCandies[,] speelveld) { int currentCandy = (int)speelveld[0, 0]; int nextCandy = 0; int score = 1; for (int i = 0; i < speelveld.Length; i++) { int y = i / speelveld.GetLength(0); int x = i % speelveld.GetLength(0); nextCandy = (int)speelveld[x, y]; if (nextCandy == currentCandy) { score++; if (score == 3) { return(true); } } else { score = 1; } currentCandy = (int)speelveld[x, y]; } return(false); }
void InitCandies(RegularCandies[,] candies) { for (int r = 0; r < candies.GetLength(0); r++) { for (int k = 0; k < candies.GetLength(1); k++) { candies[r, k] = (RegularCandies)rnd.Next(1, 7); } } }
void InitCandies(RegularCandies[,] matrix) { Random rnd = new Random(); for (int i = 0; i < matrix.GetLength(0); i++) { for (int j = 0; j < matrix.GetLength(1); j++) { matrix[i, j] = (RegularCandies)rnd.Next(1, 7); } } }
void InitCandies(ref RegularCandies[,] speelveld) { Random rnd = new Random(); for (int x = 0; x < speelveld.GetLength(0); x++) { for (int y = 0; y < speelveld.GetLength(1); y++) { speelveld[x, y] = (RegularCandies)rnd.Next(0, 7); } } }
void InitCandies(RegularCandies[,] matrix) { Random rng = new Random(); for (int row = 0; row < matrix.GetLength(0); row++) { for (int col = 0; col < matrix.GetLength(1); col++) { matrix[row, col] = (RegularCandies)rng.Next(1, 7); } } }
private void InitCandies(RegularCandies[,] field) { Random rand = new Random(); for (int r = 0; r < field.GetLength(0); r++) { for (int c = 0; c < field.GetLength(1); c++) { field[r, c] = (RegularCandies)rand.Next(0, Enum.GetNames(typeof(RegularCandies)).Length); } } }
void InitCandies(RegularCandies[,] playingField) { Random Rnd = new Random(); for (int r = 0; r < playingField.GetLength(0); r++) { for (int c = 0; c < playingField.GetLength(1); c++) { int number = Rnd.Next(1, Enum.GetValues(typeof(RegularCandies)).Length); playingField[r, c] = (RegularCandies)number; } } }
void InitCandies(RegularCandies[,] matrix) { int num; Random rnd = new Random(); for (int row = 0; row < matrix.GetLength(0); row++) { for (int col = 0; col < matrix.GetLength(1); col++) { num = rnd.Next(0, 6); matrix[row, col] = (RegularCandies)num; } } }
void InitCandies(RegularCandies[,] matrix)// question C { Random rnd = new Random(); for (int row = 0; row < matrix.GetLength(0); row++) { for (int column = 0; column < matrix.GetLength(1); column++) { matrix[row, column] = (RegularCandies)rnd.Next(1, 7);//to fix this one, dont know what im doing wrong. } //Console.WriteLine(); } }
void DisplayCandies(RegularCandies[,] matrix) { RegularCandies candy; string symbol = "#"; Console.ForegroundColor = ConsoleColor.Black; Console.Write(" 0"); Console.ResetColor(); for (int col = 0; col < matrix.GetLength(0); col++) { Console.Write($" {col}"); } Console.WriteLine(); for (int row = 0; row < matrix.GetLength(0); row++) { Console.Write($" {row}"); for (int col = 0; col < matrix.GetLength(1); col++) { candy = matrix[row, col]; if (candy == RegularCandies.JellyBean) { Console.ForegroundColor = ConsoleColor.Red; } else if (candy == RegularCandies.Lozenge) { Console.ForegroundColor = ConsoleColor.Gray; } else if (candy == RegularCandies.LemonDrop) { Console.ForegroundColor = ConsoleColor.DarkYellow; } else if (candy == RegularCandies.GumSquare) { Console.ForegroundColor = ConsoleColor.Green; } else if (candy == RegularCandies.LollipopHead) { Console.ForegroundColor = ConsoleColor.Blue; } else { Console.ForegroundColor = ConsoleColor.Magenta; } Console.Write(" {0}", symbol); Console.ResetColor(); } Console.WriteLine(); } }
void PrintCandies(RegularCandies[,] speelveld) { int rows = speelveld.GetLength(0); int columns = speelveld.GetLength(1); for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { RegularCandies toPrint = speelveld[r, c]; switch (toPrint) { case RegularCandies.JellyBean: Console.ForegroundColor = ConsoleColor.Red; break; case RegularCandies.Lozenge: Console.ForegroundColor = ConsoleColor.DarkYellow; break; case RegularCandies.LemonDrop: Console.ForegroundColor = ConsoleColor.Yellow; break; case RegularCandies.GumSquare: Console.ForegroundColor = ConsoleColor.Green; break; case RegularCandies.LollipopHead: Console.ForegroundColor = ConsoleColor.Blue; break; case RegularCandies.JujubeCluster: Console.ForegroundColor = ConsoleColor.Magenta; break; default: Console.ResetColor(); break; } Console.Write("# "); } Console.WriteLine(); } Console.ResetColor(); }
RegularCandies[,] initCandies(RegularCandies[,] playingField) { Array values = Enum.GetValues(typeof(RegularCandies)); Random random = new Random(); for (int i = 0; i < playingField.GetLength(0); i++) { for (int j = 0; j < playingField.GetLength(1); j++) { playingField[i, j] = (RegularCandies)values.GetValue(random.Next(values.Length)); } } return(playingField); }
void SchrijfSpeelveld(RegularCandies[,] speelveld, string bestandsnaam) { StreamWriter writer = new StreamWriter(bestandsnaam); for (int r = 0; r < speelveld.GetLength(0); r++) { for (int k = 0; k < speelveld.GetLength(1); k++) { writer.Write((int)speelveld[r, k] + " "); } writer.WriteLine(); } writer.Close(); }
void InitCandies(RegularCandies[,] candies) { Random rnd = new Random(); for (int row = 0; row < candies.GetLength(0); row++) { for (int colomn = 0; colomn < candies.GetLength(1); colomn++) { int value = rnd.Next(1, 7); RegularCandies candyvalue = (RegularCandies)value; candies[row, colomn] = candyvalue; } } }
void InitCandies(RegularCandies[,] PlayingField) { Random rnd = new Random(); int num; for (int row = 0; row < PlayingField.GetLength(0); row++) { for (int col = 0; col < PlayingField.GetLength(1); col++) { num = rnd.Next(0, 6); RegularCandies Candy = (RegularCandies)num; PlayingField[row, col] = Candy; } } }
void InitCandies(ref RegularCandies[,] speelveld) { int rows = speelveld.GetLength(0); int columns = speelveld.GetLength(1); int candies = Enum.GetNames(typeof(RegularCandies)).Length; for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { speelveld[r, c] = (RegularCandies)rnd.Next(0, candies); } } }
void DisplayCandies(RegularCandies[,] playingField) { for (int r = 0; r < playingField.GetLength(0); r++) { for (int c = 0; c < playingField.GetLength(1); c++) { switch (playingField[r, c]) { case RegularCandies.Jellybean: Console.ForegroundColor = ConsoleColor.Red; Console.Write("# "); Console.ResetColor(); break; case RegularCandies.Lozenge: Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("# "); Console.ResetColor(); break; case RegularCandies.LemonDrop: Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("# "); Console.ResetColor(); break; case RegularCandies.GumSquare: Console.ForegroundColor = ConsoleColor.Green; Console.Write("# "); Console.ResetColor(); break; case RegularCandies.LollipopHead: Console.ForegroundColor = ConsoleColor.Blue; Console.Write("# "); Console.ResetColor(); break; case RegularCandies.JujubeCluster: Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("# "); Console.ResetColor(); break; } } Console.WriteLine(); } }
void PrintCandies(RegularCandies[,] candies) { char tag = '#'; for (int r = 0; r < candies.GetLength(0); r++) { for (int k = 0; k < candies.GetLength(1); k++) { switch (candies[r, k]) { case RegularCandies.Jellybean: Console.ForegroundColor = ConsoleColor.Red; break; case RegularCandies.Lozenge: Console.ForegroundColor = ConsoleColor.DarkYellow; break; case RegularCandies.LemonDrop: Console.ForegroundColor = ConsoleColor.Yellow; break; case RegularCandies.Gum_Square: Console.ForegroundColor = ConsoleColor.Green; break; case RegularCandies.LollipopHead: Console.ForegroundColor = ConsoleColor.Blue; break; case RegularCandies.Jujube_Cluster: Console.ForegroundColor = ConsoleColor.DarkMagenta; break; } Console.Write("{0} ", tag); if (k + 1 == candies.GetLength(1)) { k = 0; Console.WriteLine(); break; } } } Console.ResetColor(); }
void SchrijfSpeelveld(RegularCandies[,] speelveld, string bestandsnaam) { StreamWriter writer = new StreamWriter(bestandsnaam); writer.WriteLine($"{speelveld.GetLength(0)} {speelveld.GetLength(1)}"); for (int y = 0; y < speelveld.GetLength(1); y++) { for (int x = 0; x < speelveld.GetLength(0); x++) { writer.Write($"{(int)speelveld[x, y]} "); } writer.WriteLine(); } writer.Close(); }