Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Question: I need a C++ code that cracks the 4 digit code in a source code. please read the following for a reference Prompt: Mastermind with an AI Guidelines 4 digit code breaking 0000-9999 Use my

Question: I need a C++ code that cracks the 4 digit code in a source code. 

please read the following for a reference

Prompt: Mastermind with an AI

Guidelines 4 digit code breaking 0000-9999

Use my Driver/Stub to write your own AI function.

Create your AI function whose output is the next guess to break the code.

Include writeup/flowcharts/pseudocode,

You should be able to break the code faster than a Binary Search.

Code mentioned in prompt: There are two versions you can use. 

Link: 2021_Spring_CSC_CIS_7/main.cpp at master · ml1150258/2021_Spring_CSC_CIS_7 · GitHub

under project MasterMindAI_V1 or V2.

Source Code to Copy: V2 here

//System Libraries #include #include #include #include #include using namespace std; //Function Prototypes string AI(char,char); bool eval(string,string,char &,char &); string set(); int main(int argc, char** argv) {    //Set the random number seed    srand(static_cast(time(0)));        //Declare variables    string code,guess;  //code to break, and current guess    char rr,rw;         //right digit in right place vs. wrong place    int nGuess;         //number of guesses        //Initialize Values    nGuess=0;    code=set();    rr=rw=0;        //Loop until solved and count to find solution    do{       nGuess++;       guess=AI(rr,rw);    }while(eval(code,guess,rr,rw));    //Check evaluation    cout<(rr)                <(rw)<(r[i])<<" "                    <(w[i])<0?guess-10:0,guess);        //Calculate the guess    int n1000=(guess-guess%1000)/1000;    int n100=(guess-guess%100)/100-10*n1000;    int n10=(guess%100-guess%10)/10;    int n1=guess%10;    sGuess[0]=n1000+'0';    sGuess[1]=n100+'0';    sGuess[2]=n10+'0';    sGuess[3]=n1+'0';    aGuess[++guess]=sGuess;//Save the result        //Return the result    return sGuess; } bool eval(string code,string guess,char &rr,char &rw){    string check="    ";    rr=0,rw=0;    //Check how many are right place    for(int i=0;i

Sample output: Currently it will generate a 4 digit code and display how many guess it took, the actual code, and the code the AI guessed.

Ex: 5237 5236 5236

5226   3   0            <- this output shows the current guess and how many digits are correct

5227   2   0

I need it to display

Ex: 13or less  5236 5236

Last info: Basically I need an AI code in V2 to be altered in a way that will allow the computer to guess the randomly generated code with 13 guesses. In addition I need a simple flowchart and a psuedocode for it aswell. Not looking for amazing work. Just something that works.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question