public ComponentScore(Node node, Node[] mines, IScorer scorer) { Mines = new[] { node }.Where(x => x.IsMine).ToList(); Scores = new Dictionary <int, long>(); foreach (var mine in mines) { var d = scorer.GetDistance(mine, node); Scores.Add(mine.Id, d * d); } SelfScore = Mines.Sum(x => Scores[x.Id]); }
public Component(Node node, Node[] mines, IScorer scorer) { Nodes = new List <Node> { node }; Mines = Nodes.Where(x => x.IsMine).ToList(); foreach (var mine in mines) { var d = scorer.GetDistance(mine, node); Scores.Add(mine.Id, d * d); } }
private int GetShortestDistanceToMineInOtherComponent(Node node, PunterConnectedComponents punterConnectedComponents, Punter punter) { var minesInOtherComponents = scorer.State.Mines .Where(mine => !punterConnectedComponents.IsInSameComponent(mine.Id, node.Id, punter.Id)) .ToArray(); if (minesInOtherComponents.Length == 0) { return(1000 * 1000 * 1000); } return(minesInOtherComponents.Min(mine => scorer.GetDistance(mine, node))); }