Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a graphical tic-tac-toe program in which a human player can play an AI player, two human players can play each other or two AI

Implement a graphical tic-tac-toe program in which a human player can play an AI player, two human players can play each other or two AI players can play each other.

In this version of tic-tac-toe the board is a five by five grid and four contiguous X's or O's in a line constitute a win. (That means there are 28 ways to win.) Also, to make the matches more interesting, every game should start with 2, 4, 6 or 8 randomly chosen squares pre-occupied by 'X's and 'O's. The pre-filled squares should have the same number of X's and O's.

Implement a Player class to represent each player and to store the player's name , current score, status (X or O) along with a reference to the shared Board object. Player should also have a move method (possibly abstract) to get the player's next move (probably just a square number). Player will have two subclasses Human and AI which both override the move method. The human move method will get a legal square number from the user. The AI move method will return a square number based on a recursive algorithm (see below).

Additionally there should be a Board class to store the current board, the number of squares occupied (0 to 25) etc along with methods to determine whether X or O has a win etc.

Finally you'll implement a TicTacToe class to manage the game and serve as the graphical front end (e.g. via an applet or JFrame) . TicTacToe will include references to each player (via instance variables of type Player) and a reference to the current board object.

The AI version of move should incorporate recursive lookahead to find the best move. See BB and the exercises posted under TicTacToe on MyProgrammingLab to see how this can work. (In those exercises the recursion is "unwound" in the form of several methods with similar names that call each other in a chain.)

Your AI player should play at a level equal to or above that of an average human player. For example, it should usually beat or tie someone who is playing 5-by-5 Tic Tac Toe for the first few times. It should do that without taking an unreasonable time to move. A reasonable time should never be more than 3 minutes per move and usually much less.

In java please

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_2

Step: 3

blur-text-image_3

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago