Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm kind of confused on how state design patterns work with implementing this AI MasterMindState: State Design Pattern You need to be able to switch

I'm kind of confused on how state design patterns work with implementing this AI

MasterMindState: State Design Pattern

You need to be able to switch back and forth between a human player and a computer player. This is readily accomplished using the MasterMindState interface:

public interface MasterMindState { public void mouseClicked(int x_click, int y_click); } 

The four integers (0, 1, 2, 3) at the bottom right of the GUI allow the user to switch between human player mode (0) and AI mode (1, 2, or 3 for each of three different AI strategies). If the human player is active, then the current state of MasterMind is set to MasterMindPlayerState where mouse clicks are examined to see if a color has been clicked on, and, if so, the color is added to the Guess. Further, if the human player is not in the middle of selecting four colors for a Guess, the mouse click is checked to see if the current state should be switched to MasterMindAIState. A similar procedure is required when the current state is MasterMindAIState. Mouse clicks are examined to see if the user wants to switch to human player mode. Otherwise, the mouse click indicates that the AI should make another Guess.

MasterMindAIState also stores the different AIs in an array of type MasterMindAI. Let MasterMindRandom be the default AI. Eventually, you will add the more complex AIs described next. The user will be able to switch between AIs by MasterMindAIState using a different AI to make the nextGuess decision.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Design a job advertisement.

Answered: 1 week ago