private static void Loop(List<SkyNetCell> nodes, int idInitial) { SkyNet sn = new SkyNet(nodes, idInitial ); var path = sn.FindPath(); int n1 = path[0].Id; int n2 = path[1].Id; var c1 = nodes.FirstOrDefault(n => n.Id == n1); var c2 = nodes.FirstOrDefault(n => n.Id == n2); c1.Neighbors.Remove(c2); c2.Neighbors.Remove(c1); }
static void Main(string[] args) { string[] inputs; inputs = Console.ReadLine().Split(' '); int N = int.Parse(inputs[0]); // the total number of nodes in the level, including the gateways int L = int.Parse(inputs[1]); // the number of links int E = int.Parse(inputs[2]); // the number of exit gateways var nodes = new List<SkyNetCell>(); for (int i = 0; i < N; i++) { nodes.Add(new SkyNetCell(i)); } //link cells for (int i = 0; i < L; i++) { var t = Console.ReadLine(); inputs = t.Split(' '); Console.Error.WriteLine(t); int cellId1 = int.Parse(inputs[0]); // N1 and N2 defines a link between these nodes int cellId2 = int.Parse(inputs[1]); var node1 = nodes.First(x => x.Id == cellId1); var node2 = nodes.First(x => x.Id == cellId2); node1.Neighbors.Add(node2); node2.Neighbors.Add(node1); } //mark gateway for (int i = 0; i < E; i++) { int EI = int.Parse(Console.ReadLine()); // the index of a gateway node Console.Error.WriteLine("EI-->" + EI); var gateway = nodes.First(x => x.Id == EI); gateway.IsGateWay = true; } //game loop while (true) { int IdInitial = int.Parse(Console.ReadLine()); // The index of the node on which the Skynet agent is positioned this turn SkyNet sn = new SkyNet(nodes, IdInitial); var path = sn.FindPath(); int n1 = path[0].Id; int n2 = path[1].Id; string pathToCut = n1 +" "+n2; var c1 = nodes.FirstOrDefault(n => n.Id == n1); var c2 = nodes.FirstOrDefault(n => n.Id == n2); c1.Neighbors.Remove(c2); c2.Neighbors.Remove(c1); Console.WriteLine(pathToCut); } }