|
Please HeLp Wid A game of 3 x 3 tic-tac-toe (noughts and crosses) in C++
It is this assignment:
__________________________________________________ _
For this practical assignment you have to implement a game of 3 x 3 tic-tac-toe (noughts and crosses) where a person plays against the computer. You may choose who starts the game.
To find a winning strategy, the computer must be able to look ahead and consider all possibilities of the opponent's move in order to choose its own best move. A game tree of all possible moves is generated and some kind of evaluation function is applied to find the best move. A procedure known as the minimax procedure is used to find good moves. MAX plays against MIN . MAX's best choice is the possibility with the highest positive evaluation while MIN's best one is the possibility with the smallest (that is, the most negative) evaluation. The evaluation e(p) of a position p is given by the following rule:
If p is not a winning position for either player:
• e(p) = (number of complete rows, columns, or diagonals that are still open for MAX) - (number of complete rows, columns, or diagonals that are still open for MIN)
• If p is win for MAX: e(p) = infinity;
• If p is a win for MIN: e(p) = -infinty;
To find the best possible move for MAX (X) if it is MAX's turn to play:
• Consider all possible positions where X can be placed. (level 1)
• For each position of X, consider all possible positions where a O can be placed (level 2)
• Apply the above evaluation function to each node in level 2 and find the lowest value (best for MIN of each group). Pass that value up one level.
• Back up one level and find the highest of the lowest values in level 2.
• Let MAX's move be that possibility
The computer (MAX) now waits for the person (MIN) to play after which the whole process is repeated with the present node as the new first node until a win for MAX is found. If a win for MIN is found (-infinity) that node's children are not evaluated.
__________________________________________----_----------_---_
|