SlideShare a Scribd company logo
Mastermind design walkthrough
Mastermind design walkthrough
• The main menu has three options
   • New Game – Starts a new game
   • Rules – Shows instructions on how to
      play the game
   • Quit – Closes the application

• This is the page where the user goes if he
  clicks “Main Menu” button which is available
  on the game board
• Number is disabled when
  clicked to have a code with
  non repeating digits

• Enter will be enabled when
  all for digits in the code are
  ready to be entered
Mastermind design walkthrough
MVC architecture used for
     Mastermind
Controller
• The Controller is responsible for the flow of the data transmission
• It consists of the „main‟ method which is responsible for starting the game
• It is responsible for creating the View classes and Model classes
• It maintains instances of the Model classes and invokes various business methods in them;
  in response to user‟s actions which could be either inputting the data or controlling the
  Graphical User Interface (GUI) for displaying the data using View classes

View
• View classes handle the GUI for the user
• The data to be represented will be received from Controller whenever the user inputs new
  information or performs specific actions.
• The received data from Controller will be presented in different elements such as
  Textbox, Label, Button, Table etc. (Some of these widgets can accept input from the user)
• The View is independent from the Model classes; thus, it does not maintain any information
  about the existing classes in the Model.
Model
• The Model is the main component and the heart of the application
• It has classes that will perform majority of the game functionality part
• The contained objects will have different business methods which are related to different business
  events and scenarios that take place in the context of the application
• The master class is the Game class which is a concrete class that will keep track of the player’s turn
  and the outcome of the game
• Display and Processing are separated

• Future enhancements and other maintenance of the code base made very easy and reusable

• Attach multiple views to a model to provide different presentations (view/model decoupling)

• Change the way a view responds to user input without changing its visual presentation”
  (view/controller decoupling)

• All this combined gives GREAT FLEXIBILITY
User enters his secret code
User guesses computer‟s secret code
Computer guesses user‟s secret code
Mastermind design walkthrough
Mastermind design walkthrough
• Used to have flexibility and maintainability
• We can increase the difficulty level in the future by adding concrete classes that use a better version
  of the algorithm for guessing
• New checker functionality can be added when we decide to have a different method of checking for
  feedback (Eg: Giving only feedback when the position as well as the number match and not for
  number only)
• The controller component handles the entire application and the game starts by running the main
  method in the controller component(singleton pattern)
• Only instance of the controller should be used to handle the game application
• Using a singleton pattern to control the creation of Controller class instances helps us in this case
Mastermind design walkthrough
Mastermind design walkthrough
Mastermind design walkthrough
• The algorithm used to play the computer‟s chance is based on the famous five-guess
  algorithm which was developed by Donald Knuth in 1977. The steps involved in
  guessing a code given by the user is as follows:
    1. Create a set S of remaining possibilities (Which is initially 10*9*8*7). Select the first
       possibility from this set and use it as the first guess and get the feedback for this
       guess
    2. Remove all possibilities from S that would not give the same score of black and
       white pegs in the feedback if they were the answer
    3. Select the first possible code from S and use it as the next guess and get the
       feedback.
    4. Go back to step 2 until you have got it right

           This is the only algorithm being used right
          now but we can add various difficulty levels,
         as we are using strategy pattern to implement
                          the algorithm.
1) MVC Pattern:
http://msdn.microsoft.com/en-us/library/ff649643.aspx

2) Mastermind algorithm:
http://en.wikipedia.org/wiki/Mastermind_(board_game)
Mastermind design walkthrough

More Related Content

PDF
Programming Without Coding Technology (PWCT) - Button Control
PDF
Programming Without Coding Technology (PWCT) - Frame control
PPTX
MDS_mod
PDF
Programming Without Coding Technology (PWCT) - Image control
PDF
Programming Without Coding Technology (PWCT) - Treeview control
PDF
Programming Without Coding Technology (PWCT) - Checkbutton control
PDF
Programming Without Coding Technology (PWCT) - Animatebox control
PDF
Programming Without Coding Technology (PWCT) - Grid control
Programming Without Coding Technology (PWCT) - Button Control
Programming Without Coding Technology (PWCT) - Frame control
MDS_mod
Programming Without Coding Technology (PWCT) - Image control
Programming Without Coding Technology (PWCT) - Treeview control
Programming Without Coding Technology (PWCT) - Checkbutton control
Programming Without Coding Technology (PWCT) - Animatebox control
Programming Without Coding Technology (PWCT) - Grid control

What's hot (18)

PDF
Programming Without Coding Technology (PWCT) - Simple GUI Application
PDF
Programming Without Coding Technology (PWCT) - Label Control
PDF
Programming Without Coding Technology (PWCT) - Checkbox control
PDF
Programming Without Coding Technology (PWCT) - Date Picker control
PDF
Programming Without Coding Technology (PWCT) - Progressbar control
PDF
Programming Without Coding Technology (PWCT) - Editbox control
PPTX
Software Development
PDF
Programming Without Coding Technology (PWCT) - Error Handling (Try/Catch)
PDF
Programming Without Coding Technology (PWCT) - Textbox Control
PDF
Programming Without Coding Technology (PWCT) - Hyperlink control
PDF
Programming Without Coding Technology (PWCT) - Timer control
PDF
Programming Without Coding Technology (PWCT) - How to deal with Memo Variables.
PPT
Using macros in microsoft excel part 2
PDF
Programming Without Coding Technology (PWCT) - IF Statement Component
PPTX
Microsoft mathematicsrevised
PDF
Programming Without Coding Technology (PWCT) - The Macro Operator
PPTX
Using macros in microsoft access
PDF
Programming Without Coding Technology (PWCT) - Tab control
Programming Without Coding Technology (PWCT) - Simple GUI Application
Programming Without Coding Technology (PWCT) - Label Control
Programming Without Coding Technology (PWCT) - Checkbox control
Programming Without Coding Technology (PWCT) - Date Picker control
Programming Without Coding Technology (PWCT) - Progressbar control
Programming Without Coding Technology (PWCT) - Editbox control
Software Development
Programming Without Coding Technology (PWCT) - Error Handling (Try/Catch)
Programming Without Coding Technology (PWCT) - Textbox Control
Programming Without Coding Technology (PWCT) - Hyperlink control
Programming Without Coding Technology (PWCT) - Timer control
Programming Without Coding Technology (PWCT) - How to deal with Memo Variables.
Using macros in microsoft excel part 2
Programming Without Coding Technology (PWCT) - IF Statement Component
Microsoft mathematicsrevised
Programming Without Coding Technology (PWCT) - The Macro Operator
Using macros in microsoft access
Programming Without Coding Technology (PWCT) - Tab control
Ad

Similar to Mastermind design walkthrough (20)

PDF
PPT
PDF
mvcExpress training course : part1
PPTX
Software Engineer- A unity 3d Game
PPT
Tyira.ppt
PPTX
Silverlight as a Gaming Platform
PPTX
Evolution Explosion - Final Year Project Presentation
PPT
Design patterns
PDF
Android application - Tic Tac Toe
PPTX
Mvc pattern and implementation in java fair
PDF
Pac Man: Game Development using PDA and OOP
PDF
Design Patterns Summer Course 2009-2010 - Session#1
PPTX
Software Craftsmanship and Agile Code Games
PPTX
Design Patterns Summer Course 2010-2011 - Session#1
PPT
lecture10-patterns.ppt
PPT
lecture10-patterns.ppt
PPTX
06 fse design
PPS
Vp all slides
PPTX
Design process and concepts
mvcExpress training course : part1
Software Engineer- A unity 3d Game
Tyira.ppt
Silverlight as a Gaming Platform
Evolution Explosion - Final Year Project Presentation
Design patterns
Android application - Tic Tac Toe
Mvc pattern and implementation in java fair
Pac Man: Game Development using PDA and OOP
Design Patterns Summer Course 2009-2010 - Session#1
Software Craftsmanship and Agile Code Games
Design Patterns Summer Course 2010-2011 - Session#1
lecture10-patterns.ppt
lecture10-patterns.ppt
06 fse design
Vp all slides
Design process and concepts
Ad

Mastermind design walkthrough

  • 3. • The main menu has three options • New Game – Starts a new game • Rules – Shows instructions on how to play the game • Quit – Closes the application • This is the page where the user goes if he clicks “Main Menu” button which is available on the game board
  • 4. • Number is disabled when clicked to have a code with non repeating digits • Enter will be enabled when all for digits in the code are ready to be entered
  • 6. MVC architecture used for Mastermind
  • 7. Controller • The Controller is responsible for the flow of the data transmission • It consists of the „main‟ method which is responsible for starting the game • It is responsible for creating the View classes and Model classes • It maintains instances of the Model classes and invokes various business methods in them; in response to user‟s actions which could be either inputting the data or controlling the Graphical User Interface (GUI) for displaying the data using View classes View • View classes handle the GUI for the user • The data to be represented will be received from Controller whenever the user inputs new information or performs specific actions. • The received data from Controller will be presented in different elements such as Textbox, Label, Button, Table etc. (Some of these widgets can accept input from the user) • The View is independent from the Model classes; thus, it does not maintain any information about the existing classes in the Model.
  • 8. Model • The Model is the main component and the heart of the application • It has classes that will perform majority of the game functionality part • The contained objects will have different business methods which are related to different business events and scenarios that take place in the context of the application • The master class is the Game class which is a concrete class that will keep track of the player’s turn and the outcome of the game
  • 9. • Display and Processing are separated • Future enhancements and other maintenance of the code base made very easy and reusable • Attach multiple views to a model to provide different presentations (view/model decoupling) • Change the way a view responds to user input without changing its visual presentation” (view/controller decoupling) • All this combined gives GREAT FLEXIBILITY
  • 10. User enters his secret code
  • 15. • Used to have flexibility and maintainability • We can increase the difficulty level in the future by adding concrete classes that use a better version of the algorithm for guessing • New checker functionality can be added when we decide to have a different method of checking for feedback (Eg: Giving only feedback when the position as well as the number match and not for number only)
  • 16. • The controller component handles the entire application and the game starts by running the main method in the controller component(singleton pattern) • Only instance of the controller should be used to handle the game application • Using a singleton pattern to control the creation of Controller class instances helps us in this case
  • 20. • The algorithm used to play the computer‟s chance is based on the famous five-guess algorithm which was developed by Donald Knuth in 1977. The steps involved in guessing a code given by the user is as follows: 1. Create a set S of remaining possibilities (Which is initially 10*9*8*7). Select the first possibility from this set and use it as the first guess and get the feedback for this guess 2. Remove all possibilities from S that would not give the same score of black and white pegs in the feedback if they were the answer 3. Select the first possible code from S and use it as the next guess and get the feedback. 4. Go back to step 2 until you have got it right This is the only algorithm being used right now but we can add various difficulty levels, as we are using strategy pattern to implement the algorithm.
  • 21. 1) MVC Pattern: http://msdn.microsoft.com/en-us/library/ff649643.aspx 2) Mastermind algorithm: http://en.wikipedia.org/wiki/Mastermind_(board_game)