I've seen a lot of algorithms for how to play this, Donal Knuth has one that can win in 5 moves, but none that are really usable by humans. The method I use, which seems to always win is:
Guess 1111
Depending how many 1's were right, Guess 1222, 1122, 1112, 2222
Continue in this manor until the solution is found.
GRGG -> (0, 2) One green in the 2nd position, red is 3 or 4.
BGRB -> (1, 1) No blues, red must be last.
OGOR -> (4, 0) Success.
Have been meaning to simulate this and see if there are any games where this method would not work. Sometimes it takes all the moves but I've never lost.
I created a solver using a SAT/SMT solver that guesses a solution that is consistent with all the previous guesses and their corresponding feedback. It always returns a solution in a small number of guesses. I don’t think it is the optimal solving algorithm but it was a fun exercise!
I've seen a lot of algorithms for how to play this, Donal Knuth has one that can win in 5 moves, but none that are really usable by humans. The method I use, which seems to always win is:
Guess 1111
Depending how many 1's were right, Guess 1222, 1122, 1112, 2222
Continue in this manor until the solution is found.
I just played this game ID: https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/gues...
where it worked perfectly:
RRRR -> (1, 0) One red, somewhere.
RYYY -> (0, 1) No yellows, red is not first
GRGG -> (0, 2) One green in the 2nd position, red is 3 or 4.
BGRB -> (1, 1) No blues, red must be last.
OGOR -> (4, 0) Success.
Have been meaning to simulate this and see if there are any games where this method would not work. Sometimes it takes all the moves but I've never lost.