Assignment 4


In this assignment, we will take the agent theme to a new and interesting level by introducing a "game" aspect to the simulation. Essentially, two players will own agents (pieces) and play a game. Here are the details of the game:

In terms of programming, the following points will help you get started:

To get started:

  1. Download the jar-file, unpack it and compile the source files.
  2. Run GameGui. This will bring up a frame with a menu. One of these lets you run a "demo" in which you can observe the default implementations battle it out.
  3. Now see what happens if you play the house as Player 2 (That is, you are Player 2, and the house is Player 1). You will get prompted for the name of your class file, so type "beavis2" without the quotes (if your username is beavis2.)
  4. Important: You need to name your Java files carefully. If your username is beavis then your Player 1 source file should be called beavis1.java and your Player 2 source file should be called beavis2.java.
  5. Next, your player files need to contain public classes by those names and only one class in each file. Thus, the file beavis1.java will have a public class called beavis1 and no other classes. Similarly, the file beavis2.java will have a public class called beavis2 and no other classes. So, all your code needs to be in these player classes.
  6. Important: your player classes must implement the interface Player provided to you in the file Player.java.
  7. All you really need to do is implement the two methods (with the exact same signatures!) in the interface. Via the methods, you will get a chance to decide where you want to place your agents on the start row and, when the game proceeds, you get a chance to decide where to move agents.
  8. The simulator will call your getInitialPosition() method repeatedly to ask you where you want the agents initially placed. It will check to make sure that you use a legal start position.
  9. After the game starts, the simulator will call your move() method and expect to get back three things (all three of which are returned in a Position instance. These three things are: (1) which agent are you going to move; (2) The X value of the desired position; and (3) the Y value of the desired position. Again, the simulator will check to make sure the move is legal, i.e., it will check to see if the cell is vacant, if your agent can actually move there etc.
  10. If you discover you cannot move, you should return null.
  11. Important: Any illegal move will cost you the game.
  12. All the Java documentation you need is provided here:
  13. To discover positions of agents on the board (which is maintained by the simulator), call the static getAgentID() method of the class Game. Do NOT create an instance of Game.
  14. OK, now implement your players!

Deliverables:

Submission: