public void Step1() { Game r = new Game(); List <int> row = new List <int>(); List <int> col = new List <int>(); int count1 = 0; int result = r.check(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (Game.state[i, j] == 0 && result == 0) { row.Add(i); col.Add(j); count1++; } } } if (count1 == 0) { x = -1; y = -1; return; } System.Random ran = new System.Random(); if (result == 0) { int index = ran.Next(0, count1); x = row[index]; y = col[index]; return; } }