// Generate random locations for the clues private void GenerateRandom(bool[,] grid) { // Generate random numbers using random numbers as the seed // too ensure trully random numbers for both coordinates Random randomX = new Random(Guid.NewGuid().GetHashCode()); Random randomY = new Random(Guid.NewGuid().GetHashCode()); // Get maximum array size for loop int maxX = grid.GetLength(0); int maxY = grid.GetLength(1); // Generate random location in matrix for the "key" int randX = randomX.Next(0, maxX); int randY = randomY.Next(0, maxY); if (!grid[randX, randY]) { grid[randX, randY] = true; clue = new Clue(randX, randY); // MessageBox.Show("Random Location Set Too: \n[" + randX.ToString() + "," + randY.ToString() + "]"); // For testing random generator } }
// Is the user guess == to clue private bool isMatch(Guess guess, Clue key) { return((guess.getX() == key.getX() && guess.getY() == key.getY()) ? true : false); }