import java.util.*;
public class ComputerGuess {
List<int[]> ls;
List<int[]> temp;
List<Computer> computers;
Computer computer;
int A, B, N;
public ComputerGuess() {
A = 0;
B = 0;
temp = new ArrayList<int[]>();
ls = InitialLS();
}
private List<int[]> InitialLS() {
List<int[]> tt = new ArrayList<int[]>();
int[] temp = null;
tag: for (int i = 1000; i < 10000; i++) {
temp = new int[4];
for (int j = 0; j <= 3; j++) {
int temps = i / (int) Math.pow(10, 3 - j) % 10;
for (int k = 0; k < j; k++) {
if (temps == temp[k]) {
continue tag;
}
}
temp[j] = temps;
}
tt.add(temp);
}
return tt;
}
public String toString(int[] temp) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 4; i++)
sb.append(temp[i] + " ");
return sb.toString();
}
public void Show() {
computers = new ArrayList<Computer>();
boolean Judging = true;
System.out.println("Before ls 's count is: " + ls.size());
while (Judging) {
int i = 0;
computer = new Computer();
if (temp.size() > 0) {
ls.clear();
for (int[] tt : temp) {
ls.add(tt);
}
temp.clear();
System.out.println("After ls 's count is: " + ls.size());
}
int n = new Random().nextInt(ls.size());
System.out.print("你心里想的数是:\t");
if (i == 0) {
int[] rand = computer.getGuessNumber();
System.out.println(computer.toString(rand));
Judging = ShowYourJudge(rand);
} else {
System.out.println(toString(ls.get(n)));
Judging = ShowYourJudge(ls.get(n));
}
}
}