// The DoTurn function is where your code goes. The Game object // contains the state of the game, including information about all planets // and fleets that currently exist. Inside this function, you issue orders // using the game.issueOrder() function. For example, to send 10 ships from // planet 3 to planet 8, you would say game.issueOrder(3, 8, 10). // // There is already a basic strategy in place here. You can use it as a // starting point, or you can throw it out entirely and replace it with // your own. public static void doTurn(Game game) { Planet source = null; Planet dest = null; // (1) If an economic planet have more than 50 ships, send 50 ships to the closest military planet. foreach (Planet p in game.getMyEconomicPlanets()) { int score = p.numShips; if (score > 50) { source = p; dest = game.findClosestMilitaryPlanet(source); if (dest != null) { game.issueOrder(source, dest, 50); } } } // (2) If we currently have more than 2 fleet in flight, just do nothing. if (game.getMyMilitaryFleets().Count() >= 2) { return; } // (3) Find my strongest military planet. source = null; int sourceShips = int.MinValue; foreach (Planet p in game.getMyMilitaryPlanets()) { int score = p.numShips; if (score > sourceShips) { sourceShips = score; source = p; } } // No military planet found, just stop here. if (source == null) { return; } // (4) Find the closest enemy or neutral planet. dest = null; int destDist = int.MaxValue; foreach (Planet p in game.getNotMyPlanets()) { int dist = game.distance(source.id, p.id); if (dist < destDist) { destDist = dist; dest = p; } } // (5) Send all the ships from my strongest planet to the closest // planet that I do not own. if (source != null && dest != null) { int numShips = source.numShips; game.issueOrder(source, dest, numShips); } }
// The DoTurn function is where your code goes. The Game object // contains the state of the game, including information about all planets // and fleets that currently exist. Inside this function, you issue orders // using the game.issueOrder() function. For example, to send 10 ships from // planet 3 to planet 8, you would say game.issueOrder(3, 8, 10). // // There is already a basic strategy in place here. You can use it as a // starting point, or you can throw it out entirely and replace it with // your own. public static void doTurn(Game game) { Planet dest = null; Planet source = null; double destScore = 0; int destFleetShips = 0; bool ennemy = false; List <Planet> cibles = game.getMyWeakPlanets(); if (cibles.Count == 0) { cibles = game.getNotMyIndusPlanets(); ennemy = true; } if ((cibles.Count == 0) || (game.getMyIndusPlanets().Count / game.getMyMilitaryPlanets().Count > 5)) { cibles = game.getNotMyMiliPlanets(); ennemy = true; } foreach (Planet p in cibles) { foreach (Planet s in game.getMyMilitaryPlanets()) { int fleetShips = 10; if (ennemy) { fleetShips += Math.Abs(game.getShipsWithFleet(p)); } int sourceShips = game.getShipsWithFleetAttackOnly(s); int minimumMili = 10 + game.getMyPlanets().Count; //game.getAverageMiliPlanetShips() + 10; //Log.debug("fleetShips=" + fleetShips + " sourceShips=" + sourceShips + " s=" + s.numShips); if ((fleetShips > 0) && (fleetShips < sourceShips / 2) && (sourceShips - fleetShips > minimumMili) && (s.numShips - fleetShips > minimumMili)) { double score = game.getDestScore(p, s); if (score > destScore) { dest = p; destScore = score; destFleetShips = fleetShips; source = s; } } } } //Log.debug("dest: " + dest.id.ToString() + " source " + source.id.ToString()); // 3 On envoie les fleet if (source != null && dest != null) { game.issueOrder(source, dest, destFleetShips); } else { return; } }
// The DoTurn function is where your code goes. The Game object // contains the state of the game, including information about all planets // and fleets that currently exist. Inside this function, you issue orders // using the game.issueOrder() function. For example, to send 10 ships from // planet 3 to planet 8, you would say game.issueOrder(3, 8, 10). // // There is already a basic strategy in place here. You can use it as a // starting point, or you can throw it out entirely and replace it with // your own. public static void doTurn(Game game) { // (1) If we currently have a fleet in flight, just do nothing. if (game.getMyMilitaryFleets().Count() >= 1) { return; } // (2) Find my strongest military planet. Planet source = null; int sourceShips = int.MinValue; foreach (Planet p in game.getMyMilitaryPlanets()) { int score = p.numShips; if (score > sourceShips) { sourceShips = score; source = p; } } if (source == null) { return; } // (3) Find the weakest enemy or neutral planet. Planet dest = null; int destDist = int.MaxValue; foreach (Planet p in game.getNotMyPlanets()) { int dist = game.distance(source.id, p.id); if (dist < destDist) { destDist = dist; dest = p; } } // (4) Send half the ships from my strongest planet to the weakest // planet that I do not own. if (source != null && dest != null) { int numShips = source.numShips / 2; game.issueOrder(source, dest, numShips); } }