A code, or a guess, is in the listing a array of four ints. The values of these ints are 0,1,2,3,4,5. Which colour is which number is defined in the color table of screen. Which letter is used for which number is defined in charToInt.
An evaluation,( or a score, that's the same), is also an array of 4 ints. These ints can be 0 (no pin), 1 (a white pin), or 2 (a black pin). Usually, first black pins are given, then white pins.
The least readable method is the paint of the screen. Some explanation: By using magfactor I can make the applet bigger and smaller if I want to (I don't want to, but it's nice I can do it). In every call to graphics, I must multiply the coordinates with magfactor.
I for myself have made a sketch of the screen division: There are eleven code positions(The last one is used for the code that has to be guessed. The first ten are for your guesses): A code gets 40 by 10 pixels (if magfactor were 1). Besides every code position, there is room for an evaluation. This measures 10 by 10. (The real life bord game uses the same division.)
To evaluate the code, I had to make sure no colours were doublely rewarded. For instance a colour can be at the exact position, and can cause a black pin, and have the same color to something at a different position. To tackle this problem, I copy both the code and the guess, so I can write in it. I first check for black pins. If you have a match, you overwrite the colors in both the code and the guess with some different nonsense number. Now they will not match anything else, so they can't be rewarded double.
I hope this helped you read this, I must admit, not so structured program. If you still can't read it, maybe you should mail me.Another good mastermind version by Rehman Mackwani can be found here (based on this ).