private void LogRepresentation(RiftGame game) { var podNodes = game.GetZonesWithMyPods().ToList(); var controlNodes = game.GetZonesUnderMyControl().ToList(); Log($"Current statistics: {podNodes.Count} with myNodes, {controlNodes.Count} under control"); }
private IEnumerable <PodMovement> GetMovements(RiftGame game) { var controlledZones = game.GetZonesUnderMyControl(); foreach (var z in controlledZones) { var movableInZone = z.GetAmountMovable(game.MyPlayerID); Log($"Can move {movableInZone} from zone {z.NodeIndex}"); if (!(movableInZone > 0)) { continue; } //Find the node to move to var moveTo = z.LinkedNodes.FirstOrDefault(zz => zz.OwningPlayerID != game.MyPlayerID) ?? z.LinkedNodes.FirstOrDefault(); if (moveTo != null) { Log($"Moving {movableInZone} to {moveTo.NodeIndex}"); yield return(new PodMovement() { Amount = movableInZone.Value, ZoneOrigin = z.NodeIndex, ZoneDestination = moveTo.NodeIndex }); } } }
private IEnumerable <PodPurchase> GetPurchases(RiftGame game, int maxAmount) { int amountAvailable = maxAmount; Log($"Platimum to buy {amountAvailable} pods"); //Populate neutral zones var neutralZones = GetNeutralZonesForMoves(game).ToList(); Log($"Found {neutralZones.Count()} neutralzones"); //While we can get nodes that are neutral while (amountAvailable > 0 && neutralZones.Any()) { //Pick a random node, because otherwise we will start populating in the left top var neutralZone = GetRandomFromCollection(neutralZones); amountAvailable--; yield return(new PodPurchase() { Amount = 1, Zone = neutralZone.NodeIndex }); neutralZone.AddPodsForPlayer(game.MyPlayerID, 1); //Update the temporary count //Check if there are still zones neutralZones = GetNeutralZonesForMoves(game).ToList(); } if (amountAvailable > 0) { Log("Still platinum available after populating empty nodes to purchase!"); } //Check if we need to strengthen our outer defenses (zones that are mine, but are next to empty or enemy nodes) var zonesToStrengthen = game.GetZonesUnderMyControl().Where(z => z.LinkedNodes.Any(l => l.OwningPlayerID != game.MyPlayerID)); Log($"Found {zonesToStrengthen.Count()} zones to strengthen"); foreach (var zoneToStrengthen in zonesToStrengthen) { if (amountAvailable <= 0) { break; } amountAvailable--; yield return(new PodPurchase() { Amount = 1, Zone = zoneToStrengthen.NodeIndex }); zoneToStrengthen.AddPodsForPlayer(game.MyPlayerID, 1); //Update the temporary count } }