CS378: Autonomous Multiagent Systems -- Fall 2002: Programming Assignment 2

Programming Assignment 2 for Autonomous Multiagent Systems (cs378)


This assignments assumes the knowledge gained from assignment 1.

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

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 /projects/cs378.pstone/sampleclient.

Copy over the files in the sampleclient directory.
Compile by typing "make".
Run by typing "./client" (after starting the server)

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), you will see that it uses select() to read from multiple input streams: 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 8.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 8.0))" at startup. The version is important.
  • The response from the server to the "(init)" command tells which side the player is on: (init [l/r]...) where "l" means left side, "r" means right side.
  • Search for the statement that starts printf( "recv. Rather than printing out the sensation, 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.
  • Beware of altering the socket protocol in the client. The protocol implemented by the sampleclient is as follows: the init message is sent to the server on port 6000. The server replies on a different port, and all subsequent messages are to be sent to that port.
  • By default, a player is not allowed to kick the ball twice in a row on a kick_off. You ccan get around this by starting the game with a drop ball. Or, you can turn off this rule in the simulator for this part of the assignment. To do so, copy over /projects/cs378.pstone/rcsoccersim-8.05.10/install/bin/.rcssserver-server.conf into your home directory:
    % cp /projects/cs378.pstone/rcsoccersim-8.05.10/install/bin/.rcssserver-server.conf ~/
    and change the line
    free_kick_faults        : on
    free_kick_faults        : off
  • 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 "[yourlogin]-score.log"
  • Your modified source code called [yourlogin]-score.c 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 [yourlogin]-1on1.log


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


  • 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.
  • You may find it helpful to turn off the offsides rule in the simulator for this part of the assignment. To do so, change the use_offside line in your lcoal copy of .rcssserver-server.conf (as described above): change the line
    use_offside: on
    use_offside: off
  • What to turn in:

  • A logfile called [yourlogin]-pass.log
  • Commented source code called [yourlogin]-pass.c.

  • [Back to Department Homepage]

    Page maintained by Peter Stone
    Questions? Send me mail