Example #1
0
  PlayerAction AI_beta() {
    MapInfo mi = env.getMapInfo();
    Point p = env.getPlayerInfo().getLocation();
    CharaInfo pi = env.getPlayerInfo();
    //		if (mi.getNeedingSpellCount(env.getPlayerInfo(), p) == 0) {
    SpellPos minSpellPos = null;

    if (pumpkinX) {
      List<PumpkinInfo> plist = env.getEnemyInfo().getPumpkinInfos();
      for (PumpkinInfo pinfo : plist) {
        Point pp = pinfo.getCenterLocation();
        int point;
        if (pinfo.getType() == PumpkinType.KingPumpkin) point = 50;
        else point = 20;
        SpellPos nsp = new SpellPos(pp, -point);
        minSpellPos = min(minSpellPos, nsp);
      }

      //			List<Point> plist2 = PumpkinType.MiniPumpkin.getMineLocations();
      //			debug(plist2.toArray());
      //			for (Point pp : plist2) {
      //				SpellPos nsp = new SpellPos(pp, -20);
      //				//				if (minSpellPos == null)
      //				//					minSpellPos = nsp;
      //				//				if (minSpellPos.compareTo(nsp) > 0)
      //				//					minSpellPos = nsp;
      //				//				if (minSpellPos.compareTo(nsp) == 0 && Math.random() < 0.5)
      //				//					minSpellPos = nsp;
      //				minSpellPos = min(minSpellPos, nsp);
      //			}
    }

    for (int i = 0; i < mi.getWidth(); i++) {
      for (int j = 0; j < mi.getHeight(); j++) {
        Point pp = new Point(i, j);
        if (mi.getNeedingSpellCount(pi, pp) > 0) {
          SpellPos nsp = new SpellPos(pp, ((i + j + 1) % 2) * 400);
          minSpellPos = min(minSpellPos, nsp);
        }

        if (pampkinMakable(pp)) {
          SpellPos nsp = new SpellPos(pp, -20);
          minSpellPos = min(minSpellPos, nsp);
        }
      }
    }
    if (minSpellPos == null) return PlayerAction.NONE;
    if (minSpellPos.ds.length == 0) return PlayerAction.SPELL;
    return minSpellPos.ds[0].toPlayerAction();
    //		} else {
    //			return PlayerAction.SPELL;
    //		}
  }
Example #2
0
 ArrayList<Point> getPPos() {
   MapInfo mi = env.getMapInfo();
   ArrayList<Point> r = new ArrayList<Point>();
   for (int i = 1; i < mi.getWidth() - 1; i++) {
     for (int j = 1; j < mi.getHeight() - 1; j++) {
       if (isWritable(new Point(i, j))
           && isWritable(new Point(i, j - 1))
           && isWritable(new Point(i, j + 1))
           && isWritable(new Point(i - 1, j))
           && isWritable(new Point(i + 1, j))) {
         r.add(new Point(i, j));
       }
     }
   }
   return r;
 }