private void LoadQStatePlugin(string f) { try { bool loaded = false; foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type qstate in a.GetTypes(). Where(t => String.Equals(t.Namespace, "QLearner.QStates", StringComparison.Ordinal)). Where(t => t.IsSubclassOf(typeof(QState))). Where(t => t.IsVisible). Where(t => !t.IsAbstract). Where(t => t.Name == f)) { state = (QState)Activator.CreateInstance(qstate); WriteOutput("Loaded QState: " + qstate.Name, true); state.setQLearner(this); Settings.Enabled = state.HasSettings; if (state != null && algo != null) { agent = new QAgent(this, algo, state); Reset(); Awaken.Enabled = Learn.Enabled = true; } Properties.Settings.Default.QStatePlugin = qstate.Name; Properties.Settings.Default.Save(); loaded = true; break; } } if (!loaded) { WriteOutput("QState Not Found: " + f, true); ResetPlugins(false); } } catch (Exception e) { WriteOutput("Unable to load QState: " + f + "\n" + e, true); ResetPlugins(false); } }
private void LoadQStatePlugin(string f) { try { bool loaded = false; foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies()) foreach (Type qstate in a.GetTypes(). Where(t => String.Equals(t.Namespace, "QLearner.QStates", StringComparison.Ordinal)). Where(t => t.IsSubclassOf(typeof(QState))). Where(t => t.IsVisible). Where(t => !t.IsAbstract). Where(t => t.Name==f)) { state = (QState)Activator.CreateInstance(qstate); WriteOutput("Loaded QState: " + qstate.Name, true); state.setQLearner(this); Settings.Enabled = state.HasSettings; if (state != null && algo != null) { agent = new QAgent(this, algo, state); Reset(); Awaken.Enabled = Learn.Enabled = true; } Properties.Settings.Default.QStatePlugin = qstate.Name; Properties.Settings.Default.Save(); loaded = true; break; } if (!loaded) { WriteOutput("QState Not Found: " + f, true); ResetPlugins(false); } } catch (Exception e) { WriteOutput("Unable to load QState: " + f +"\n"+e, true); ResetPlugins(false); } }