SlaveMind Game - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# SlaveMind Game

Posts: 6Member
I am working on a slavemind game project written in Java. Does anybody here have been working on that or have done that before? I really need the source code for the SlaveMind Game. This is how the game is: The game of Mastermind where one player sets up a number of pins behind a barrier and the other player guesses the colour and position of each pin is well known. The Slavemind game in this assignment is similar except it is played against the computer using numbers instead of coloured pins.
The computer generates a number consisting of five non-unique digits between 1 and 5. The human player repeatedly guesses the number, receiving feedback on the accuracy of each guess from the computer. Feedback is of the following form:
A P is awarded if a digit in the guess is correct and in the correct position. More than one P means that multiple digits are in the correct position, without saying which digits or positions they are. PPPPP means that all digits are correct and in the correct position.
An N is awarded if a digit in the guess is correct but in the wrong position.
A Z is awarded if no digits of the guess are in the target number.
So that the game is not too easy, the feedback always evaluates and displays the Ps before the Ns.

I would be very thankful if you could post a reply to this. TQ!

• Posts: 6,349Member
: I am working on a slavemind game project written in Java. Does anybody here have been working on that or have done that before? I really need the source code for the SlaveMind Game. This is how the game is: The game of Mastermind where one player sets up a number of pins behind a barrier and the other player guesses the colour and position of each pin is well known. The Slavemind game in this assignment is similar except it is played against the computer using numbers instead of coloured pins.
: The computer generates a number consisting of five non-unique digits between 1 and 5. The human player repeatedly guesses the number, receiving feedback on the accuracy of each guess from the computer. Feedback is of the following form:
: A P is awarded if a digit in the guess is correct and in the correct position. More than one P means that multiple digits are in the correct position, without saying which digits or positions they are. PPPPP means that all digits are correct and in the correct position.
: An N is awarded if a digit in the guess is correct but in the wrong position.
: A Z is awarded if no digits of the guess are in the target number.
: So that the game is not too easy, the feedback always evaluates and displays the Ps before the Ns.
:
: I would be very thankful if you could post a reply to this. TQ!
:
:
See Math.random() to setup the game.
Use int[] arrays to hold the numbers and a string to hold the results
The simplest way to check the results, is first to loop through the player and computer arrays and check each element 1 on 1:
[code]
for (int i=0; i < pinCount; i++) {
if (computer[i] == player[i]) {
result = result + 'P';
player[i] = -1;
}
}
[/code]
Then check each digit out of place:
[code]
for (int i=0; i < pinCount; i++) {
for (int j=0; j < pinCount; j++) {
if (computer[i] == player[i] && i != j) {
result = result + 'N';
player[i] = -1;
}
}
}
[/code]
This code needs some work to correctly display it.
The turns repeat until the results string equals all P's.
• Posts: 6Member
Could you please sending me the source code to the SlaveMind game written in Java? I do understand better with your suggested codes but I think I can understand it better if you could send me the whole source code. Thank you very much before hand.
• Posts: 6,349Member
: Could you please sending me the source code to the SlaveMind game written in Java? I do understand better with your suggested codes but I think I can understand it better if you could send me the whole source code. Thank you very much before hand.
:
I don't have that code, and I'm unwilling to make it for you, since I've already have 3 projects running. I could be persuaded to trade with you if you like, although all my projects are much larger than this one.