public void UpdateFuturesStats(Map map) { var graph = new Graph(map); foreach (var futuresGroup in futures) { var connectedCalc = new ConnectedCalculator(graph, futuresGroup.Key); foreach (var future in futuresGroup.Value) { var connected = connectedCalc.GetConnectedMines(future.source).Contains(future.target) || connectedCalc.GetConnectedMines(future.target).Contains(future.source); futuresList.SetItemChecked(futureToListIndex[future], connected); } } }
public ScoreData GetScoreData(int punter, Map map, Future[] futures) { var scoreData = new ScoreData(); var graph = new Graph(map); var distCalc = new MineDistCalculator(graph); var minesCalc = new ConnectedCalculator(graph, punter); long res = 0; foreach (var vertex in graph.Vertexes) { var mines = minesCalc.GetConnectedMines(vertex.Key); foreach (var mine in mines) { long dist = distCalc.GetDist(mine, vertex.Key); res += dist * dist; } } scoreData.ScoreWithoutFutures = res; foreach (var future in futures) { var mines = minesCalc.GetConnectedMines(future.target); var dist = distCalc.GetDist(future.source, future.target); var futureScoreValue = dist * dist * dist; if (mines.Contains(future.source)) { scoreData.GainedFuturesScore += futureScoreValue; scoreData.GainedFuturesCount++; } scoreData.PossibleFuturesScore += futureScoreValue; scoreData.TotalFuturesCount++; } return(scoreData); }
public List <TurnResult> NextTurns() { var calculator = new ConnectedCalculator(Graph, PunterId); var result = new List <TurnResult>(); foreach (var vertex in Graph.Vertexes.Values) { foreach (var edge in vertex.Edges.Where(x => x.CanBeOwnedBy(PunterId, allowToUseOptions))) { var fromMines = calculator.GetConnectedMines(edge.From); var toMines = calculator.GetConnectedMines(edge.To); var fromScore = CalcVertexScore(toMines, fromMines, edge.From); var toScore = CalcVertexScore(fromMines, toMines, edge.To); var addScore = AggregateEdgeScores(fromScore, toScore); result.Add( new TurnResult { Estimation = addScore, Move = AiMoveDecision.ClaimOrOption(edge, PunterId, allowToUseOptions) }); } } return(result); }