Commits

INADA Naoki committed a007eda

他人から遠い vein を選ぶ.

  • Participants
  • Parent commits 0367fcc

Comments (0)

Files changed (1)

File src/net/javachallenge/players/Methane1Player.java

                 System.err.println("Warn: too big squad size.");
                 squadSize = robots;
             }
-            //List<TrianglePoint> route = makeRoute(location, target.getLocation());
-//            List<TrianglePoint> route = location.getShortestPath(target.getLocation());
-//            if (route == null) return;
-            
+            // List<TrianglePoint> route = makeRoute(location,
+            // target.getLocation());
+            // List<TrianglePoint> route =
+            // location.getShortestPath(target.getLocation());
+            // if (route == null) return;
+
             robots -= squadSize;
             commands.add(Commands.launch(squadSize, location, target.getLocation()));
-            //commands.add(Commands.launchWithPath(squadSize, route));
+            // commands.add(Commands.launchWithPath(squadSize, route));
             saveTemporalCommands(commands);
             System.err.println("INFO: Attack from " + location + " to " + target.getLocation() + " with " + squadSize
                     + " robots.");
-            //System.err.println("Route:" + route);
+            // System.err.println("Route:" + route);
         }
 
         public boolean equals(Object other) {
 
     @Override
     public TrianglePoint selectVein(Game game) {
-        TrianglePoint origin;
-        if (firstVein == null) {
-            origin = Make.point(1000, 1000);
-        } else {
-            origin = firstVein.getLocation();
-        }
-
         int gas_ratio = 2;
         int metal_ratio = 3;
 
                 continue;
             }
             int score = 0;
-            // score += -v.getLocation().getDistance(origin) * 12;
+
             score += v.getNumberOfRobots() * 8;
             score += v.getInitialRobotProductivity() * 40;
             switch (v.getMaterial()) {
             default:
                 break;
             }
+            for (Vein ov : game.getField().getVeins()) {
+                if (ov.getOwnerId() == -1)
+                    continue;
+                int d = ov.getDistance(v);
+                if (d < 16) {
+                    score -= 16 - d;
+                    if (d < 10) {
+                        score -= 10 - d;
+                    }
+                    if (d < 6) {
+                        score -= 6 - d;
+                    }
+                }
+                score -= ov.getDistance(v);
+
+            }
             if (score > bestScore) {
                 bestVein = v;
                 bestScore = score;
     private boolean _makeRouteSub(TrianglePoint from, TrianglePoint to, List<TrianglePoint> route, int t) {
         int x = from.getX();
         int y = from.getY();
-        
-        if (from.equals(to)) return true;
+
+        if (from.equals(to))
+            return true;
 
         if (t > 0) {
-            for (Squad s: game.getField().getSquads()) {
+            for (Squad s : game.getField().getSquads()) {
                 int now;
-                TrianglePoint cur=s.getCurrentLocation();
+                TrianglePoint cur = s.getCurrentLocation();
                 List<TrianglePoint> sp = s.getPath();
-                for (now=0; now<sp.size(); ++now) {
+                for (now = 0; now < sp.size(); ++now) {
                     if (sp.get(now).equals(cur)) {
                         break;
                     }
                 }
- //               System.err.println("now="+now+" path="+sp.size() + " t="+t);
+                // System.err.println("now="+now+" path="+sp.size() + " t="+t);
                 if (now + t - 1 < sp.size()) {
-                    if (sp.get(now + t -1).equals(from)) {
+                    if (sp.get(now + t - 1).equals(from)) {
                         System.err.println("Boom: " + from);
                         return false;
                     }
                 }
             }
         }
-        
+
         int dist = from.getDistance(to);
 
-        TrianglePoint next = Make.point(x-1, y);
+        TrianglePoint next = Make.point(x - 1, y);
         if (next.getDistance(to) < dist) {
             route.add(next);
-            if (_makeRouteSub(next, to, route, t+1)) {
+            if (_makeRouteSub(next, to, route, t + 1)) {
                 return true;
             }
-            route.remove(t+1);
+            route.remove(t + 1);
         }
 
-        next = Make.point(x+1, y);
+        next = Make.point(x + 1, y);
         if (next.getDistance(to) < dist) {
             route.add(next);
-            if (_makeRouteSub(next, to, route, t+1)) {
+            if (_makeRouteSub(next, to, route, t + 1)) {
                 return true;
             }
-            route.remove(t+1);
+            route.remove(t + 1);
         }
 
-        if ((x+y) % 2 == 0) {
-        //if (from.isUpwardTriangle()) {
-            next = Make.point(x, y+1);
+        if ((x + y) % 2 == 0) {
+            // if (from.isUpwardTriangle()) {
+            next = Make.point(x, y + 1);
         } else {
-            next = Make.point(x, y-1);
+            next = Make.point(x, y - 1);
         }
         if (next.getDistance(to) < dist) {
             route.add(next);
-            if (_makeRouteSub(next, to, route, t+1)) {
+            if (_makeRouteSub(next, to, route, t + 1)) {
                 return true;
             }
-            route.remove(t+1);
+            route.remove(t + 1);
         }
         return false;
     }
                         }
                         if (s.getOwnerId() == self.getId()) {
                             enemyRobots -= s.getRobot();
-                            if (enemyRobots < 0) enemyRobots = 0;
+                            if (enemyRobots < 0)
+                                enemyRobots = 0;
                         }
                         targetSquads.add(s);
                     }