[Home]History of ModdedBot/Code

Robo Home | Changes | Preferences | AllPages


Revision 2 . . December 6, 2003 3:09 EST by Vuen
Revision 1 . . November 8, 2003 3:59 EST by Vuen
  

Difference (from prior major revision) (no other diffs)

Changed: 1c1
This is the source code to version 1.0 of ModdedBot. It is included within the .jar, which you can obtain here: http://www.robocoderepository.com/BotDetail.jsp?id=1831
This is the source code to version 1.1 of ModdedBot. It is included within the .jar, which you can obtain here: http://www.robocoderepository.com/BotDetail.jsp?id=1831

Changed: 8c8,9
* Last edited on November 7, 2003
* version 1.1
* Last edited on December 5, 2003

Changed: 13,14c14,15
import java.util.Vector;
import java.util.Iterator;
import java.util.*;
import robocode.exception.EventInterruptedException?;

Changed: 29c30
//These? are private variables that hold needed info
//These? are pr ivate variables that hold needed info

Changed: 31c32
private Vector events; //Holds? all robot events
private Vector events; //Holds? all robot events

Removed: 37,38d37



Removed: 74d72


Changed: 77c75
* onBla(BlaEvent?) methods.
* onXXX(XXXEvent) methods.

Changed: 95c93



Changed: 97,99c95,97







Changed: 101c99



Changed: 105c103



Changed: 107,109c105,107







Changed: 111,113c109,111







Changed: 115c113



Changed: 118c116



Changed: 120,122c118,120







Changed: 124,126c122,124







Changed: 129,130c127,128





Added: 131a130,135

//create new RobotDeathEvent?
Event newevent = new RobotDeathEvent?(hit.getName());
//DON'T FORGET to set the priority and time of the event!
newevent.setPriority(getEventPriority?("RobotDeathEvent?"));
newevent.setTime(getTime());

Changed: 133,134c137,138
//create new RobotDeathEvent? and add to fakes
eventsfake.add(new RobotDeathEvent?(hit.getName()));
//add RobotDeathEvent? to eventsfake (NOT events)
eventsfake.add(newevent);

Added: 138a143


Changed: 143,145c148,149






Removed: 148,149d151



Added: 165a168
Collections.sort(events);

Added: 171a175,189
/* These variables handle prioritization. */
private boolean isHandlingEvents? = false;
private int currentEventPriority? = Integer.MIN_VALUE;
private boolean[] interruptible = new boolean[101];
/* This method handles setting interruptibility. Since we hold all blocking
* calls from the robot, we have to handle interruptibility manually.
*/
public void setInterruptible(boolean interruptible) {
init();
if (!isHandlingEvents?) return;
this.interruptible[currentEventPriority?] = interruptible;
}




Changed: 173c191,196
/* This event parses the events and calls the proper event handlers.*/
/* This event parses the events and calls the proper event handlers.
*
* This method is configured to automatically handle interruptibility the
* same way Robocode does. An error is thrown through the robot's event
* handler and caught by ModdedBot to interrupt an event.
*/

Added: 174a198,201
//set this to true. we shouldn't have to worry about setting it false
// again because from then on we always handle events.
isHandlingEvents? = true;


Changed: 177c204
for (int i = 0; i < events.size(); i++) {
while (events.size() > 0) {

Added: 178a206,229
Event event = (Event)events.firstElement();

//since the list is sorted, all events remaining are lower priority
// than the current one, so we cannot interrupt it and so we can
// stop dumping events.
if (event.getPriority() < currentEventPriority?)
break;

//we need to interrupt the current event
if (event.getPriority() == currentEventPriority? && interruptible[currentEventPriority?]) {
interruptible[currentEventPriority?] = false;
throw new EventInterruptedException?(event.getPriority());
}

//we haven't interrupted the current event; since the list is
// sorted, all events after this one will have the same or lower
// priority, so we can stop dumping events.
if (event.getPriority() == currentEventPriority?)
break;

//we can now remove the event from the vector. we remove it after
// interrupting so that we don't remove the event that we
// want to interrupt with!
events.remove(0);

Changed: 181,187c232,280
//If? you have created any of your own custom event classes, add them
// here BEFORE the rest of the events get parsed, and change the
// next line to else if so that any events you have extended won't
// fire twice.

//If? you haven't created any custom event classes, you don't need
// to modify this method.
int oldEventPriority? = currentEventPriority?;
currentEventPriority? = event.getPriority();


try {

//If? you have created any of your own custom event classes, add them
// here BEFORE the rest of the events get parsed, and change the
// next line to else if so that any events you have extended won't
// fire twice.

//If? you haven't created any custom event classes, you don't need
// to modify this method.

if (event instanceof ScannedRobotEvent)
onScannedRobot((ScannedRobotEvent)event);
else if (event instanceof RobotDeathEvent?)
onRobotDeath?((RobotDeathEvent?)event);

else if (event instanceof HitRobotEvent?)
onHitRobot?((HitRobotEvent?)event);
else if (event instanceof HitWallEvent?)
onHitWall?((HitWallEvent?)event);
else if (event instanceof HitByBulletEvent?)
onHitByBullet?((HitByBulletEvent?)event);

else if (event instanceof BulletHitEvent?)
onBulletHit?((BulletHitEvent?)event);
else if (event instanceof BulletMissedEvent?)
onBulletMissed?((BulletMissedEvent?)event);
else if (event instanceof BulletHitBulletEvent?)
onBulletHitBullet?((BulletHitBulletEvent?)event);

else if (event instanceof CustomEvent)
onCustomEvent((CustomEvent)event);
else if (event instanceof SkippedTurnEvent?)
onSkippedTurn((SkippedTurnEvent?)event);
else if (event instanceof WinEvent?)
onWin((WinEvent?)event);
else if (event instanceof DeathEvent?)
onDeath((DeathEvent?)event);
else
printError("Unknown Event!! This event is unhandled: " + event.getClass().getName());


} catch (EventInterruptedException? e) {
//we dropped down the stack, and we resume event dumping with
// the new events vector using the old dump method.
}

Added: 188a282
currentEventPriority? = oldEventPriority?;

Removed: 191,219d284
if (events.get(i) instanceof ScannedRobotEvent)
onScannedRobot((ScannedRobotEvent)events.get(i));
else if (events.get(i) instanceof RobotDeathEvent?)
onRobotDeath?((RobotDeathEvent?)events.get(i));

else if (events.get(i) instanceof HitRobotEvent?)
onHitRobot?((HitRobotEvent?)events.get(i));
else if (events.get(i) instanceof HitWallEvent?)
onHitWall?((HitWallEvent?)events.get(i));
else if (events.get(i) instanceof HitByBulletEvent?)
onHitByBullet?((HitByBulletEvent?)events.get(i));

else if (events.get(i) instanceof BulletHitEvent?)
onBulletHit?((BulletHitEvent?)events.get(i));
else if (events.get(i) instanceof BulletMissedEvent?)
onBulletMissed?((BulletMissedEvent?)events.get(i));
else if (events.get(i) instanceof BulletHitBulletEvent?)
onBulletHitBullet?((BulletHitBulletEvent?)events.get(i));

else if (events.get(i) instanceof CustomEvent)
onCustomEvent((CustomEvent)events.get(i));
else if (events.get(i) instanceof SkippedTurnEvent?)
onSkippedTurn((SkippedTurnEvent?)events.get(i));
else if (events.get(i) instanceof WinEvent?)
onWin((WinEvent?)events.get(i));
else if (events.get(i) instanceof DeathEvent?)
onDeath((DeathEvent?)events.get(i));
else
printError("Unknown Event!! This event is unhandled: " + events.get(i).getClass().getName());

Added: 230a296,297



Added: 249a317,319




Added: 262a333


Changed: 312,314c383,386
//This? is just a debugger method; it will call whenever an error occurs
// within the mod. You can call this or remove this or do whatever you want
// with it; debug your mod however you like.
/* This is just a debugger method; it will call whenever an error occurs
* within the mod. You can call this or remove this or do whatever you want
* with it; debug your mod however you like.
*/

Removed: 321,323d392




Changed: 400c469
</pre>
</pre>

Robo Home | Changes | Preferences | AllPages
Search: