I have a Connect Four project. There are two parts to the project - the first part was to make the actual working game, which I did. Now my professor has given us some instructions, some of which including:
In this part of the assignment, you will create a Player class that will be a semi-intelligent computer Connect 4 player. You will be provided with a Board class that you must use, without modifying, as part of your project. We will host an in class tournament between the Connect 4 players that you create and the winner will be awarded a prize. The Player class will store a character indicating whether it is playing ‘X’ or ‘O’. The Player class should have standard constructors, accessors and mutators. In addition, you will create the following general functions for the game:
bestMove(int scores [ ]): This function will take an array of 7 scores (one for each possible move the Player is considering) and return the integer index number for the move that the player should make, NOT the score stored there. It should first check to see whether there is a single highest score. If there is, then it should return the index of the highest score (which is equivalent to the move that the player should make). If there is a tie, then it will select one of the top scoring moves and return the index of that move. You can use any heuristic you choose in breaking a tie as long as you document it in your comments. Some simple heuristics are:
Always use the leftmost.
Always use the rightmost.
Randomly select.
I am having a little writer's block here and am unsure of how to start this. The bestMove() function obviously goes in the Player class, but I'm unsure of how to start the bestMove() function. Ideas?
I don't know this game but from your explanation it seems that the bestMove function should search for the maximum in an array of int returning the index. The array might be provided to you by the board class, I don't know.