  // written by: Juan Bazurto
  // assisted by: Rich Pullose
  // debugged by: Mike Puntolillo, Juan Bazurto
package minoritygame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

@SuppressWarnings("serial")
public class EFBar extends JFrame {
    public static TextArea textArea1;
	public static JCheckBox HmnPly;
    private JCheckBox Mortality;
    private JCheckBox PoorStrat;
    private JCheckBox sherlock;
    private JButton SimGame;
    private JCheckBox attendance;
    private JCheckBox scores;
    private JCheckBox gaussian;
    private JCheckBox deaths;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JLabel jLabel5;
    private JLabel jLabel6;
    private JLabel jLabel7;
    private JLabel jLabel8;
    private JLabel jLabel9;
    private JLabel jLabel10;
    private JLabel jLabel11;
    private JLabel jLabel12;
    private JTextField mem;
    public static JTextField numA;
    private JTextField strat;
    private JTextField totrnd;
    private JTextField alpha;
    private JTextField beta;
    private JTextField drptsh;
    private JTextField drpfrq;
    public static boolean graph1;
    public static boolean graph2;
    public static boolean graph3;
    public static boolean graph4;

    /** Creates new form EFBar */
    public EFBar() {
        initComponents();
    }

    private void initComponents() {
	    jLabel1 = new JLabel();
	    HmnPly = new JCheckBox();
		Mortality = new JCheckBox();
		PoorStrat = new JCheckBox();
		sherlock = new JCheckBox();
        jLabel11 = new JLabel();
        jLabel2 = new JLabel();
        numA = new JTextField();
        jLabel3 = new JLabel();
        strat = new JTextField();
        jLabel4 = new JLabel();
        mem = new JTextField();
        jLabel5 = new JLabel();
        totrnd = new JTextField();
        jLabel12 = new JLabel();
		jLabel6 = new JLabel();
        alpha = new JTextField();
        jLabel7 = new JLabel();
        beta = new JTextField();
        jLabel9 = new JLabel();
        drptsh = new JTextField();
        jLabel10 = new JLabel();
        drpfrq = new JTextField();
        jLabel8 = new JLabel();
        attendance = new JCheckBox();
        scores = new JCheckBox();
        gaussian = new JCheckBox();
        deaths = new JCheckBox();
        SimGame = new JButton();
        textArea1 = new TextArea();

		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		jLabel1.setFont(new Font("Tahoma", 1, 12));
		jLabel1.setText("Options:");

		HmnPly.setText("Human Player");
        HmnPly.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                HmnPlyActionPerformed(evt);
            }
        });

		Mortality.setText("Mortality");
        Mortality.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                MortalityActionPerformed(evt);
            }
        });

        PoorStrat.setText("Drop Poor Strategies");
        deaths.setEnabled(false);
        PoorStrat.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                PoorStratActionPerformed(evt);
            }
        });

        sherlock.setText("Sherlock");
        sherlock.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                sherlockActionPerformed(evt);
            }
        });

	    jLabel12.setFont(new Font("Tahoma", 1, 12)); // NOI18N
	    jLabel12.setText("Basic Game Parameters:");

        jLabel2.setText("Number of Agents:");
        numA.setText("9");
        numA.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
				numAfocusLost(evt);
      	   }
        });

		jLabel3.setText("Strategies Per Agent:");
		strat.setText("3");
		strat.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                stratfocusLost(evt);
            }
        });


        jLabel4.setText("Memory Size per Agent:");
        mem.setText("2");
		mem.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                memfocusLost(evt);
            }
        });

        jLabel5.setText("Total Rounds:");
        totrnd.setText("20");
		totrnd.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                totrndfocusLost(evt);
            }
        });

	    jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
	    jLabel11.setText("Extensions:");

		jLabel6.setText("Alpha for Score Deprecation:");
		alpha.setText("1");
		alpha.addFocusListener(new FocusAdapter() {
		    public void focusLost(FocusEvent evt) {
		    	alphafocusLost(evt);
		    }
        });

        jLabel7.setText("Beta for Mortality:");
        beta.setText("0.0000995");
        beta.setEnabled(false);
		beta.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
               betafocusLost(evt);
            }
        });

		jLabel9.setText("Score Drop Threshold:");
		drptsh.setText("0.2");
	    drptsh.setEnabled(false);
	    drptsh.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
               drptshfocusLost(evt);
            }
        });

	    jLabel10.setText("Score Drop Frequency:");
	    drpfrq.setText("50");
	    drpfrq.setEnabled(false);
	    drpfrq.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
               drpfrqfocusLost(evt);
            }
        });

	    jLabel8.setFont(new Font("Tahoma", 1, 12));
        jLabel8.setText("Print Out:");

        attendance.setText("Attendance");
        attendance.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
				attendanceActionPerformed(evt);
            }
        });

        scores.setText("Scores");
		scores.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                scoresActionPerformed(evt);
            }
        });

	    gaussian.setText("Gaussian Distribution");
	    gaussian.addActionListener(new ActionListener() {
		  public void actionPerformed(ActionEvent evt) {
                gaussianActionPerformed(evt);
            }
        });

        deaths.setText("Deaths");
		deaths.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                deathsActionPerformed(evt);
            }
        });

        SimGame.setText("Simulate Game");
        SimGame.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
				SimGameActionPerformed(evt);
            }
        });

        textArea1.setEditable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(HmnPly)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Mortality)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(PoorStrat)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(sherlock))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(totrnd)
                                    .addComponent(mem)
                                    .addComponent(strat)
                                    .addComponent(jLabel2)
                                    .addComponent(numA, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)))
                            .addComponent(jLabel12))
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(alpha, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel9)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(drptsh, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(beta, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(27, 27, 27)
                                        .addComponent(SimGame, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(scores)
                                            .addComponent(attendance, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(deaths)
                                            .addComponent(gaussian))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addComponent(jLabel7)
                            .addComponent(drpfrq, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(textArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {alpha, beta, numA});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(HmnPly)
                    .addComponent(Mortality)
                    .addComponent(PoorStrat)
                    .addComponent(sherlock))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel12)
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(numA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(strat, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addGap(7, 7, 7)
                        .addComponent(totrnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(attendance)
                            .addComponent(gaussian))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(scores, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                            .addComponent(deaths, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(SimGame, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel11)
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(alpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(46, 46, 46)
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(beta, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(drptsh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addGap(7, 7, 7)
                                .addComponent(drpfrq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {alpha, beta, mem, numA, strat, totrnd});

        pack();
    }// </editor-fold>


	 private void HmnPlyActionPerformed(ActionEvent evt) {
		if (HmnPly.isSelected() == true && Integer.parseInt(numA.getText().trim()) % 2 == 1){
			int num = Integer.parseInt(numA.getText().trim())+1;
			gameParameters.HUMAN = HmnPly.isSelected();
			gameParameters.NUMAGENTS = num;
			numA.setText(Integer.toString(num));
		}
		else if (HmnPly.isSelected() == false && Integer.parseInt(numA.getText().trim()) % 2 == 0){
			int num = Integer.parseInt(numA.getText().trim())-1;
			gameParameters.HUMAN = HmnPly.isSelected();
			gameParameters.NUMAGENTS = num;
			numA.setText(Integer.toString(num));
		}
	 }

	 private void MortalityActionPerformed(ActionEvent evt) {
		gameParameters.MORTALITY = Mortality.isSelected();
		if (Mortality.isSelected()==true) {
		   beta.setEnabled(true);
		   deaths.setEnabled(true);
	 	}

		else if (Mortality.isSelected()==false) {
		   beta.setEnabled(false);
		   deaths.setEnabled(false);
		   deaths.setSelected(false);
                   graph4=false;
	 	}
	 }

	 private void PoorStratActionPerformed(java.awt.event.ActionEvent evt) {
		 if (PoorStrat.isSelected()==true){
			 drptsh.setEnabled(true);
			 drpfrq.setEnabled(true);
			 gameParameters.ADAPT=true;
		 }
		 else if (PoorStrat.isSelected()==false){
			 drptsh.setEnabled(false);
			 drpfrq.setEnabled(false);
			 gameParameters.ADAPT=false;
		 }
	 }

	 private void sherlockActionPerformed(java.awt.event.ActionEvent evt) {
		 if (sherlock.isSelected()==true){
			 gameParameters.SHERLOCK=true;
		 }
		 else if (sherlock.isSelected()==false){
			 gameParameters.SHERLOCK=false;
		 }
	 }

	 private void numAfocusLost(FocusEvent e){
 		boolean a = true;
 		try {
			Integer.parseInt(numA.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (numA.getText().length() == 0){
		}
		else if (a == false || Integer.parseInt(numA.getText().trim()) > 100000 || Integer.parseInt(numA.getText().trim()) <= 1){
			JOptionPane.showMessageDialog(null, "Input an Positive Integer greater than 1 and less than 100001.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			numA.setText("");
			numA.requestFocus();
		}
		else {
			gameParameters.NUMAGENTS = Integer.parseInt(numA.getText().trim());
		}
	}

	private void stratfocusLost(FocusEvent evt) {
		boolean a = true;
 		try {
			Integer.parseInt(strat.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		int size=(int) (Math.pow(2, Math.pow(2, gameParameters.M))+1);
		if (strat.getText().length()==0){
		}
		else if (a == false || Integer.parseInt(strat.getText().trim()) >= size || Integer.parseInt(strat.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer greater than 0 and less than "+size+ ".", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			strat.setText("2");
			strat.requestFocus();
		}
		else {
			gameParameters.NUMSTRAT = Integer.parseInt(strat.getText().trim());
	   }
	}

	 private void memfocusLost(FocusEvent evt) {
 		boolean a = true;
 		try {
			Integer.parseInt(mem.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (mem.getText().length() == 0){
		}
		else if (a == false || Integer.parseInt(mem.getText().trim()) > 4 || Integer.parseInt(mem.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer greater than 0 and less than 5.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			mem.setText("");
			mem.requestFocus();
		}

		else {
			gameParameters.M=Integer.parseInt(mem.getText().trim());;
		}
	 }

	 private void totrndfocusLost(FocusEvent evt) {
 		boolean a = true;
 		try {
			Integer.parseInt(totrnd.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (totrnd.getText().length() == 0){
		}
		else if (a == false || Integer.parseInt(totrnd.getText().trim()) > 1000000 || Integer.parseInt(totrnd.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer greater than 0 and less than 1,000,001.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			totrnd.setText("");
			totrnd.requestFocus();
		}

		else {
			 gameParameters.ROUNDS=Integer.parseInt(totrnd.getText());
		}
    }

	 private void alphafocusLost(FocusEvent evt) {
 		boolean a = true;
 		try {
			Double.parseDouble(alpha.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (alpha.getText().length() == 0){
		}
		else if (a == false || Double.parseDouble(alpha.getText().trim()) > 1 || Double.parseDouble(alpha.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer greater than 0 and less than or equal to 1.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			alpha.setText("");
			alpha.requestFocus();
		}
		else {
			gameParameters.ALPHA=Double.parseDouble(alpha.getText());;
	   }
    }

	 private void betafocusLost(FocusEvent evt) {
 		boolean a = true;
 		try {
			Double.parseDouble(beta.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (beta.getText().length() == 0){
		}
		else if (a == false || Double.parseDouble(beta.getText().trim()) >= 1 || Double.parseDouble(beta.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer between 0 and 1.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			beta.setText("");
			beta.requestFocus();
		}
		else {
			gameParameters.PROBADJUST=Double.parseDouble(beta.getText());
	    }
    }

	 private void drptshfocusLost(FocusEvent evt) {
 		boolean a = true;
 		try {
			Double.parseDouble(drptsh.getText().trim());
		}
		catch (NumberFormatException nfe) {
			a = false;
		}

		if (drptsh.getText().length() == 0){
		}
		else if (a == false || Double.parseDouble(drptsh.getText().trim()) >= 1 || Double.parseDouble(drptsh.getText().trim()) <= 0){
			JOptionPane.showMessageDialog(null, "Input an positive integer between 0 and 1.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			drptsh.setText("");
			drptsh.requestFocus();
		}
		else {
			gameParameters.ADAPTTHRESHOLD=Double.parseDouble(beta.getText());
	    }
     }

	 private void drpfrqfocusLost(FocusEvent evt) {
	 		boolean a = true;
	 		try {
				Integer.parseInt(drpfrq.getText().trim());
			}
			catch (NumberFormatException nfe) {
				a = false;
			}

			if (drpfrq.getText().length() == 0){
			}
			else if (a == false || Integer.parseInt(drpfrq.getText().trim()) <= 5){
				JOptionPane.showMessageDialog(null, "Input an positive integer greater than 5.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
				drpfrq.setText("");
				drpfrq.requestFocus();
			}

			else {
				 gameParameters.ADAPTPERIOD=Integer.parseInt(drpfrq.getText());
			}
	    }

	 public void attendanceActionPerformed(ActionEvent evt) {
		 graph1=attendance.isSelected();
	 }

	 public void scoresActionPerformed(ActionEvent evt) {
		 graph2=scores.isSelected();
	 }

	 private void gaussianActionPerformed(ActionEvent evt) {
         graph3=gaussian.isSelected();
	 }

	 private void deathsActionPerformed(ActionEvent evt) {
		 graph4=deaths.isSelected();
	 }

	 private void SimGameActionPerformed(ActionEvent evt){
	   if (numA.getText().length() == 0 && HmnPly.isSelected()==false){
		   numA.setText("9");
		   gameParameters.NUMAGENTS = 9;
	   }

		else if (numA.getText().length() == 0 && HmnPly.isSelected()==true){
			numA.setText("10");
			gameParameters.NUMAGENTS = 10;
		}

		if (strat.getText().length() == 0){
			 strat.setText("3");
		}

		if (mem.getText().length() == 0){
			 mem.setText("2");
		}

		if(totrnd.getText().length() == 0){
			totrnd.setText("20");
		}

		if (alpha.getText().length() == 0 ){
			alpha.setText("1");
		}

		if (beta.getText().length() == 0 && Mortality.isSelected()==true){
			beta.setText(".0000995");
		}

		if (drptsh.getText().length() == 0 && PoorStrat.isSelected()==true){
			drptsh.setText("0.2");
		}

		if (drptsh.getText().length() == 0 && PoorStrat.isSelected()==true){
			drpfrq.setText("50");
		}

	 	if (Integer.parseInt(numA.getText()) % 2 != 1 && HmnPly.isSelected()==true){
			gameParameters.HUMAN=HmnPly.isSelected();
			 GameSim.run(null);
		}

		else if (Integer.parseInt(numA.getText()) % 2 == 1 && HmnPly.isSelected()==false){
			 GameSim.run(null);
		}

		else if (Integer.parseInt(numA.getText()) % 2 == 1 && HmnPly.isSelected()==true){
			JOptionPane.showMessageDialog(null, "Pick an even number of agents if playing along.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
			numA.setText("10");
			numA.requestFocus();
		}
		else if (Integer.parseInt(numA.getText()) % 2 == 0 && HmnPly.isSelected()==false){
			JOptionPane.showMessageDialog(null, "Pick an odd number of agents if not playing along.", "ERROR" ,JOptionPane.ERROR_MESSAGE);
	 		numA.setText("9");
			numA.requestFocus();
		}
   	}

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EFBar().setVisible(true);
            }
        });
    }

}

