I have to fill a matrix with randomic numbers from a set of (-1,0,1)... My code do this, however I would like that my matrix has more different elements inside of it. I try to explain myself better with an example.
One of the output of my code is:
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,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0,0,0,1,1,1,-1,1,1,1,-1
0,-1,0,0,0,0,0,-1,0,0,0,1,-1,1,0,-1,0,0,0,0,0,0,0,-1,1,1,0,0,0,0,-1
0,-1,0,0,0,1,1,1,-1,0,0,1,1,1,0,-1,0,0,0,0,0,0,0,0,1,1,-1,0,0,0,-1
1,-1,1,0,1,0,1,1,0,0,0,1,1,0,-1,-1,0,0,1,0,0,0,0,1,1,1,0,1,-1,0,-1
0,-1,0,0,0,-1,-1,-1,1,1,1,0,-1,-1,-1,-1,1,1,0,1,0,1,0,-1,1,1,-1,0,-1,1,1
0,-1,0,0,0,-1,0,0,1,1,0,1,-1,-1,0,-1,1,1,0,1,0,1,0,1,1,-1,-1,0,0,1,1
0,-1,0,1,0,-1,0,-1,0,0,0,0,1,-1,1,-1,1,1,0,0,0,0,0,-1,0,1,-1,0,1,1,1
0,1,0,0,0,0,0,1,-1,1,0,0,1,0,-1,1,0,0,0,1,0,1,0,-1,0,1,0,0,0,0,-1
1,1,1,0,1,1,-1,1,-1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,0,1,-1,0,1,1,-1
0,-1,0,0,0,-1,-1,-1,0,0,0,1,-1,0,-1,-1,0,0,0,0,0,0,0,-1,1,1,-1,0,0,0,1
0,-1,0,0,0,-1,-1,1,0,0,0,0,1,-1,-1,-1,0,0,0,0,0,0,0,-1,1,0,-1,0,0,0,1
0,-1,0,0,0,0,1,1,-1,0,0,0,1,0,1,-1,1,1,0,0,0,0,0,1,0,1,-1,1,-1,1,-1
0,-1,0,0,0,-1,1,1,0,0,0,1,1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,1
So not a lot of the same rows like in my output.
But I don't have an idea how to do this... it is possible?
My code:
static void Main()
{
int righe = 2432; //rows
int colonne=31; //coloumns
int[,] matrice = new int[righe, colonne];
for(int i = 0; i<righe; i++)
{
for (int y = 0; y < colonne; y++)
{
System.Random random = new System.Random();
int number = random.Next(0, 2);
int[] choices = new int[3] { -1, 0, 1 };
matrice[i, y] = choices[number]; //insert the random value
Console.WriteLine(matrice[i, y]);
}
}
}