/// <inheritdoc /> public GameController(IScore scorer, IStrat strat) { _scorer = scorer; _strat = strat; _strat.Initialize(_scorer); rng = new Random(); }
private static IStrat LoadPlayerStratFromCode(string source) { Dictionary <string, string> providerOptions = new Dictionary <string, string> { { "CompilerVersion", "v4.0" } }; CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions); CompilerParameters compilerParams = new CompilerParameters { GenerateInMemory = true, GenerateExecutable = false }; compilerParams.ReferencedAssemblies.Add(typeof(IStrat).Assembly.Location); compilerParams.ReferencedAssemblies.Add(typeof(Player).Assembly.Location); compilerParams.ReferencedAssemblies.Add(typeof(Move).Assembly.Location); CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, source); if (results.Errors.Count == 0) { } IStrat test = results.CompiledAssembly.CreateInstance("Test") as IStrat; return(test); }