private void OpenFile() { OpenFileDialog f = new OpenFileDialog(); f.Title = "Load previously learned data..."; f.Filter = "QLearned Files (*.qlearned)|*.qlearned"; QLearned o = null; if (f.ShowDialog() == DialogResult.OK) { WriteOutput("Opening " + f.FileName + "..."); EnableControls(false); using (Stream stream = File.Open(f.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { try { BinaryFormatter bFormatter = new BinaryFormatter(); o = (QLearned)bFormatter.Deserialize(stream); stream.Close(); if (o != null) { if (algo == null || algo.GetType().Name != o.algo) { QAlgoPlugins.SelectedItem = o.algo; } if (state == null || state.GetType().Name != o.state) { QStatePlugins.SelectedItem = o.state; } agent = new QAgent(this, algo, state); agent.Open(o); } else { popup("Unable to open data from " + f.FileName); } } catch (Exception e) { stream.Close(); popup("Unable to open data from " + f.FileName + "\nDetails: " + e); } } } EnableControls(true); }
private void LoadQAlgoPlugin(string f) { try { bool loaded = false; foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type qalgo in a.GetTypes(). Where(t => String.Equals(t.Namespace, "QLearner.QAlgos", StringComparison.Ordinal)). Where(t => t.IsSubclassOf(typeof(QAlgo))). Where(t => t.IsVisible). Where(t => !t.IsAbstract). Where(t => t.Name == f)) { algo = (QAlgo)Activator.CreateInstance(qalgo); WriteOutput("Loaded QAlgo: " + qalgo.Name, true); algo.setQLearner(this); if (algo != null && state != null) { agent = new QAgent(this, algo, state); Reset(); Awaken.Enabled = Learn.Enabled = true; } Properties.Settings.Default.QAlgoPlugin = qalgo.Name; Properties.Settings.Default.Save(); loaded = true; break; } } if (!loaded) { WriteOutput("QAlgo Not Found: " + f, true); ResetPlugins(false); } } catch (Exception e) { WriteOutput("Unable to load QAlgo: " + f + "\n" + e, true); ResetPlugins(false); } }
private void OpenFile() { OpenFileDialog f = new OpenFileDialog(); f.Title = "Load previously learned data..."; f.Filter = "QLearned Files (*.qlearned)|*.qlearned"; QLearned o=null; if (f.ShowDialog() == DialogResult.OK) { WriteOutput("Opening " + f.FileName + "..."); EnableControls(false); using (Stream stream = File.Open(f.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { try { BinaryFormatter bFormatter = new BinaryFormatter(); o = (QLearned)bFormatter.Deserialize(stream); stream.Close(); if (o != null) { if (algo == null || algo.GetType().Name != o.algo) QAlgoPlugins.SelectedItem = o.algo; if (state == null || state.GetType().Name != o.state) QStatePlugins.SelectedItem = o.state; agent = new QAgent(this, algo, state); agent.Open(o); } else { popup("Unable to open data from " + f.FileName); } } catch (Exception e) { stream.Close(); popup("Unable to open data from " + f.FileName+"\nDetails: "+e); } } } EnableControls(true); }
private void LoadQAlgoPlugin(string f) { try { bool loaded = false; foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) foreach (Type qalgo in a.GetTypes(). Where(t => String.Equals(t.Namespace, "QLearner.QAlgos", StringComparison.Ordinal)). Where(t => t.IsSubclassOf(typeof(QAlgo))). Where(t => t.IsVisible). Where(t => !t.IsAbstract). Where(t => t.Name == f)) { algo = (QAlgo)Activator.CreateInstance(qalgo); WriteOutput("Loaded QAlgo: " + qalgo.Name, true); algo.setQLearner(this); if (algo != null && state != null) { agent = new QAgent(this, algo, state); Reset(); Awaken.Enabled = Learn.Enabled = true; } Properties.Settings.Default.QAlgoPlugin = qalgo.Name; Properties.Settings.Default.Save(); loaded = true; break; } if (!loaded) { WriteOutput("QAlgo Not Found: " + f, true); ResetPlugins(false); } } catch (Exception e) { WriteOutput("Unable to load QAlgo: " + f + "\n" + e, true); ResetPlugins(false); } }
public void Inherit(QAPI q) { main = q.main; agent = q.agent; }
public void setQAgent(QAgent q) { agent = q; }