private static void runTourn(String args[],GameEngine engine,long seed, int n)
	{
		Statement s;
		java.net.InetAddress localMachine = null;
		try {
			localMachine = java.net.InetAddress.getLocalHost();
		} catch (UnknownHostException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
    	String hostname =  localMachine.getHostName();
    	int tournament_id =-1;
		try {
			s = conn.createStatement();	
			s.execute("INSERT INTO tournament (start,source,player,board,num_lights,seed,run_num)" +
					" VALUES (NOW(),\""+hostname+"\",\""+args[0]+"\",\""+args[2]+"\",\""+args[1]+"\",\""+seed+"\",\""+n+"\")",Statement.RETURN_GENERATED_KEYS);
			ResultSet rszz= s.getGeneratedKeys();
			rszz.next();
			tournament_id = rszz.getInt(1);
//			System.out.println("ID " + tournament_id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Tournament t = new Tournament(engine);
		engine.getConfig().setSelectedBoard(new File("boards/"+args[2]+".xml"));
		try {
			engine.getConfig().setPlayerClass((Class<Player>) Class.forName(args[0]));
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		engine.getConfig().setNumMosquitos(1000);
		engine.getConfig().setNumLights(Integer.valueOf(args[1]));
		engine.getConfig().setMaxRounds(15000);
		try
		{
			t.play();
		}
		catch(Exception e)
		{
			System.err.println("Exception in Tournament " + tournament_id + ", player " + args[0]);
			e.printStackTrace();
		}
		if(t.timedOut)
		{
			System.err.println("Timeout in Tournament " + tournament_id + ", player " + args[0]);
		}
		if(n == 0)
		{
			BoardPanel pan = new BoardPanel(engine, false);
			BufferedImage im = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB);
			pan.paint(im.getGraphics());
		    Iterator writers = ImageIO.getImageWritersByFormatName("png");
		    ImageWriter writer = (ImageWriter)writers.next();
		    File f = new File("output/"+args[0]+"_"+args[2]+"_"+args[1]+".png");
		    ImageOutputStream ios;
			try {
				ios = ImageIO.createImageOutputStream(f);
				 writer.setOutput(ios);
				 writer.write(im);
				 
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		   
		    
		}
		
		try {
			s = conn.createStatement();
			s.execute("UPDATE tournament SET end=NOW(), num_caught="+t.finalN+",time="+t.finalTime + " where id="+tournament_id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}