private void ActiveGame_Exiting(object sender, EventArgs e) { _activeGame.Dispose(); _activeGame = null; _activeTest = null; // HACK: TouchPanel should probably clear itself at the // end of a Game run. TouchPanel.EnabledGestures = GestureType.None; View.Window.MakeKeyAndVisible(); View.LayoutSubviews(); }
private void RunTest(InteractiveTest test) { if (_activeGame != null || _activeTest != null) { throw new InvalidOperationException("An interactive test is already active."); } _activeTest = test; _activeGame = test.Create(); _activeGame.Exiting += ActiveGame_Exiting; _activeGame.Run(GameRunBehavior.Asynchronous); View.Window.Hidden = true; }
private static InteractiveTest[] DiscoverInteractiveTests() { var assembly = Assembly.GetExecutingAssembly(); var tests = new List <InteractiveTest> (); foreach (var type in assembly.GetTypes()) { InteractiveTest test; if (!InteractiveTest.TryCreateFrom(type, out test)) { continue; } tests.Add(test); } return(tests.ToArray()); }
public static bool TryCreateFrom(Type type, out InteractiveTest test) { test = null; if (!typeof(Game).IsAssignableFrom(type)) { return(false); } var attrs = type.GetCustomAttributes(typeof(InteractiveTestAttribute), false); if (attrs.Length == 0) { return(false); } var attr = (InteractiveTestAttribute)attrs[0]; test = new InteractiveTest( type, attr.Name ?? type.Name, attr.Category ?? Categories.Default); return(true); }
public static bool TryCreateFrom(Type type, out InteractiveTest test) { test = null; if (!typeof(Game).IsAssignableFrom(type)) return false; var attrs = type.GetCustomAttributes( typeof(InteractiveTestAttribute), false); if (attrs.Length == 0) return false; var attr = (InteractiveTestAttribute)attrs[0]; test = new InteractiveTest( type, attr.Name ?? type.Name, attr.Category ?? Categories.Default); return true; }
private void ActiveGame_Exiting (object sender, EventArgs e) { _activeGame.Dispose (); _activeGame = null; _activeTest = null; // HACK: TouchPanel should probably clear itself at the // end of a Game run. TouchPanel.EnabledGestures = GestureType.None; View.Window.MakeKeyAndVisible (); View.LayoutSubviews (); }
private void RunTest(InteractiveTest test) { if (_activeGame != null || _activeTest != null) throw new InvalidOperationException("An interactive test is already active."); _activeTest = test; _activeGame = test.Create (); _activeGame.Exiting += ActiveGame_Exiting; _activeGame.Run (GameRunBehavior.Asynchronous); View.Window.Hidden = true; }
private static void Main() { // testSortedLinkedList(); // return; while (true) { System.Console.ResetColor(); System.Console.Clear(); System.Console.WriteLine("I, M, Q"); var key = System.Console.ReadKey().Key; if (key == ConsoleKey.I) { var interactiveTest = new InteractiveTest(); interactiveTest.Main(); } else if (key == ConsoleKey.M) { System.Console.Clear(); System.Console.WriteLine("Multi Test Run"); var numTests = 200; System.Console.Write($"Num Tests ({numTests})? "); var numTestsStr = System.Console.ReadLine(); if (!string.IsNullOrEmpty(numTestsStr)) { numTests = Int32.Parse(numTestsStr); } var sizes = new [] { 200, 400, 800, 1000, 2000 }; System.Console.Write($"Sizes ({string.Join(", ", sizes)})?"); var sizesStr = System.Console.ReadLine(); if (!string.IsNullOrEmpty(sizesStr)) { sizes = sizesStr.Split(',').Select(s => int.Parse(s.Trim())).ToArray(); } var greedyFactors = EnumerableExtensions.Sequence(0d, 2d, 0.25d) .ToList(); System.Console.Write($"GreedFactor ({string.Join(", ", greedyFactors)})?"); var tInput = System.Console.ReadLine(); if (!string.IsNullOrEmpty(tInput)) { greedyFactors = tInput.Split(',').Select(s => double.Parse(s.Trim())).ToList(); } var dateStr = DateTime.Now.ToString("yyyyMMdd-HHmm"); foreach (var size in sizes) { var manyTest = new ManyTest { NumberOfTests = numTests, MapHeight = size, MapWidth = size, OutputFile = $"~/Documents/AStarTests/{dateStr}/{size}x{size} {numTests}.csv", GreedyFactors = greedyFactors }; manyTest.Run(); } } else if (key == ConsoleKey.Q) { break; } } }