http://home.comcast.net/~kokyunage/robocode/communication.jar
The files belong in a package named wiki.team.communication. The version can be obtained by calling String getVersion() on an instance of a Communique implementation. At this point, the version is "Beta 1.0", and there is no JavaDoc? available, but the code examples below should illustrate their usage.
Usage examples:
Sending and Receiving: (these methods exist in my event handling layer)
protected void processAllEvents()
{
Iterator<? extends Event> iterator;
// ...
// TeamRobot does not have a getMessageEvents(), so I process all other events first and what is left is message events
iterator = this.getAllEvents().iterator();
while( iterator.hasNext() )
{
Event e = iterator.next();
if( e instanceof MessageEvent )
{
this.process( (MessageEvent)e );
}
}
this.processTeamMessage( this.communiques );
// ...
}
protected abstract void processTeamMessage( List<Communique> communiques );
public void prepareCommunique( Communique communique )
{
this.communiques.add( communique );
}
public void transmitCommuniques()
{
try
{
this.broadcastMessage( CommuniqueFactory.packageCommuniques( this.communiques ) );
}
catch( IOException ex )
{
ExceptionHandler.handleException( ex );
}
this.communiques.clear();
}
private List<Communique> communiques = new ArrayList<Communique>();
Using Communique data : (these methods exist in my 'foundation' layer, between the event handling and my specific bot (Ugluk, Banzai, etc) ) In the examples below, I haven't really done much to illustrate the larger formats (yet).
protected void processTeamMessage( List<Communique> communiques )
{
Iterator<Communique> iterator = communiques.iterator();
while( iterator.hasNext() )
{
Communique c = iterator.next();
if( c instanceof CommuniquePersonalData ) consoleTick( c.toString() );
else if( c instanceof CommuniqueMyBullet ) consoleTick( c.toString() );
else if( c instanceof CommuniqueEnemyScan ) consoleTick( c.toString() );
else if( c instanceof CommuniqueEnemyWave ) consoleTick( c.toString() );
else if( c instanceof CommuniqueMyRadarTarget )
{
CommuniqueMyRadarTarget mr = ( CommuniqueMyRadarTarget ) c;
System.out.println( c.getSender() + " is scanning " + mr.name );
}
else if( c instanceof CommuniqueMyBulletTarget )
{
CommuniqueMyBulletTarget mb = ( CommuniqueMyBulletTarget ) c;
System.out.println( c.getSender() + " is aiming for " + mb.name );
}
else if( c instanceof CommuniqueSuggestedRadarTarget )
{
CommuniqueSuggestedRadarTarget tr = ( CommuniqueSuggestedRadarTarget ) c;
System.out.println( c.getSender() + " suggests scanning " + tr.name );
}
else if( c instanceof CommuniqueSuggestedBulletTarget )
{
CommuniqueSuggestedBulletTarget tb = ( CommuniqueSuggestedBulletTarget ) c;
System.out.println( c.getSender() + " suggests aiming for " + tb.name );
}
else if( c instanceof CommuniqueOther )
{
CommuniqueOther na = ( CommuniqueOther ) c;
System.out.println( c.getSender() + " says " + na.message );
}
else if( c instanceof CommuniqueNotAvailable )
{
CommuniqueNotAvailable na = ( CommuniqueNotAvailable ) c;
System.out.println( c.getSender() + " tries to communicate " + na.message );
}
else
{
System.out.println( c.getSender() + " fails to communicate." );
}
iterator.remove();
}
}