Guest_imported
New member
- Jan 1, 1970
- 0
Here is something neat that i wanna to try to make:
intro:
The game of Mastermid is played as follow: One player (the code maker) chooses a secret arrangement of colored pegs and the other player (the code breaker) tried to guess it. The code breakers put forth an arrangement of colored pegs, and the code maker reports two number:
1. The number of pegs that are correct color and in the correct
postion.
2. The number of pegs that are the correct color regardless of whether they are in the correct postion
Task:
Write a program that plays the part of the code maker in this game. The code will consist of an arrangement of 3 "pegs" each with a "color" from 1 to 5. The program output may look similar to:
Guess 1:
First peg: 3
Second peg: 4
Third peg: 2
You have 1 correct peg(s) and 2 correct color(s)
Guess 2:
First peg: 3
Second peg: 4
Third peg: 5
You have 1 correct peg(s) and 3 correct color(s)
Guess 3:
First peg: 3
Second peg: 5
Third peg: 4
You have 3 correct peg(s) and 3 correct color(s)
You have borken the code in 3 guesses
**Note**: For simpilicity, do not allow either guess or the code to contain duplicates. You should write a function that checks for duplicate pegs and use it to prevent duplicates.
Okay, here i made the prototype for all my functions with little help of the tutorial book, but i can't seem to understand the logic to acheive this program in detail.
<code>
#include <iostream.h>
#include <stdlib.h>
//---------------------------------------------------------------------
void GeneratePegColor (int &Peg1, int &Peg2, int &Peg3);
void UserGuess (int guess1, int guess2, int guess3, int GuessesLeft);
int ReturnNumberOfCorrectPegColor (int Peg1, int Peg2, int Peg3,int guess1, int guess2, int guess3);
int ReturnNumberOfCorrectPegPosition (int Peg1, int Peg2, int Peg3,int guess1, int guess2, int guess3);
bool Dope_test1 (int var1,int var2, int var3);
bool Dope_test2 (int var1,int var2, int var3);
//---------------------------------------------------------------------
</code>
Can anyone give me some hints or detail instruction on the logic behind this?? Thanx you for taking ur time to help me out! Thanx you!
intro:
The game of Mastermid is played as follow: One player (the code maker) chooses a secret arrangement of colored pegs and the other player (the code breaker) tried to guess it. The code breakers put forth an arrangement of colored pegs, and the code maker reports two number:
1. The number of pegs that are correct color and in the correct
postion.
2. The number of pegs that are the correct color regardless of whether they are in the correct postion
Task:
Write a program that plays the part of the code maker in this game. The code will consist of an arrangement of 3 "pegs" each with a "color" from 1 to 5. The program output may look similar to:
Guess 1:
First peg: 3
Second peg: 4
Third peg: 2
You have 1 correct peg(s) and 2 correct color(s)
Guess 2:
First peg: 3
Second peg: 4
Third peg: 5
You have 1 correct peg(s) and 3 correct color(s)
Guess 3:
First peg: 3
Second peg: 5
Third peg: 4
You have 3 correct peg(s) and 3 correct color(s)
You have borken the code in 3 guesses
**Note**: For simpilicity, do not allow either guess or the code to contain duplicates. You should write a function that checks for duplicate pegs and use it to prevent duplicates.
Okay, here i made the prototype for all my functions with little help of the tutorial book, but i can't seem to understand the logic to acheive this program in detail.
<code>
#include <iostream.h>
#include <stdlib.h>
//---------------------------------------------------------------------
void GeneratePegColor (int &Peg1, int &Peg2, int &Peg3);
void UserGuess (int guess1, int guess2, int guess3, int GuessesLeft);
int ReturnNumberOfCorrectPegColor (int Peg1, int Peg2, int Peg3,int guess1, int guess2, int guess3);
int ReturnNumberOfCorrectPegPosition (int Peg1, int Peg2, int Peg3,int guess1, int guess2, int guess3);
bool Dope_test1 (int var1,int var2, int var3);
bool Dope_test2 (int var1,int var2, int var3);
//---------------------------------------------------------------------
</code>
Can anyone give me some hints or detail instruction on the logic behind this?? Thanx you for taking ur time to help me out! Thanx you!