Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop the element type that will represent each board position.Develop the element type that will represent each board position. In addition to representing the state

Develop the element type that will represent each board position.Develop the element type that will represent each board position. In addition to
representing the state of the TicTacToe board, you will also need an integer to store
the evaluation of the position in Step 2.3 below. I recommend something as simple
as the TicTacToePosition shown here. I chose to represent the board as a
String of nine characters, each position either a blank, an 'x' or an 'O'.
The root of your tree will be the blank board. There are 9 children from
here. That is, the human player can select to place their x in any position 0
through 8. Create these children. From there, each of these positions has
at most 8 counter moves for 0. This continues down until there are no
moves left. We will ignore symmetries.
There are at most 9!+dots1!(986,409) board configurations. Our tree will
need to be order 9 and this will result in many empty positions. You should
start your tree out with the capacity set at a staggering 500,000,000 places! This may require more heap memory
than your Java installation is used to. Therefore, you may need to use the option: -xm2048M to increase your
memory usage. Instructions on using this option are dependent on the IDE you use.
To perform this step, you may want to study and adapt the pre-order traversal algorithm. Remember not to
generate moves for positions that are already occupied.
If this is as far as you get, you will want to prove that your solution works. Print out the first 100 positions in the
array. Perhaps you could use code like the following (adapted to any data types/classes you have used). Put this
code in the main method of a class called GenTree.java.
for (int i=0; i100; i++){
TicTacToePosition t= gameTree * get(i);
if (t= null)
System.out.printf("%2d)%s
", i, gameTree.get(i).board);
else
System.out.printf("%2d) Empty
", i);
}
image text in transcribed

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago