public void actionPerformed(ActionEvent arg0)
	{
		String command = arg0.getActionCommand();
		if (command.compareToIgnoreCase("Begin") == 0)
		{
			

			// disable the begin button and the configPanel (freeze the config)
			controlPanel.begin.setEnabled(false);
			configPanel.setEnabled(false);
			fast = false;
//			Thread runner = new Thread(new Runnable() {
//				
//				@Override
//				public void run() {
					if (engine.setUpGame())
					{
						boardPanel.setEngine(engine);
						boardFrame.setEngine(engine);
						boardPanel.setBoard(engine.getBoard(), false);
						boardFrame.setBoard(engine.getBoard(), false);
						// boardFrame.playerLabel.setText(engine.getPlayerName());
						// boardFrame.playerLabel.setForeground(engine.getPlayerColor());
						boardFrame.round.setText("Round: 0");
						controlPanel.stop.setEnabled(true);
						controlPanel.play.setEnabled(true);
						controlPanel.pause.setEnabled(false);
						controlPanel.step.setEnabled(true);
					} else
					{
						// game set up failed. Turn the right buttons on/off.
						controlPanel.begin.setEnabled(true);
						configPanel.setEnabled(true);
					}
					repaint();					
//				}
//			});
//			runner.run();
			
		} else if (command.compareToIgnoreCase("Step") == 0)
		{
			engine.step();
		} else if (command.compareToIgnoreCase("Play") == 0)
		{
			controlPanel.step.setEnabled(false);
			controlPanel.play.setEnabled(false);
			controlPanel.pause.setEnabled(true);
			controlPanel.begin.setEnabled(false);
			controlPanel.stop.setEnabled(true);
			fast = true;
			GameRunner runner = new GameRunner(configPanel.getSpeedSlider());
			runner.setName("Game Runner");
			runner.start();
		} else if (command.equalsIgnoreCase("Pause"))
		{
			fast = false;
			controlPanel.step.setEnabled(true);
			controlPanel.play.setEnabled(true);
			controlPanel.pause.setEnabled(false);
			controlPanel.begin.setEnabled(false);
			controlPanel.stop.setEnabled(true);
		} else if (command.compareToIgnoreCase("Stop") == 0)
		{
			fast = false;
			controlPanel.stop.setEnabled(false);
			controlPanel.play.setEnabled(false);
			controlPanel.pause.setEnabled(false);
			controlPanel.step.setEnabled(false);
			controlPanel.begin.setEnabled(true);
			configPanel.setEnabled(true);
		} else if (command.compareToIgnoreCase("Tournament") == 0)
		{
//			 controlPanel.begin.setEnabled(false);
//			 controlPanel.play.setEnabled(false);
//			 controlPanel.step.setEnabled(false);
//			 controlPanel.pause.setEnabled(false);
//			 controlPanel.stop.setEnabled(false);
//			 controlPanel.tournament.setEnabled(false);
//			 configPanel.setEnabled(false);
//			
//			 Tournament t = new Tournament(this.engine, ); //avoid dialog messages.
//			 engine.removeGameListener(this);
//			 t.run();
//						
//			 ArrayList<TournamentResult> results = t.getResults();
//			 for(TournamentResult r : results)
//			 System.out.println(r);
//			 File file = new
//			 File("tournament_"+engine.getConfig().getSelectedBoard().getName()
//					 +"_"+engine.getConfig().getActivePlayerNum()
//					 +"_"+engine.getConfig().getRange()
//			 +"_"+ engine.getConfig().getMaxRounds()
//			 +"_"+engine.getConfig().getTournamentGames()+".txt");
//			 try{
//			 FileWriter f = new FileWriter(file, false);
//							
//			 for(TournamentResult r : results)
//			 f.write(r.toString()+"\n");
//			 //f.write("\n");
//			 f.close();
//			 }catch(IOException e){
//			 System.err.println("Failed printing to output file:" + file );
//			 }
//						
//			 //TODO turn into thread, allow us to kill it...
//			 engine.addGameListener(this);
//			 //TODO need to record outcome somewhere...
//			
//			 controlPanel.begin.setEnabled(true);
//			 controlPanel.play.setEnabled(false);
//			 controlPanel.step.setEnabled(false);
//			 controlPanel.stop.setEnabled(false);
//			 controlPanel.tournament.setEnabled(true);
//			 configPanel.setEnabled(true);

		} else if (command.compareToIgnoreCase("BoardFrame") == 0)
		{
			boardFrame.setVisible(true);
		} else
		{
			throw new RuntimeException("Unknow Action Command: " + command);
		}
	}