public void TestDoubleExit() { Graph graph = new Graph(6); graph.AddBidirectionnalLink(0, 1); graph.AddBidirectionnalLink(1, 2); graph.AddBidirectionnalLink(2, 3); graph.AddBidirectionnalLink(3, 4); graph.AddBidirectionnalLink(3, 5); List <int> exits = new List <int>(); exits.Add(0); exits.Add(4); exits.Add(5); Context context = new Context(); context.Graph = graph; context.Exits = exits; context.SkynetNode = 2; var result = Algo2.Play(context); Assert.AreEqual("3 4", result); }
static void Main(string[] args) { Context context = new Context(); 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 context.Graph = new Graph(N); for (int i = 0; i < L; i++) { inputs = Console.ReadLine().Split(' '); int N1 = int.Parse(inputs[0]); // N1 and N2 defines a link between these nodes int N2 = int.Parse(inputs[1]); context.Graph.AddBidirectionnalLink(N1, N2); } for (int i = 0; i < E; i++) { int EI = int.Parse(Console.ReadLine()); // the index of a gateway node context.Exits.Add(EI); } // game loop while (true) { int SI = int.Parse(Console.ReadLine()); // The index of the node on which the Skynet agent is positioned this turn context.SkynetNode = SI; Console.WriteLine(Algo2.Play(context)); // Write an action using Console.WriteLine() // To debug: Console.Error.WriteLine("Debug messages..."); // Example: 0 1 are the indices of the nodes you wish to sever the link between } }
private async void SummaryDisplay() { if (!countedAlgo.Any()) { if (!friends.Any()) { friends = await DatabaseManager.DefaultManager.GetUsersTripsItemsAsync(tripItem); } if (!payments.Any()) { payments = await DatabaseManager.DefaultManager.GetPaymentItemsAsync(tripItem); } algo = new Algo2(payments.ToList(), HomeActivity1.userItem, new HashSet <UserItem>(friends), tripItem); try { countedAlgo = await algo.Algorithms_start(); } catch (Exception ex) { if (ex is ArgumentException) { Toast.MakeText(this, "Upps data are wrong!", ToastLength.Short).Show(); } if (ex is OverflowException) { Toast.MakeText(this, "Numbers to big to sum!", ToastLength.Long).Show(); } countedAlgo = new ObservableCollection <string>(); countedAlgo.Add("Something went wrong!"); } } var adapter = new AlgoAdapter(this, countedAlgo); listView.Adapter = adapter; // listView.ItemClick -= listViewClick; //TODO catch summary exception, better algo start }
private async void SummaryRefresh() { algo = new Algo2(payments.ToList(), HomeActivity1.userItem, new HashSet <UserItem>(friends), tripItem); try { countedAlgo = await algo.Algorithms_start(); } catch (Exception ex) { if (ex is ArgumentException) { Toast.MakeText(this, "Upps data are wrong!", ToastLength.Short).Show(); } if (ex is OverflowException) { Toast.MakeText(this, "Numbers to big to sum!", ToastLength.Long).Show(); } countedAlgo = new ObservableCollection <string>(); countedAlgo.Add("Something went wrong!"); } var adapter = new AlgoAdapter(this, countedAlgo); listView.Adapter = adapter; }
public ValueContainer(Algo2 reference) { _reference = reference; }