   How do YOU implement difficulty levels?
  Hey guys, I'm working on a Mastermind game for some practice and I've got a question... I want to have 3 difficulty levels... Easy:    There are 4 colored pegs to choose from, the answer is 4 pegs, and player has ten guessesMedium:    There are 5 colored pegs to choose from, the answer still has 4 pegs, and player has 12 guessesHard:    7 colored pegs to choose from, answer has 5 pegs, and player has 15 guessesHow would I implement this into my code? Use big if statements around all the code that depends on difficulty level? How would you handle this?   
  Once the game starts, you don't have three difficulty levels. You have a number of colors, a number of pegs, and a number of guesses. Set those based on the difficulty level, then use them as necessary.   ;  Never played Mastermind, so this is purely from what you said.in pseudo-codeclass MasterMind{    enum Difficulty { Easy, Medium, Hard };    setDifficulty ( Difficulty difficulty )    {   switch ( difficulty )   case Easy:  setPegs ( 4 );  setGuesses ( 10 );   case Medium:  setPegs ( 5 );  setGuesses ( 12 );   // etc.    }    setPegs ( int pegs )    // ...    setGuesses ( int guesses )    // ...    generateBoard()    // use #pegs to create proper board    // etc.};  You just need to set your variables based on the difficulty level before the game starts.  Something like this.if (easy) {    colors = 4;    answer = 4;    guesses = 10;}else if (medium) {    colors = 5;    answer = 4;    guesses = 12;}else {    colors = 7    answer = 5;    guesses = 15}Then your game continues on using those values.   ;Quote:Original post by SneftelOnce the game starts, you don't have three difficulty levels. You have a number of colors, a number of pegs, and a number of guesses. Set those based on the difficulty level, then use them as necessary.Use this.  I know you requested specifics, but Sneftel's response is the right one.   