private BoardStatus GetBoardStatus(IPirateGame game) { Pirate pirate = game.MyPirates()[0]; game.Debug("pirate: " + pirate.Id); Treasure treasure = game.Treasures()[0]; game.Debug("treasure: " + treasure.Id); return(new BoardStatus() { Pirate = pirate, Treasure = treasure }); }
public void DoTurn(IPirateGame state) { // Initing stuff List <Island> islands = state.NotMyIslands(); List <Pirate> myPirates = state.MyPirates(); List <Pirate> copyPirates = new List <Pirate>(myPirates); Dictionary <Pirate, Island> pirateToIsland = new Dictionary <Pirate, Island>(); for (int i = 0; i < islands.Count; i++) { Pirate closestPirate = GetClosestPirate(state, islands[i], myPirates); //state.Debug($"closest: {closestPirate.Id.ToString()} to island: {islands[i]}"); if (closestPirate != null) { myPirates.Remove(closestPirate); pirateToIsland.Add(closestPirate, islands[i]); } } copyPirates.ForEach(pirate => { if (pirateToIsland.ContainsKey(pirate) && pirateToIsland[pirate] != null) { Island island = pirateToIsland[pirate]; state.Debug($"Pirate {pirate.Id.ToString()} to island {island.Id.ToString()}"); List <Direction> movingDirections = state.GetDirections(pirate, island); if (movingDirections.Count > 0 && !pirate.IsLost) { state.Debug($"Pirate: {pirate.Id.ToString()}"); movingDirections.ForEach(direc => { state.Debug($"{direc}"); }); state.SetSail(pirate, movingDirections[0]); } } else // Bot that has no island { state.Debug($"Nothing {pirate.Id.ToString()}"); Island closestIsland = GetClosestIsland(state, pirate, state.NotMyIslands()); if (closestIsland != null) { List <Direction> movingDirections = state.GetDirections(pirate, closestIsland); state.SetSail(pirate, movingDirections[0]); } } }); }
private BoardStatus GetBoardStatus(IPirateGame game) { Pirate pirate = game.MyPirates()[0]; game.Debug("pirate: " + pirate.Id); Treasure treasure = game.Treasures()[0]; game.Debug("treasure: " + treasure.Id); Script script = GetAvailableScript(game); return(new BoardStatus() { Pirate = pirate, Treasure = treasure, Script = script }); }
public static void doAttacks(IPirateGame game, bool deadMap) { if (shot != null) { game.Debug("can only call doAttacks(IPirateGame) once per turn!"); return; } shot = new List <Pirate>(); foreach (Pirate p in targetMap.Keys) { foreach (PirateContainer c in targetMap[p]) { game.Debug(p.Id + " --> " + c.P.Id); } } for (int i = 1; i <= game.AllMyPirates().Count&& targetMap.Keys.Count > 0; i++) { List <Pirate> removed = new List <Pirate>(); foreach (Pirate p in targetMap.Keys) { if (targetMap[p].Count == i && p.DefenseExpirationTurns == 0 && (!deadMap || p.HasTreasure)) { PirateContainer pc = targetMap[p][0]; pc.attack(p, game); removed.Add(p); foreach (Pirate k in targetMap.Keys) { targetMap[k].Remove(pc); } } } foreach (Pirate p in removed) { targetMap.Remove(p); } } /*for (int i = 0; i < queued.Count; i++) * { * if (queued[i].E.Count == 1 && !shot.Contains(queued[i].E[0])) * { * queued[i].P.attack(queued[i].E[0], game);// TODO: if kamikaze, and my target, ignore it * shot.Add(queued[i].E[0]); * } * }*/ }
private void locatePowerups(IPirateGame game, int ships, ref PirateContainer[] ps, ref int[] ds, ref Powerup[] pu) { for (int i = 0; i < ships; i++) { //if (game.GetMyPirate(i).HasTreasure) //break; ps[i] = new PirateContainer(game.GetMyPirate(i), (i % 2) == 1); ds[i] = int.MaxValue; foreach (Powerup p in pu) { if (p == null) { break; } //game.Debug("here is the prub: " + i + " - " + p); int d = game.Distance(ps[i].P.Location, p.Location); if (d < ds[i]) { ds[i] = d; pu[i] = p; game.Debug("Powerup found in distance " + d + " for ship " + i); } } } } // calculates the closest powerups to ps[i]
} // calculates the closest powerups to ps[i] // can we move the given Pirate to the given Location according to the number of moves? // if so --> move it! private static int move(PirateContainer p, Location t, int moves, IPirateGame game, bool dontHitEnemies = false) { if (moves == 0 || (!p.AVALIBLE && p.S != PirateContainer.State.moved) || p.P.Location.Equals(t)) { return(0); } var X = from l in game.GetSailOptions(p.P, t, moves) where (!QueuedMotion.isOccupied(l, game, dontHitEnemies) && p.move1(l, game, moves)) select l; if (X.Count() > 0) { PirateContainer.free.Remove(p); Location loc = X.ElementAt(rand.Next(X.Count())); game.SetSail(p.P, loc); new QueuedMotion(p.P, loc); return(game.Distance(p.P, loc)); } game.Debug("Failed to find a move for " + p.P.Id + " to " + t); return(0); }
public bool move1(Location l, IPirateGame game, int remaining) { if (s != State.none && s != State.treasure && s != State.moved) { game.Debug("State on Pirate " + P.Id + " cannot shift from " + s.ToString() + " to moved!"); return(false); } int d = game.Distance(P, l); if (d > remaining || (P.HasTreasure && d > P.CarryTreasureSpeed)) { game.Debug("Pirate " + P.Id + " cannot move, not enough moves!"); return(false); } s = State.moved; return(true); }
public bool defend(IPirateGame game) { if (s != State.none) { game.Debug("State on Pirate " + P.Id + " cannot shift from " + s.ToString() + " to defended!"); return(false); } if (P.ReloadTurns > 0) { game.Debug("Pirate " + P.Id + " cannot defend, no ammo!"); return(false); } free.Remove(this); s = State.defended; game.Defend(P); return(true); }
public bool attack(Pirate p, IPirateGame game) { if (s != State.none) { game.Debug("State on Pirate " + P.Id + " cannot shift from " + s.ToString() + " to attacked!"); return(false); } if (P.ReloadTurns > 0) { game.Debug("Pirate " + P.Id + " cannot attack, no ammo!"); return(false); } free.Remove(this); s = State.attacked; game.Attack(P, p); return(true); }
public bool move(Location l, IPirateGame game) { if (s != State.none && s != State.treasure) { game.Debug("State on Pirate " + P.Id + " cannot shift from " + s.ToString() + " to moved!"); return(false); } int d = game.Distance(P, l); if (d > remainingMoves || (P.HasTreasure && d > 1)) { game.Debug("Pirate " + P.Id + " cannot move, not enough moves!"); return(false); } free.Remove(this); s = State.moved; game.SetSail(P, l); new QueuedMotion(P, l); return(true); }
private static bool move(Pirate p, Location t, int moves, IPirateGame game) { foreach (Location l in game.GetSailOptions(p, t, moves)) { if (!game.IsOccupied(l)) { game.SetSail(p, l); return(true); } } game.Debug("Failed to find a move for " + p.Id); return(false); }
private void chooseMap(IPirateGame game) { string ts = ""; foreach (Treasure t in game.Treasures()) { ts += t.ToString(); } int map = string.Format("{0}{1}{2}{3}", new object[] { game.Treasures().Count, ts, game.GetRows(), game.GetCols() }).GetHashCode(); game.Debug("Map: " + map); Location l = new Location(1, 1); deadMap = (game.Treasures().Count == 1 && game.AllMyPirates().Count == game.AllEnemyPirates().Count); if (map == -918018829 || game.Treasures().Count < 2) { deadMap = true; } if (!deadMap) { rand = new Random(101010); //79409223);//12486534 } else { rand = new Random(12486534); } game.Debug((deadMap ? "Loaded deadmap config" : "Not the deadmap")); if (map == 1512814401 || deadMap) { throw new Exception("First turn skipped"); } } //chooses map
public int DoTurn(IPirateGame game) { var pirates = game.MyPirates().Where(pirate => pirate.Id % 2 == 0).ToArray(); if (game.GetTurn() < 10) game.Debug(game.GetAttackRadius().ToString()); var firingPirates = new HashSet<Pirate>(); var firedUponTargets = new HashSet<Pirate>(); var shootingTuples = from pirate in pirates from enemy in game.EnemyPiratesWithTreasures() where pirate.ReloadTurns == 0 where pirate.TurnsToSober == 0 where enemy.TurnsToSober == 0 where game.Distance(pirate, enemy) <= 4 select new { Pirate = pirate, Target = enemy }; if (shootingTuples.Any()) { foreach (var shootingTuple in shootingTuples) { if (!firingPirates.Contains(shootingTuple.Pirate) && !firedUponTargets.Contains(shootingTuple.Target)) { firingPirates.Add(shootingTuple.Pirate); firedUponTargets.Add(shootingTuple.Target); game.Attack(shootingTuple.Pirate, shootingTuple.Target); } } } var piratesAndEnemies = pirates.Except(firingPirates).Select(pirate => Tuple.Create(pirate, game.GetEnemyPirate(pirate.Id))).ToList(); if (piratesAndEnemies.Any()) { // if any pirate needs to move, move only the first pirate var movingTuple = piratesAndEnemies.Where(pair => game.Distance(pair.Item1, pair.Item2.InitialLocation) > 2).FirstOrDefault(); if (movingTuple != null) { var movingPirate = movingTuple.Item1; var enemyHomeBase = movingTuple.Item2.InitialLocation; var sailOptions = game.GetSailOptions(movingPirate, enemyHomeBase, Math.Min(4, game.Distance(movingPirate, enemyHomeBase) - 2)); game.SetSail(movingPirate, sailOptions[random.Next(sailOptions.Count)]); } } }
// can we move the given Pirate to the given Location according to the number of moves? // if so --> move it! private static int move(PirateContainer p, Location t, int moves, IPirateGame game, bool dontHitEnemies = false) { if (moves == 0 || !p.AVALIBLE || p.P.Location.Equals(t)) { return(0); } // calculate the best route foreach (Location l in game.GetSailOptions(p.P, t, moves)) { if (!QueuedMotion.isOccupied(l, game, dontHitEnemies) && p.move(l, game)) { return(game.Distance(p.P, l)); } } game.Debug("Failed to find a move for " + p.P.Id + " to " + t); return(0); }
// can we move the given Pirate to the given Location according to the number of moves? // if so --> move it! private static int move(PirateContainer p, Location t, int moves, IPirateGame game, bool dontHitEnemies = false) { if (moves == 0 || !p.AVALIBLE || p.P.Location.Equals(t)) { return(0); } // calculate the best route /*foreach (Location l in game.GetSailOptions(p.P, t, moves)) * { * if (!QueuedMotion.isOccupied(l, game, dontHitEnemies) && p.move(l, game)) * return game.Distance(p.P, l); * }*/ var X = from l in game.GetSailOptions(p.P, t, moves) where (!QueuedMotion.isOccupied(l, game, dontHitEnemies) && p.move1(l, game)) select l; if (X.Count() > 0) { PirateContainer.free.Remove(p); Location loc = X.ElementAt(rand.Next(X.Count())); game.SetSail(p.P, loc); new QueuedMotion(p.P, loc); return(game.Distance(p.P, loc)); } else if (X.Count() == 0) { if (PirateContainer.GetRemainingMoves() > 2) { Location loc = p.P.Location; p.move(loc, game); } } game.Debug("Failed to find a move for " + p.P.Id + " to " + t); return(0); }
private void DotCollectTurn(IPirateGame game) { var firstPirate = game.MyPirates().First(p => p.Id == 1); var secondPirate = game.MyPirates().First(p => p.Id == 3); var firstCandidate = GetCandidate(game, firstPirate); var secondCadidate = GetCandidate(game, secondPirate); game.Debug("First {0} Second {1}", firstPirate.HasTreasure, secondPirate.HasTreasure); if (!firstPirate.HasTreasure && !secondPirate.HasTreasure) { game.Debug("Move Fast"); var candiate = firstCandidate.Distance <= secondCadidate.Distance ? firstCandidate : secondCadidate; MoveToTreasure(game, candiate, 2); } else { game.Debug("Move Slow"); MovePirateSlow(game, firstCandidate); MovePirateSlow(game, secondCadidate); } }
public void DoTurn(IPirateGame game) { if (game.GetTurn() == 1) { int s = 891; //DateTime.Now.Millisecond; rand = new Random(s); game.Debug("seed: " + s); } try { this.game = game; turns = game.GetActionsPerTurn(); CheckBase(); StopEnemies(); ManagePlayZero(); } catch (Exception e) { game.Debug(e.ToString()); } }
//////////Methods////////// /// <summary> /// The method that the engine calls whenever our turn arrives /// </summary> public void DoTurn(IPirateGame game) { game.Debug("start turn at {0}", game.TimeRemaining()); // if this is the first turn if (game.GetTurn() == 1) { // create a new game enviroment this.game = new Game(game); // initialize the event list, and fill it up! this.events = new List <Event>(); this.AddEvents(); // initialize the states manager, and fill it up! this.statesManager = new StatesManager(); this.AddStates(); // initialize the actions chooser this.actionsChooser = new ActionsChooser(this.game); } // if this is NOT the first turn else { // update the game enviroment this.game.Update(game); // update the states manager this.statesManager.Update(this.game); } this.game.Log(LogType.Timing, LogImportance.Important, "finish update at {0}", this.game.GetTimeRemaining()); // run the best events for us this.UpdateChooser(); this.game.Execute(this.actionsChooser); this.game.Log(LogType.Timing, LogImportance.ExtremelyImportant, "finish turn at {0}", this.game.GetTimeRemaining()); game.Debug("real finish at {0}", game.TimeRemaining()); }
public void DoTurn(IPirateGame game) { try { int remaining = 6; Pirate[] ps = new Pirate[4]; int[] ds = new int[4]; List <int> dss = new List <int>();// should always be size 4 for (int i = 0; i < 4; i++) { ps[i] = game.GetMyPirate(i); ds[i] = int.MaxValue; if (game.Treasures().Contains(ts[i])) { continue; } foreach (Treasure t in game.Treasures()) { if (game.Distance(ps[i], t) < ds[i]) { ds[i] = game.Distance(ps[i], t); //ts[i] = t; } } } // sort the ds into the dss { bool add; do { add = false; int min = -1; for (int i = 0; i < ds.Length; i++) { if (!dss.Contains(i)) { if (min == -1 || ds[i] <= ds[min]) { min = i; add = true; } } } if (add) { dss.Add(min); } } while (add); } if (kamikaze) { if (ps[0].InitialLocation.Equals(new Location(23, 1))) { ts[3] = new Treasure(19, new Location(17, 19)); ts[1] = new Treasure(20, new Location(24, 30)); ts[2] = new Treasure(20, new Location(25, 29)); ts[0] = new Treasure(20, new Location(26, 28)); } else { ts[3] = new Treasure(19, new Location(17, 13)); ts[1] = new Treasure(20, new Location(24, 2)); ts[2] = new Treasure(20, new Location(25, 3)); ts[0] = new Treasure(20, new Location(26, 4)); } ds[0] = 0; ds[1] = 0; ds[2] = 0; ds[3] = 0; } List <Pirate> ltp = game.MyPiratesWithTreasures(); remaining -= ltp.Count; foreach (Pirate p in ltp) { move(p, p.InitialLocation, 1, game); } Pirate k = null, tar = null; if (game.Treasures().Count == 0 && game.EnemyPiratesWithTreasures().Count > 0) { int d = int.MaxValue; tar = game.EnemyPiratesWithTreasures()[0]; foreach (Pirate p in game.MyPiratesWithoutTreasures()) { if (p.TurnsToSober == 0 && p.ReloadTurns < 6 && d > game.Distance(p, tar)) { d = game.Distance(p, tar); k = p; } } } for (int j = 0; j < 4; j++) { int i = dss[j]; if (!ps[i].HasTreasure) { bool attacked = false; if (ps[i].ReloadTurns == 0) { Pirate t = null; foreach (Pirate e in game.EnemySoberPirates()) { if (game.InRange(ps[i], e)) { if (e.ReloadTurns == 0) { t = e; break; } else if (e.HasTreasure) { if (t == null || t.HasTreasure || t.ReloadTurns > 0) { t = e; } } else if (e.ReloadTurns > 0 && !e.HasTreasure) { continue; } } } if (t != null) { game.Attack(ps[i], t); attacked = true; } } if (!attacked && ps[i].TurnsToSober == 0 && ps[i].TurnsToRevive == 0) { if ((game.Treasures().Count > 0 && move(ps[i], ts[i].Location, remaining, game) || (game.EnemyPiratesWithTreasures().Count > 0 && ps[i] == k && move(ps[i], tar.Location, remaining, game)))) { remaining = 0; } } } } } catch (Exception e) { game.Debug("Crashed!"); game.Debug(e.Message); game.Debug(e.StackTrace); } }
private void MoveToBase(IPirateGame game, Pirate pirate) { game.Debug("Move pirate {0} home", pirate.Id); List<Location> possibleLocations = game.GetSailOptions(pirate, pirate.InitialLocation, 1); game.SetSail(pirate, possibleLocations[0]); }
private void MoveToTreasure(IPirateGame game, PirateAndCandidate candiadte, int moves) { if (candiadte.Treasure == null) { return; } List<Location> possibleLocations = game.GetSailOptions(candiadte.Pirate, candiadte.Treasure.Location, moves); game.Debug("Move pirate {0} to treasure {1} with {2}", candiadte.Pirate.Id, candiadte.Treasure.Id, moves); game.SetSail(candiadte.Pirate, possibleLocations[0]); }
// this is the actual turn public void DoTurn(IPirateGame game) { if (game.GetTurn() == 1) { rand = new Random(42934837); //,,79409223 if (game.AllEnemyPirates().Count > game.AllMyPirates().Count) { rand = new Random(31400000); } Location l = new Location(1, 1); if (game.Treasures().Count == 1 && game.AllMyPirates().Count == game.AllEnemyPirates().Count) { deadMap = true; } game.Debug((deadMap ? "DEADMAP!!!" : "NIE!")); if (deadMap) { return; // this stops some fighting over treasures } } nowhere = (game.GetEnemyScore() == game.GetMyScore() && game.GetTurn() == (game.GetMaxTurns() / 3)); if (nowhere) { game.Debug("ACTIVATING NOWHERE MODE!!!"); } panic = (((game.Treasures().Count == 0 || game.GetEnemyScore() >= (game.GetMaxPoints() - 2))) && game.EnemyPiratesWithTreasures().Count > 0); if (panic) { game.Debug("ACTIVATING PANIC MODE!!!"); } PirateContainer.init(game); QueuedAttack.init(); QueuedMotion.init(); int remaining = game.GetActionsPerTurn(); int ships = game.AllMyPirates().Count; try { // calculate the closest treasure to ps[i] PirateContainer[] ps = new PirateContainer[ships]; int[] ds = new int[ships]; Treasure[] ts = new Treasure[ships]; for (int i = 0; i < ships; i++) { ps[i] = new PirateContainer(game.GetMyPirate(i), (i % 2) == 1); ds[i] = int.MaxValue; foreach (Treasure t in game.Treasures()) { if (game.Distance(ps[i].P, t) < ds[i]) { ds[i] = game.Distance(ps[i].P, t); ts[i] = t; } } } // control the kamikazes calcKamikazes(ps, ref ts, ref ds, game); // move Pirates that have treasures towards the base { List <PirateContainer> ltp = PirateContainer.withTreasure; foreach (PirateContainer p in ltp) { List <Pirate> es = findEnemiesFor(p.P, game); if (es.Count > 0 && p.P.ReloadTurns == 0) { p.defend(game); } else { remaining -= move(p, p.P.InitialLocation, 1, game, true); } } } // search and destroy, TODO: prioritise this!!! Pirate k = null, tar = null; if (panic) { int mx = (game.GetRows() + game.GetCols() - game.GetAttackRadius()) / game.GetActionsPerTurn(); // turns it takes to get from a corner to its opposing corner int d = int.MaxValue; tar = game.EnemyPiratesWithTreasures()[0]; // TODO: focus on closest to enemy base // find closest Pirate foreach (PirateContainer p in PirateContainer.free) // notice all pirates with Treasure already moved, see: ltp { game.Debug("panic->k testing for " + p.P.Id + " | " + d); game.Debug(p.AVALIBLE + " && " + (p.P.ReloadTurns < mx) + " && " + (d > game.Distance(p.P, tar))); if (p.AVALIBLE && p.P.ReloadTurns < mx && d > game.Distance(p.P, tar)) { d = game.Distance(p.P, tar); k = p.P; game.Debug("panic->k = " + p.P.Id + " | " + d); } } if (k == null) // no Pirate with ammo, so choose the closest to the InitialLocation then move to there { foreach (PirateContainer p in PirateContainer.free) // notice all pirates with Treasure already moved, see: ltp { if (p.AVALIBLE && d > game.Distance(p.P, tar.InitialLocation)) // TODO: make the "6" generic to board size { d = game.Distance(p.P, tar.InitialLocation); k = p.P; } } } } List <int> dss = sortInto(ds); // sort the ds into the dss // AAAAATTTTTTTTTTTTAAAAAAAAAAACCCCCCCCKKKKKKKKKKKKKKK!!!!!!!!!!!!!!!! (or defend...) for (int i = PirateContainer.free.Count; i > 0;) { PirateContainer p = PirateContainer.free[--i]; if (p.P.ReloadTurns == 0 && !p.P.HasTreasure && p.AVALIBLE) { List <Pirate> es = findTargetsFor(p.P, game); if (es.Count > 0) { new QueuedAttack(p, es); } } } QueuedAttack.doAttacks(game, deadMap); // move for (int j = 0; j < ships; j++) { int i = dss[j]; if (ps[i].S == PirateContainer.State.none && ps[i].AVALIBLE && !ps[i].P.HasTreasure) { if (game.Treasures().Count > 0) // use typical motion { int mv = move(ps[i], ts[i].Location, remaining, game); if (mv > 0) { remaining -= mv; continue; } } if (game.EnemyPiratesWithTreasures().Count > 0 && ps[i].P == k) // activate search and destroy { remaining -= move(ps[i], tar.Location, remaining, game); } } } } catch (Exception e) { game.Debug("Crashed!"); game.Debug(e.Message); game.Debug(e.StackTrace); } game.Debug("turn " + game.GetTurn() + ": ran " + (game.GetActionsPerTurn() - remaining) + " motions"); }
// this is the actual turn public void DoTurn(IPirateGame game) { int remaining = game.GetActionsPerTurn(); if (game.GetTurn() == 1) { game.Debug("moves per turn: " + remaining); } try { #region init if (game.GetTurn() == 1) { chooseMap(game); } nowhere = inNowhereMode(game); if (nowhere) { game.Debug("ACTIVATING NOWHERE MODE"); } panic = inPanicMode(game); if (panic) { game.Debug("ACTIVATING PANIC MODE"); } PirateContainer.init(game); QueuedAttack.init(); QueuedMotion.init(); int ships = game.AllMyPirates().Count; PirateContainer[] ps = new PirateContainer[ships]; int[] ds = new int[ships]; Treasure[] ts = new Treasure[ships]; #endregion calcBestTreasure(game, ships, ref ps, ref ds, ref ts); // calculate the closest treasure to ps[i] BringBackTreasure(game, ref remaining); // move Pirates that have treasures towards the base calcKamikazes(ps, ref ts, ref ds, game); // control the kamikazes //BringBackTreasure(game, ref remaining); // move Pirates that have treasures towards the base //Powerup pt = new SpeedPowerup(-1, new Location(0, 0), 0, 0, 0); #region power up calculations Powerup[] pu = (from l in game.Powerups() where l.Type == "Speed" select l).ToArray(); if (pu.Count() > 0) { Powerup[] puu = new Powerup[ships]; for (int i = pu.Count() - 1; i >= 0; i--) { puu[i] = pu[i]; } game.Debug("A speed powerup was found"); int[] dis = new int[ships]; locatePowerups(game, ships, ref ps, ref dis, ref puu); int chosen = -1; for (int i = 0, min = int.MaxValue; i < ships; ++i) { if (dis[i] < min && ps[i].AVALIBLE && dis[i] != 0) //&& !ps[i].P.HasTreasure { min = dis[i]; chosen = i; } } game.Debug("Moving pirate " + chosen + " towards powerup"); if (chosen != -1) { game.Debug("Distance of chosen powerup - " + dis[chosen]); if (puu[chosen] == null) { game.Debug("we found the problem"); } remaining -= move(ps[chosen], puu[chosen].Location, remaining, game); } } #endregion #region panic mode Pirate k = null, tar = null; if (panic) { search_n_destroy(game, ref tar, ref k); // search and destroy, TODO: prioritise this!!! } #endregion List <int> dss = sortInto(ds); // sort the ds into the dss attack(game); QueuedAttack.doAttacks(game, deadMap); #region move // move for (int j = 0; j < ships; j++) { int i = dss[j]; if (ps[i].S == PirateContainer.State.none && ps[i].AVALIBLE && !ps[i].P.HasTreasure) { if (game.Treasures().Count > 0) // use typical motion { Location l = powerup(ps[i].P.Location, ts[i].Location, game); int mv; if (l != null) { mv = move(ps[i], l, remaining, game); } else { mv = move(ps[i], ts[i].Location, remaining, game); } if (mv > 0) { remaining -= mv; continue; } } if (game.EnemyPiratesWithTreasures().Count > 0 && ps[i].P == k) // activate search and destroy { remaining -= move(ps[i], tar.Location, remaining, game); } } } #endregion } catch (Exception e) { game.Debug("Crashed!"); game.Debug(e.Message); game.Debug(e.StackTrace); } finally { WastedTurnsCounter += remaining; game.Debug("________"); game.Debug("turn " + game.GetTurn() + " - moves summary"); game.Debug("turns used: " + (game.GetActionsPerTurn() - remaining)); game.Debug("turns wasted: " + remaining); game.Debug("________"); game.Debug("game summary"); game.Debug("turns used: " + (game.GetTurn() * game.GetActionsPerTurn() - WastedTurnsCounter) + "/" + (game.GetTurn() * game.GetActionsPerTurn()) + ", " + Math.Round((100 - (float)WastedTurnsCounter * 100 / (float)(game.GetTurn() * game.GetActionsPerTurn())), 2) + "% efficiency"); game.Debug("turns wasted: " + WastedTurnsCounter); } }
public void DoTurn(IPirateGame game) { if (MyBotUtils.IsTurnMultipleOf100(game)) { game.Debug("Turn number divides in 100."); } }