source: branches/PushGP/HeuristicLab.PushGP/PushGP.Cli/Program.cs @ 14834

Last change on this file since 14834 was 14834, checked in by pkimmesw, 2 years ago

#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,

File size: 1.1 KB
Line 
1using System;
2using System.Threading.Tasks;
3
4namespace HeuristicLab.Algorithms.PushGP.Cli {
5  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
6  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
7
8  class Program {
9    static void Main(string[] args) {
10      if (args.Length == 0) return;
11
12      var code = args[0];
13      EvaluateStepwise(code).Wait();
14
15      Console.ReadKey();
16    }
17
18    static async Task EvaluateStepwise(string code) {
19      var interpreter = new PushInterpreter(new PushConfiguration {
20        TopLevelPushCode = false
21      });
22
23      Console.WriteLine(@"Press ESC to cancel, SPACE to resume, Any other key to step...");
24      interpreter.Run(code, true);
25
26      while (!interpreter.IsCompleted) {
27        Console.Clear();
28        interpreter.PrintStacks();
29        interpreter.Step();
30
31        var input = Console.ReadKey();
32        if (input.Key == ConsoleKey.Escape) {
33          break;
34        }
35
36        if (input.Key == ConsoleKey.Spacebar) {
37          await interpreter.ResumeAsync();
38        }
39      }
40
41      Console.Clear();
42      interpreter.PrintStacks();
43    }
44  }
45}
Note: See TracBrowser for help on using the repository browser.