Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. In this Milestone you will be creating Player classes. You are to submit two different versions. We have provided you a set of Java files to help you get started. As usual you should not change any class or method signatures we have given you. You may add methods to either of your implementations. Below is a description of the files and what your tasks are for MS3. While this MS is not totally dependent on a working Board.java (e.g. you can get a full score without a functional Board.java), it is much more difficult without one. You should ensure that your Board.java passes most of the testcases before you begin (we will open up submissions to test your Board.java after the deadline).
  2. Before you begin work, please read all of the instructions. The recommended order to complete this MS is: HumanPlayer.java, ConnectFour.java, AIPlayer.java
  3.  
  4. Player.java DO NOT MODIFY. This is the Interface that must be implemented by all Players. We did not discuss interfaces in class, but think of it as a compile time check to ensure that all players conform to a certain “interface”. In this case, all Players MUST implement the methods contained here in. The methods that must be implement by all types of players are:
  5. playToken() – returns a column in which to play a token. This must be a valid column (e.g column must exist, and column must not be full)
  6. lastMove(int c) – receives the most recent move from the other player
  7. getPlayerID() – returns the player ID of this player
  8. reset() – cleans up all state and allows the player to begin a new game
  9. HumanPlayer.java This is the representation of a human player. The constructor takes parameters as described in the file. For the HumanPlayer, the methods should do the following:
  10. playToken() – Asks the user for input, returns the column received from the user. In cases of error, re-ask the user for input.
  11. lastMove(int c) – entirely up to you how you want to use this information (hint: you should keep track of where the other player has gone and where you have gone so that you can do adequate error checking in playToken())
  12. getPlayerID() – returns the player ID of this player
  13. reset() – clean up your state and prepare for a new game
  14. ConnectFour.java – FOR YOUR USE ONLY (not graded). Here , we’ve given you the main game loop algorithm. Just fill it in with calls to your Player/Board objects. Create first with two instances of human players, and play the game against yourself/a friend. Ensure things seem to be working correctly. Test, Test, Test. After implementing AIPlayer, you’ll want to replace one of the human players with an AIPlayer and Test again.
  15. AIPlayer.java This is the representation of an Artificial Intelligence Player (computer player). The AI player, at the very least must play valid moves throughout the entire game. Decide what strategy you want your computer player to use when deciding where to place a token. The constructor takes parameters as described in the file. Implement the methods as follows.
  16. playToken() – Decides using whatever strategy you decide, the optimal column to place the token. You should probably make use of all information available to your player… There should never be an instance where you decide to place a token in an invalid column (whether full or out of bounds). You might find Math.random() useful here. Returns the column your AI has chosen.
  17. lastMove(int c) – receives the last move made by the other player. You may want to store this somewhere as it might be useful to you in implementing (a). Hint: sometimes your AI will be the first player. i.e. sometimes, lastMove will be called AFTER playToken() and sometimes before.
  18. getPlayerID() – returns the player ID of this player
  19. reset() – clean up all the state you’ve accumulated this game. Set the AI player up to begin a new game.
  20. Scoring:
  21. HumanPlayer: Asks for user input, does error checking, always plays valid token.
  22. AIPlayer: Must always play valid tokens. Your score will be based on how many valid moves your AI makes. (if all valid, full credit).
  23. For full credit, must do better than our “Dumb AI”. (Our dumb AI basically randomly places tokens all over the board. Even the smallest improvement to random will beat our Dumb AI).
  24. For half credit, must do about as well as our AI. (you can get half credit just for placing random tokens in valid columns).
  25. Lastly, we will hold a contest for best performing AI Connect Four Player! There are no guarantees for prizes. But if there are prizes, they will be guaranteed to be crappy. But you’ll get bragging rights! Details to follow. Stay tuned.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement