IntDict score; StringList choices; StringList guess; StringList secret; int gamesWon = -1; void setup() { choices = new StringList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); newGame(); } void newGame() { gamesWon++; choices.shuffle(); secret = new StringList(); for (int i=0; i<4; i++) { // selections secret.append(choices.get(i)); } newGuess(); println("\nsecret:", secret, "\n"); } void newGuess() { guess = new StringList(); score = null; } void draw() { background(0); text("Bulls & Cows " + gamesWon, 5, 20); for (int i=0; i=48 && key<=57) guess.append(str(key)); if (guess.size()==secret.size()) { score = checkScore(secret, guess); println("guess: ", guess, "\n", score, "wins:", gamesWon); } } IntDict checkScore(StringList secret, StringList guess) { IntDict result = new IntDict(); result.set("bulls", 0); result.set("cows", 0); for (int i=0; i