# CRaPI Framework #
« by Team Yaffa »

# Navigation:
 » Home
 » Articles
 » Download
 » Documentation
 » Project page on SF
 » About
# Mailinglist
  » Releases
# Links:
 » RoboCup
 » RoboCup simulator
 
SourceForge.net Logo
# CRaPI manual:

¤ Wednesday, January 8, 2003

Introduction

CRaPI - Correct, Robust and Perfect API for simulated Robocup - is a framework for development of teams in the Robocup simulated league. The framework is event driven, not bound to any specific agent architecture and works with soccer server 9.x. The programming language is C#.

Set up

1. Download the CRaPI package from our download section.
2. Unzip the CRaPI package to optional location, preferably to [<your project>\].
3. Start up your robocup project or create a new C# project.
4. Add crapi.dll as a reference to your project.

CRaPI is ready for use.

How to use CRaPI

For more examples on how to use CRaPI, download the Tiro player from our download section.

Players

A requirement in Robocup is that all players in a team are autonomous, i.e. no central control is allowed. Players are only allowed to coordinate with visual and audial means, via the server. The first thing your have to do when creating a robocup player with CRaPI is therefore to create a new Thread for each Player in CRaPI. Player is the main class of the CRaPI, and acts as the developers access point to the api. The following code is an example of how to create a thread for a player;

mPlayerThread = new Thread(new ThreadStart(mPlayer.PlayGame));

Events

The architecture of CRaPI is event-driven. It is up to the developer to select the events of interest to act on. The following code is an example of how to register on an event;

mPlayer.AfterNewCycle += new TimeEventHandler(newCycle);

The following events in the Player class of CRaPI are available:

Event

Description

BeforeNewCycle

Indicating that a new cycle is coming once the clock has been syncronized

AfterNewCycle

Indicating that a new cycle has started

BeforeWorldModelUpdate

Indicating that the WorldModel is to be updated

AfterWorldModelUpdate

Indicating that the WorldModel is updated

BeforeRefereeMessage

Indicating that a RefereeMessage is to be handled

AfterRefereeMessage

Indicating that a RefereeMessage has been handled

BeforeCoachMessage

Indicating that a CoachMessage is to be handled

AfterCoachMessage

Indicating that a CoachMessage has been handled

BeforePlayerMessage

Indicating that a PlayerMessage is to be handled

AfterPlayerMessage

Indicating that a PlayerMessage has been handled

Acting

Since the game is run in descreete cycles, the easiest way to act is to listen to the AfterNewCycle event which is fired each cycle. Acting is performed by placing Command objects in the CommandQueue in Player. When satisfied with the Commands in the queue you call the Send() method in Player to send the commands to the server, preferably before a new cycle has started. In code this could look like;

private void newCycle(object sender, TimeEventArgs arg)
{
   mPlayer.CommandQueue.Enqueue(aCommand);
   mPlayer.Send();
}