// On "Start" learning button click private void startLearningButton_Click( object sender, EventArgs e ) { // get settings GetSettings( ); ShowSettings( ); iterationBox.Text = string.Empty; // destroy algorithms qLearning = null; sarsa = null; if ( algorithmCombo.SelectedIndex == 0 ) { // create new QLearning algorithm's instance qLearning = new QLearning( 256, 4, new TabuSearchExploration( 4, new EpsilonGreedyExploration( explorationRate ) ) ); workerThread = new Thread( new ThreadStart( QLearningThread ) ); } else { // create new Sarsa algorithm's instance sarsa = new Sarsa( 256, 4, new TabuSearchExploration( 4, new EpsilonGreedyExploration( explorationRate ) ) ); workerThread = new Thread( new ThreadStart( SarsaThread ) ); } // disable all settings controls except "Stop" button EnableControls( false ); // run worker thread needToStop = false; workerThread.Start( ); }