Bulls and Cows

Bulls & Cows is an ancient game with lots of variations, including the commercial board game 'MasterMind'.

'We start with a four digit random number formed from the digits 1 to 9, without duplication. 
'NB various versions exist. More standard is to allow zero, including leading zero..

'The player should then create guesses to this number, each time (if they can!) from those which conform to previous scores,...
'   then print the score for the guess,...
'   until only the correct solution is possible.

'The score is computed as:
'    The player wins if the guess is the same as the randomly chosen number, and the program ends.
'    A score of one bull is accumulated for each digit in the guess
'        that equals the corresponding digit in the randomly chosen initial number.
'    A score of one cow is accumulated for each digit in the guess that also
'       appears in the randomly chosen number, but in the wrong position.

'The computer can have three roles. 
'    1  As a generator of random targets
'    2  As scorer, it can calculate scores of guesses against a target.
'    3  As a player, it can, by elimination, guess an unknown target
'        set by a human or program ( 1)

The simplest task is to implement a system which will score for you, rejecting invalid tries. The human at the mouse and keyboard has to do all the logical thinking.

This logic code can be given a text-only interface, or a GUI. Both cases can have the computer supply a random suitable target for you to guess.

Computer as Player

This is the most interesting. Program a machine to make logic deductions that home in on the target, without the machine being given access to its value...

A zip file of the programs and necessary bmp & wav files will soon be added here. Meanwhile, see Rosetta Code or the LB Forum...