Commits

INADA Naoki committed 005a563

他の squad を避けて攻撃する.

Comments (0)

Files changed (1)

src/net/javachallenge/players/Methane1Player.java

             return false;
         }
 
-        void attack(Vein target, int squadSize) {
+        void attack(Vein target, int squadSize, boolean force) {
             if (squadSize > robots) {
                 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) {
+                 if (force) {
+                     commands.add(Commands.launch(squadSize, location, target.getLocation()));
+                     saveTemporalCommands(commands);
+                     return;
+                 }
+                 else return;
+             }
 
             robots -= squadSize;
             commands.add(Commands.launch(squadSize, location, target.getLocation()));
         } else {
             defence *= game.getRound();
         }
-        defence /= 200 * veins;
-        defence += 4;
+        defence /= 100 * veins;
+        defence += 5;
 
         // defence = (int)(defence * (1.0 + ((double) game.getRound() / 200.0 -
         // 0.5)) / veins);
                 if (enemyId != game.getNeutralPlayerId()) {
                     enemyRobots += (dist - t) * enemyVein.getCurrentRobotProductivity();
                 }
-                enemyRobots += dist;
+                enemyRobots += (dist/2);
 
                 // ターゲットの周辺の敵基地の強さを勘案する. 取ってすぐ取り返されるなら最初から取らない.
                 if (turn > 4 || dist > 6 || enemyVein.getOwnerId() == game.getNeutralPlayerId()) {
 
                 if (vein.emerge && enemyRobots < vein.robots) {
                     targetted.add(loc);
-                    vein.attack(enemyVein, vein.robots);
+                    vein.attack(enemyVein, vein.robots, false);
                     break;
                 }
                 if (enemyRobots + def2 < vein.robots) {
                     targetted.add(loc);
                     int squadSize = vein.robots - def2;
-                    vein.attack(enemyVein, squadSize);
+                    vein.attack(enemyVein, squadSize, false);
                     break;
                 }
             }
                         System.err.println("Move to friend: from=" + vein.location + " to=" + nearVein.location
                                 + " robots=" + vein.robots + " mindist=" + mindist + " defence=" + defence
                                 + " distBonus=" + distBonus + "squad=" + squadSize);
-                        vein.attack(nearVein.vein, vein.robots - defence + distBonus);
+                        vein.attack(nearVein.vein, vein.robots - defence + distBonus, true);
                         break;
                     }
                 }
 
             if (vein.emerge && vein.robots > 0) {
                 System.err.println("WARNING! WARNING! WARNING!");
-                vein.attack(vein.nearFriends().get(0).vein, vein.robots);
+                vein.attack(vein.nearFriends().get(0).vein, vein.robots, true);
             }
         }
     }