[Home]ModeSelection

Robo Home | Changes | Preferences | AllPages

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

Changed: 70c70
I'm currently working on a Modular robot myself - combining (so far) 2 radar modes, 6 aiming strategies and 6 movement patterns. I have a school competition to pit it in on Saturday, afterwards I'll probably stick it up at the repository and fill the Polymorphism gap with it's easily expandable design. -- Kawigi
I'm currently working on a Modular robot myself - combining (so far) 2 radar modes, 6 aiming strategies and 6 movement patterns. I have a school competition to pit it in on Saturday, afterwards I'll probably stick it up at the repository and fill the Polymorphism gap with it's easily expandable design. -- Kawigi

ModeSelection is a way of designing the robot to be modular. Alisdair Owens (Author of Nicator) and I both came up with similar ideas about it when we were at university, however he used interfaces but I use inheritance. Both have advantages & disadvantages, but I will only discuss using inheritance. Both of my bots - Viper? & Warlord - use this coding technique.

Note this technique probably isnt best for bots trying to fit into weight categories.

So whats the idea behind ModeSelection?? Well here are a few points:

Ok, so whats a mode? A mode can be anything that you want your robot to do. For instance, in Warlord I use modes for radar, movement, tracking, and gun. Eg:

For radar we might want the following modes:

Now allready we can see how this might be usefull. In Melee battles we would want to use Sweep every 20 ticks, then use Find to move the radar to our current target, then use Track to keep the radar on the target until its time to sweep again.

So how do we do this? Well the way I do it is to have an abstract class called Mode. Then each mode we want can be a subclass of it:

public abstract class Mode
{
   public Mode() {}
	
   public abstract void update();
   public abstract double getScore();
}

update is called to make the Mode do something (Like it might call setTurnRadarRight(360) in sweep mode). getScore is called by the Manager (see below). The score returned should be the priority of the mode.

So how do we select a mode. Well then what we can have is a class called Manager. This has methods addMode(Mode m), update. So when we intialise our robot we call addMode on the manager with our three modes (Find, Sweep, Track). Then each tick we call update. The manager will then find the mode with the highest priority and call that mode's update method, thus carrying out the modes "wishes".

In the radar case, what we do is in the Sweep getScore method we simply do:

public double getScore()
{
  if(AdvancedRobot.getTime() % 20 == 0) // We want to scan
  {
    bScanning = true;  // We are now scanning
    return 100; // High priority
  }
  else if(bScanning) // If we are currently scanning
  {
    return 50;   // Reasonable priorty - we want to continue our sweep, but can be overidden by other modes if they wish
  }
 
  return 0;  // Not scanning, dont want to scan, let other modes do stuff
}

Thus you can see that its a really powerfull way of doing a bot. The modes can interrupt other modes if they want. You can add a mode easily to a bot (Inherit from Mode, call addMode on the manager).

This is usefull for gun aiming - each mode could use a different algorithm to fire with. The modes return their accuracy as the priority, and the most accurate mode is chosen to fire with.

Well, that turned into a bit of a lecture didnt it! I could go into way more depth, but I think thats enough for now.

Expansion:

Feel free to comment on this, and correct my speling! (Deliberate mistake :D)

-wolfman


I'm currently working on a Modular robot myself - combining (so far) 2 radar modes, 6 aiming strategies and 6 movement patterns. I have a school competition to pit it in on Saturday, afterwards I'll probably stick it up at the repository and fill the Polymorphism gap with it's easily expandable design. -- Kawigi

Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited March 26, 2003 23:18 EST by Tango (diff)
Search: