コード例 #1
0
 public boolean ScanOrganism(Organism o) {
   WorldObject wo;
   try {
     wo = sworld.senseAhead(o);
   } catch (UnsupportedSenseException e) {
     throw new RuntimeException(e);
   }
   if (wo == null) return false;
   return wo.isOrganism();
 }
コード例 #2
0
 public void Mate(MattingOrganism o) {
   WorldObject wo;
   try {
     wo = sworld.senseAhead(o);
   } catch (UnsupportedSenseException e) {
     throw new RuntimeException(e);
   }
   if (wo == null) return;
   if (!wo.isOrganism()) return;
   o.mate(wo.getOrganism());
 }
コード例 #3
0
  public void Attack(AttackingOrganism o) {
    WorldObject wo;
    try {
      wo = sworld.senseAhead(o);
    } catch (UnsupportedSenseException e) {
      throw new RuntimeException(e);
    }
    if (wo == null) return;

    o.attack(wo);
  }
コード例 #4
0
 public double ScanBlue(Organism o) {
   WorldObject wo;
   try {
     wo = sworld.senseAhead(o);
   } catch (UnsupportedSenseException e) {
     throw new RuntimeException(e);
   }
   if (wo == null) return 0;
   if (!wo.isOrganism()) {
     return 0;
   }
   return wo.getOrganism().color(2) / 255;
 }
コード例 #5
0
  public GPSimpleBrainFunctions(World w) {
    if (!(w instanceof MovableWorld))
      throw new InvalidParameterException("Excepted MovableWorld world");
    if (!(w instanceof SensableWorld))
      throw new InvalidParameterException("Excepted SensableWorld world");

    world = w;
    sworld = (SensableWorld) w;
    mworld = (MovableWorld) w;

    if (!sworld.getSenseStyle().contains(SenseStyle.AHEAD))
      throw new InvalidParameterException("Excepted SensableWorld world with SenseStyle.AHEAD");

    if (!mworld.getMoveStyle().contains(MoveStyle.FORWARD))
      throw new InvalidParameterException("Excepted MovableWorld world with MoveStyle.FORWARD");

    if (!mworld.getMoveStyle().contains(MoveStyle.ROTATE))
      throw new InvalidParameterException("Excepted MovableWorld world with MoveStyle.ROTATE");
  }