Programming Assignment 2 for Autonomous Multiagent Systems (G22.3033-012)


 

This assignments assumes the knowledge gained from assignment 1.

For the first assignment, you used the C++ "sampleclient" to allow you to communicate with the simulator by hand. You will now alter that client, or a similar java client, to perform some tasks automatically. In this assignment, you will implement some simple, purely reactive soccer-playing agents.

IMPORTANT: You are permitted to do your programming for this course in either C++ or Java. However, the code C++ fragments you are given in the future will have been written by the instructor, whereas the Java fragments will have been written by someone else. Therefore, you should expect a higher level of support for the C++ code. Choose your language according to your own skills. But if you know both languages equally well, C++ is recommended.

This assignment (and all for this course) is about creating agents. It's not about programming. If you have programming questions/problems, etc. (e.g. "How do I generate a random number in C++?) ask the class list early and often.


Score a goal

The code you will be modifying is in /usr/local/agents/src on the class machines.

C++ instructions:
Copy over the files in the src/c++ subdirectory home directory.
Compile by typing "make".
Run by typing "client" (after starting the server)

Java instructions:
Copy over the files in the src/java subdirectory to your home directory.
Compile by typing "javac client.java".
Run by typing "java client" (after starting the server).

In both cases, you will see the same behavior as last week: agent sensations will be sent to standard input and you can type player commands into the shell.

Looking into the code (client.c or client.java), you will see that this is implemented as 2 separate threads: one for receiving input from the server, and one for receiving input from the shell.

Your task is to alter the code so that the player does the following without any input from the shell:

  • Connect to the server with version 7.0 protocol.
  • Immediately after connecting, it should move to a random place on its side of the field "(move x y)" where -52.5 < x < 0, -34 < y < 34.
  • It should find the ball, go the the ball, find the opponent's goal, "(goal r)" for the left team or "(goal l)" for the right team, and kick the ball towards that goal. The player should decide what to do based only on its latest sight. It should send at most one command after every sight it receives.
  • Hints:
  • The player should send "(init (version 7.0))" at startup. The version is important.
  • The response from the server to the "(init)" command tells which side the player is on.
  • Search for the statement that prints out "recv : " Now rather than printing that out, parse it to find the distance and angle to the ball and/or the relevant goal (if they're in the player's view).
  • Decide on a single action (kick/dash/turn) with appropriate parameters and send them to the server using the "send" (or "send_message") command as is done in the current routine that accepts keyboard input.
  • What to turn in:

  • A logfile of your player scoring 2 goals. After the first goal, left-click somewhere on the field to create a "drop-ball" so that the player can go score again. Name the logfile "score.log"
  • Your modified source code called score.c or score.java with your changes commented prominently with "CHANGE."

  • 1 on 1

    Run the same code, but this time start 2 players: 1 on each team. Turn in a logfile that runs at least until one player scores or 1000 cycles (whichever comes first). If the players get stuck, you can create drop-balls.

    What to turn in:

    A logfile called 1on1.log


    Passing

    Create 2 players on the same team that pass the ball back and forth.

    Hint:

    You may need to make the player back up or go back to a point after getting the ball so that they don't keep running into each other.

    What to turn in:

  • A logfile called pass.log
  • Commented source code called pass.c or pass.java

  • [Back to Department Homepage]

    Page maintained by Peter Stone
    Questions? Send me mail