/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package gui; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.mygdx.game.Game; import com.mygdx.game.Listener; import com.mygdx.game.Log; import com.mygdx.game.Log.LogListener; import com.mygdx.game.Serializer; import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javafx.stage.FileChooser; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import logic.Creature; /** * * @author fazo */ public class GUI extends javax.swing.JFrame implements LogListener, Listener { private Game game; private LwjglApplication app; private boolean shouldUpdateGUI = false; private Thread guiUpdater; private Map options; /** * Creates new form GUI */ public GUI() { initComponents(); currentFpsLimit.setText("" + fpsLimitSlider.getValue()); setLocationRelativeTo(null); // Center the window Log.addListener(this); options = new HashMap(); updateSettings(); guiUpdater = new Thread() { @Override public void run() { for (;;) { if (shouldUpdateGUI) { updateGUI(); shouldUpdateGUI = false; } else { try { Thread.sleep(5000); } catch (InterruptedException ex) { } } } } }; guiUpdater.setPriority(Thread.MAX_PRIORITY); guiUpdater.start(); logTextArea.setText("Started GUI.\n"); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { container = new javax.swing.JPanel(); tabs = new javax.swing.JTabbedPane(); logPane = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); logTextArea = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); logLevelBox = new javax.swing.JComboBox(); jPanel1 = new javax.swing.JPanel(); fpsLimitSlider = new javax.swing.JSlider(); jLabel3 = new javax.swing.JLabel(); toggleFPSLimitCheckbox = new javax.swing.JCheckBox(); currentFpsLimit = new javax.swing.JLabel(); multithreadingCheckbox = new javax.swing.JCheckBox(); jLabel4 = new javax.swing.JLabel(); nCreaturesSlider = new javax.swing.JSlider(); currentNCreatures = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); nPlantsSlider = new javax.swing.JSlider(); currentNPlants = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); worldSizeSlider = new javax.swing.JSlider(); currentWorldSize = new javax.swing.JLabel(); pauseButton = new javax.swing.JToggleButton(); enableCorpsesCheckbox = new javax.swing.JCheckBox(); jLabel2 = new javax.swing.JLabel(); corpseDecaySlider = new javax.swing.JSlider(); currentCorpseDecay = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); topSizeSlider = new javax.swing.JSlider(); currentTopSize = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); sightRangeSlider = new javax.swing.JSlider(); jLabel9 = new javax.swing.JLabel(); hpDecaySlider = new javax.swing.JSlider(); jLabel10 = new javax.swing.JLabel(); maxTicksSlider = new javax.swing.JSlider(); currentSightRange = new javax.swing.JLabel(); currentHpDecay = new javax.swing.JLabel(); currentMaxTicks = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); drawViewCones = new javax.swing.JCheckBox(); drawSightLines = new javax.swing.JCheckBox(); jLabel11 = new javax.swing.JLabel(); nMutatedBrainsSlider = new javax.swing.JSlider(); currentNMutatedBrains = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); nMutatedNeuronsSlider = new javax.swing.JSlider(); currentNMutatedNeurons = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); mutationFactorSlider = new javax.swing.JSlider(); currentMutationFactor = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); nMutatedConnectionsSlider = new javax.swing.JSlider(); currentNMutatedConnections = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); creatureList = new javax.swing.JList(); saveBrainBtn = new javax.swing.JButton(); loadBrainBtn = new javax.swing.JButton(); status = new javax.swing.JLabel(); menuBar = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); exitButton = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); startButton = new javax.swing.JMenuItem(); pauseMenuButton = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("AIrium"); setMinimumSize(new java.awt.Dimension(700, 700)); logTextArea.setEditable(false); logTextArea.setColumns(20); logTextArea.setLineWrap(true); logTextArea.setRows(5); logTextArea.setText("Started GUI."); logTextArea.setWrapStyleWord(true); jScrollPane1.setViewportView(logTextArea); jLabel1.setText("Log Level"); logLevelBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Errors Only", "Default", "Debug Mode" })); logLevelBox.setSelectedIndex(1); logLevelBox.setToolTipText(""); logLevelBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { logLevelBoxItemStateChanged(evt); } }); javax.swing.GroupLayout logPaneLayout = new javax.swing.GroupLayout(logPane); logPane.setLayout(logPaneLayout); logPaneLayout.setHorizontalGroup( logPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(logPaneLayout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(logLevelBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 695, Short.MAX_VALUE) ); logPaneLayout.setVerticalGroup( logPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(logPaneLayout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE) .addGap(10, 10, 10) .addGroup(logPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(logLevelBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); tabs.addTab("Log", logPane); fpsLimitSlider.setMinimum(1); fpsLimitSlider.setSnapToTicks(true); fpsLimitSlider.setToolTipText("The maximum amount of ticks per second the simulation is allowed to compute"); fpsLimitSlider.setValue(60); fpsLimitSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { fpsLimitSliderStateChanged(evt); } }); jLabel3.setText("FPS Limiter"); toggleFPSLimitCheckbox.setText("Unlimit FPS"); toggleFPSLimitCheckbox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { toggleFPSLimitCheckboxStateChanged(evt); } }); currentFpsLimit.setText("60"); multithreadingCheckbox.setSelected(true); multithreadingCheckbox.setText("Multithreading (Experimental)"); multithreadingCheckbox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { multithreadingCheckboxStateChanged(evt); } }); jLabel4.setText("Number of Creatures"); nCreaturesSlider.setMaximum(150); nCreaturesSlider.setMinimum(1); nCreaturesSlider.setValue(25); nCreaturesSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { nCreaturesSliderStateChanged(evt); } }); currentNCreatures.setText("25"); jLabel5.setText("Number of Plants"); nPlantsSlider.setMaximum(5000); nPlantsSlider.setValue(700); nPlantsSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { nPlantsSliderStateChanged(evt); } }); currentNPlants.setText("700"); jLabel7.setText("World Size"); worldSizeSlider.setMaximum(5000); worldSizeSlider.setMinimum(200); worldSizeSlider.setValue(2000); worldSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { worldSizeSliderStateChanged(evt); } }); currentWorldSize.setText("2000"); pauseButton.setText("Pause"); pauseButton.setEnabled(false); pauseButton.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { pauseButtonStateChanged(evt); } }); enableCorpsesCheckbox.setText("Creatures leave a corpse when they die"); enableCorpsesCheckbox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { enableCorpsesCheckboxStateChanged(evt); } }); jLabel2.setText("Corpse decay rate"); corpseDecaySlider.setValue(0); corpseDecaySlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { corpseDecaySliderStateChanged(evt); } }); currentCorpseDecay.setText("0"); jLabel6.setText("Number of Parents (Top Size)"); topSizeSlider.setMaximum(25); topSizeSlider.setValue(0); topSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { topSizeSliderStateChanged(evt); } }); currentTopSize.setText("0"); jLabel8.setText("Creature sight range"); sightRangeSlider.setMaximum(1000); sightRangeSlider.setMinimum(20); sightRangeSlider.setValue(100); sightRangeSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { sightRangeSliderStateChanged(evt); } }); jLabel9.setText("Creature HP Decay"); hpDecaySlider.setMaximum(1000); hpDecaySlider.setValue(500); hpDecaySlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { hpDecaySliderStateChanged(evt); } }); jLabel10.setText("Max Generation Lifespan"); maxTicksSlider.setMaximum(100000); maxTicksSlider.setValue(0); maxTicksSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { maxTicksSliderStateChanged(evt); } }); currentSightRange.setText("100"); currentHpDecay.setText("0.5"); currentMaxTicks.setText("0 (Unlimited)"); jButton1.setText("Reset Defaults"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); drawViewCones.setText("Draw view cones"); drawViewCones.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { drawViewConesStateChanged(evt); } }); drawSightLines.setText("Draw sight lines"); drawSightLines.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { drawSightLinesStateChanged(evt); } }); jLabel11.setText("Probability of children mutation"); nMutatedBrainsSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { nMutatedBrainsSliderStateChanged(evt); } }); currentNMutatedBrains.setText("10%"); jLabel13.setText("Number of mutated neurons"); nMutatedNeuronsSlider.setValue(20); nMutatedNeuronsSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { nMutatedNeuronsSliderStateChanged(evt); } }); currentNMutatedNeurons.setText("jLabel14"); jLabel15.setText("Mutation Factor"); mutationFactorSlider.setMajorTickSpacing(1); mutationFactorSlider.setMaximum(200); mutationFactorSlider.setValue(100); mutationFactorSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { mutationFactorSliderStateChanged(evt); } }); currentMutationFactor.setText("jLabel16"); jLabel12.setText("Number of mutated synapsis"); nMutatedConnectionsSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { nMutatedConnectionsSliderStateChanged(evt); } }); currentNMutatedConnections.setText("jLabel14"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(fpsLimitSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentFpsLimit)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nCreaturesSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentNCreatures)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nPlantsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentNPlants)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(worldSizeSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentWorldSize)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(corpseDecaySlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentCorpseDecay)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(topSizeSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentTopSize)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sightRangeSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentSightRange)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(hpDecaySlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(pauseButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(toggleFPSLimitCheckbox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(multithreadingCheckbox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(enableCorpsesCheckbox))) .addGap(0, 0, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentHpDecay)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel10) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(maxTicksSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentMaxTicks)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nMutatedBrainsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentNMutatedBrains)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nMutatedNeuronsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentNMutatedNeurons)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(mutationFactorSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentMutationFactor)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel12) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nMutatedConnectionsSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(currentNMutatedConnections)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(drawViewCones) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(drawSightLines))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(fpsLimitSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(currentFpsLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(toggleFPSLimitCheckbox) .addComponent(multithreadingCheckbox) .addComponent(enableCorpsesCheckbox)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(currentNCreatures, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(nCreaturesSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(currentNPlants, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nPlantsSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(worldSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(currentWorldSize, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(corpseDecaySlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(currentCorpseDecay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(topSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(currentTopSize, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sightRangeSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(currentSightRange, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(hpDecaySlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(currentHpDecay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(maxTicksSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(currentMaxTicks, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(nMutatedBrainsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(currentNMutatedBrains, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(nMutatedNeuronsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(currentNMutatedNeurons, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(currentNMutatedConnections, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(nMutatedConnectionsSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(mutationFactorSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(currentMutationFactor, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(drawViewCones) .addComponent(drawSightLines)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pauseButton) .addComponent(jButton1)) .addContainerGap()) ); tabs.addTab("Settings", jPanel1); creatureList.setModel(new javax.swing.AbstractListModel() { String[] strings = { "No creatures" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); creatureList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); creatureList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { creatureListValueChanged(evt); } }); jScrollPane2.setViewportView(creatureList); saveBrainBtn.setText("Save"); saveBrainBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveBrainBtnActionPerformed(evt); } }); loadBrainBtn.setText("Load"); loadBrainBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { loadBrainBtnActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(saveBrainBtn) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(loadBrainBtn) .addContainerGap(587, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(saveBrainBtn) .addComponent(loadBrainBtn)) .addContainerGap()) ); tabs.addTab("Creatures", jPanel3); status.setText("Simulation stopped"); javax.swing.GroupLayout containerLayout = new javax.swing.GroupLayout(container); container.setLayout(containerLayout); containerLayout.setHorizontalGroup( containerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(containerLayout.createSequentialGroup() .addComponent(status) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(tabs) ); containerLayout.setVerticalGroup( containerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(containerLayout.createSequentialGroup() .addComponent(tabs) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(status)) ); jMenu1.setText("File"); exitButton.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK)); exitButton.setText("Exit"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jMenu1.add(exitButton); menuBar.add(jMenu1); jMenu3.setText("Simulation"); startButton.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); startButton.setText("Start"); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonActionPerformed(evt); } }); jMenu3.add(startButton); pauseMenuButton.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); pauseMenuButton.setText("Pause"); pauseMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pauseMenuButtonActionPerformed(evt); } }); jMenu3.add(pauseMenuButton); menuBar.add(jMenu3); jMenu2.setText("About"); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0)); jMenuItem1.setText("Help"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu2.add(jMenuItem1); jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem2.setText("AIrium"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu2.add(jMenuItem2); menuBar.add(jMenu2); setJMenuBar(menuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); }// //GEN-END:initComponents private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed if (JOptionPane.showConfirmDialog(this, "Are you sure? The program will exit!") == JOptionPane.YES_OPTION) { System.exit(0); } }//GEN-LAST:event_exitButtonActionPerformed private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed if (game != null) { // Restart if (JOptionPane.showConfirmDialog(this, "Are you sure? The simulation will be restarted!") != JOptionPane.YES_OPTION) { return; } game.getWorld().restart(); game.setPaused(false); updateGUI(); } else { // Start new LwjglApplicationConfiguration.disableAudio = true; LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.height = 600; config.width = 800; config.resizable = false; config.title = "AIrium Renderer"; app = new LwjglApplication(game = new Game(options), config); startButton.setText("Restart"); pauseButton.setEnabled(true); game.getWorld().addListener(this); setCreatureList(); } }//GEN-LAST:event_startButtonActionPerformed @Override public void onLog(int level, String msg) { logTextArea.append(msg + "\n"); setScrollBarToTheBottom(); } @Override public void on(int event) { shouldUpdateGUI = true; guiUpdater.interrupt(); } public void updateGUI() { if (game == null) { return; } status.setText("Generation: " + game.getWorld().getGeneration() + " FPS: " + game.getWorld().getFps()); if (game.isPaused()) { pauseButton.setSelected(true); pauseMenuButton.setText("Resume"); pauseButton.setText("Resume"); } else { pauseButton.setSelected(false); pauseMenuButton.setText("Pause"); pauseButton.setText("Pause"); } setCreatureList(); } private void setCreatureList() { String list[] = new String[game.getWorld().getCreatures().size()]; for (int i = 0; i < list.length; i++) { if (i >= game.getWorld().getCreatures().size()) { return; } list[i] = "Fitness: " + game.getWorld().getCreatures().get(i).getFitness(); } creatureList.setListData(list); } private void resetDefaultSettings() { fpsLimitSlider.setValue(60); nCreaturesSlider.setValue(25); nPlantsSlider.setValue(700); worldSizeSlider.setValue(2000); corpseDecaySlider.setValue(0); topSizeSlider.setValue(0); sightRangeSlider.setValue(100); hpDecaySlider.setValue(500); maxTicksSlider.setValue(0); toggleFPSLimitCheckbox.setSelected(false); multithreadingCheckbox.setSelected(true); enableCorpsesCheckbox.setSelected(false); drawSightLines.setSelected(false); drawViewCones.setSelected(false); updateSettings(); } private void updateSettings() { currentFpsLimit.setText("" + fpsLimitSlider.getValue()); if (toggleFPSLimitCheckbox.isSelected()) { options.put("fps_limit", 0f); } else { options.put("fps_limit", (float) fpsLimitSlider.getValue()); } options.put("enable_multithreading", multithreadingCheckbox.isSelected() ? 1f : 0f); options.put("number_of_creatures", (float) nCreaturesSlider.getValue()); options.put("number_of_plants", (float) nPlantsSlider.getValue()); options.put("corpse_decay_rate", corpseDecaySlider.getValue() / 1000f); options.put("enable_corpses", enableCorpsesCheckbox.isSelected() ? 1f : 0f); currentNCreatures.setText(nCreaturesSlider.getValue() + ""); currentNPlants.setText(nPlantsSlider.getValue() + ""); currentCorpseDecay.setText(corpseDecaySlider.getValue() / 1000f + ""); options.put("world_width", (float) worldSizeSlider.getValue()); options.put("world_height", (float) worldSizeSlider.getValue()); currentWorldSize.setText(worldSizeSlider.getValue() + ""); topSizeSlider.setMaximum(nCreaturesSlider.getValue()); currentTopSize.setText(topSizeSlider.getValue() + (topSizeSlider.getValue() <= 0 ? " (Auto)" : "")); options.put("parents_count", (float) topSizeSlider.getValue()); options.put("creature_sight_range", (float) sightRangeSlider.getValue()); options.put("creature_hp_decay", (float) hpDecaySlider.getValue() / 1000); options.put("max_ticks", (float) maxTicksSlider.getValue()); options.put("draw_view_cones", drawViewCones.isSelected() ? 1f : 0); options.put("draw_sight_lines", drawSightLines.isSelected() ? 1f : 0); currentMaxTicks.setText(maxTicksSlider.getValue() + ""); currentHpDecay.setText(hpDecaySlider.getValue() / 1000f + ""); currentSightRange.setText(sightRangeSlider.getValue() + ""); options.put("nMutatedBrains", (float) nMutatedBrainsSlider.getValue() / 100); currentNMutatedBrains.setText(String.format("%.2f", (float) nMutatedBrainsSlider.getValue() / 100) + "%"); options.put("nMutatedNeurons", (float) nMutatedNeuronsSlider.getValue() / 100); currentNMutatedNeurons.setText(String.format("%.2f", (float) nMutatedNeuronsSlider.getValue() / 100) + "%"); options.put("nMutatedConnections", (float) nMutatedConnectionsSlider.getValue() / 100); currentNMutatedConnections.setText(String.format("%.2f", (float) nMutatedConnectionsSlider.getValue() / 100) + "%"); options.put("mutationFactor", (float) mutationFactorSlider.getValue() / 100); currentMutationFactor.setText(String.format("%.2f", (float) mutationFactorSlider.getValue() / 100)); if (game != null) { game.getWorld().reloadOptions(); } } public void setScrollBarToTheBottom() { jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getMaximum()); } private void logLevelBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_logLevelBoxItemStateChanged Log.setLogLevel(logLevelBox.getSelectedIndex()); }//GEN-LAST:event_logLevelBoxItemStateChanged private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null) { try { desktop.browse(new URL("http://github.com/fazo96/AIrium").toURI()); } catch (IOException ex) { Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); } catch (URISyntaxException ex) { Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please visit http://github.com/fazo96/AIrium"); } }//GEN-LAST:event_jMenuItem2ActionPerformed private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed jMenuItem2ActionPerformed(evt); }//GEN-LAST:event_jMenuItem1ActionPerformed private void pauseMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseMenuButtonActionPerformed if (game == null) { return; } game.setPaused(!game.isPaused()); }//GEN-LAST:event_pauseMenuButtonActionPerformed private void topSizeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_topSizeSliderStateChanged updateSettings(); }//GEN-LAST:event_topSizeSliderStateChanged private void corpseDecaySliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_corpseDecaySliderStateChanged updateSettings(); }//GEN-LAST:event_corpseDecaySliderStateChanged private void enableCorpsesCheckboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_enableCorpsesCheckboxStateChanged updateSettings(); }//GEN-LAST:event_enableCorpsesCheckboxStateChanged private void pauseButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pauseButtonStateChanged game.setPaused(pauseButton.isSelected()); }//GEN-LAST:event_pauseButtonStateChanged private void worldSizeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_worldSizeSliderStateChanged updateSettings(); }//GEN-LAST:event_worldSizeSliderStateChanged private void nPlantsSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nPlantsSliderStateChanged updateSettings(); }//GEN-LAST:event_nPlantsSliderStateChanged private void nCreaturesSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nCreaturesSliderStateChanged updateSettings(); }//GEN-LAST:event_nCreaturesSliderStateChanged private void multithreadingCheckboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_multithreadingCheckboxStateChanged updateSettings(); }//GEN-LAST:event_multithreadingCheckboxStateChanged private void toggleFPSLimitCheckboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_toggleFPSLimitCheckboxStateChanged updateSettings(); }//GEN-LAST:event_toggleFPSLimitCheckboxStateChanged private void fpsLimitSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fpsLimitSliderStateChanged updateSettings(); }//GEN-LAST:event_fpsLimitSliderStateChanged private void sightRangeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sightRangeSliderStateChanged updateSettings(); }//GEN-LAST:event_sightRangeSliderStateChanged private void hpDecaySliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_hpDecaySliderStateChanged updateSettings(); }//GEN-LAST:event_hpDecaySliderStateChanged private void maxTicksSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_maxTicksSliderStateChanged updateSettings(); }//GEN-LAST:event_maxTicksSliderStateChanged private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed resetDefaultSettings(); }//GEN-LAST:event_jButton1ActionPerformed private void drawViewConesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_drawViewConesStateChanged updateSettings(); }//GEN-LAST:event_drawViewConesStateChanged private void drawSightLinesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_drawSightLinesStateChanged updateSettings(); }//GEN-LAST:event_drawSightLinesStateChanged private void nMutatedNeuronsSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nMutatedNeuronsSliderStateChanged updateSettings(); }//GEN-LAST:event_nMutatedNeuronsSliderStateChanged private void mutationFactorSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mutationFactorSliderStateChanged updateSettings(); }//GEN-LAST:event_mutationFactorSliderStateChanged private void nMutatedBrainsSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nMutatedBrainsSliderStateChanged updateSettings(); }//GEN-LAST:event_nMutatedBrainsSliderStateChanged private void nMutatedConnectionsSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_nMutatedConnectionsSliderStateChanged updateSettings(); }//GEN-LAST:event_nMutatedConnectionsSliderStateChanged private void creatureListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_creatureListValueChanged if (game == null) { creatureList.setSelectedIndex(-1); } else { try { if (creatureList.getSelectedIndex() >= 0) { Game.get().getWorld().selectCreature(Game.get().getWorld().getCreatures().get(creatureList.getSelectedIndex())); } } catch (IndexOutOfBoundsException ex) { JOptionPane.showMessageDialog(this, "This creature is not available"); } } }//GEN-LAST:event_creatureListValueChanged private void saveBrainBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBrainBtnActionPerformed game.setPaused(true); updateGUI(); if (game.getWorld().getSelectedCreature() == null) { JOptionPane.showMessageDialog(this, "Please select a creature first"); return; } JFileChooser fc = new JFileChooser(); File f = null; if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { f = fc.getSelectedFile(); } else return; Serializer.saveToFile(f, Serializer.serializeBrain(game.getWorld().getSelectedCreature().getBrain().getMap())); }//GEN-LAST:event_saveBrainBtnActionPerformed private void loadBrainBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadBrainBtnActionPerformed game.setPaused(true); updateGUI(); JFileChooser fc = new JFileChooser(); File f = null; if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { f = fc.getSelectedFile(); } else return; float map[][][] = Serializer.loadBrain(Serializer.loadFromFile(f)); Creature c = (Creature) game.getWorld().spawnCreature(map); game.getWorld().selectCreature(c); updateGUI(); }//GEN-LAST:event_loadBrainBtnActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel container; private javax.swing.JSlider corpseDecaySlider; private javax.swing.JList creatureList; private javax.swing.JLabel currentCorpseDecay; private javax.swing.JLabel currentFpsLimit; private javax.swing.JLabel currentHpDecay; private javax.swing.JLabel currentMaxTicks; private javax.swing.JLabel currentMutationFactor; private javax.swing.JLabel currentNCreatures; private javax.swing.JLabel currentNMutatedBrains; private javax.swing.JLabel currentNMutatedConnections; private javax.swing.JLabel currentNMutatedNeurons; private javax.swing.JLabel currentNPlants; private javax.swing.JLabel currentSightRange; private javax.swing.JLabel currentTopSize; private javax.swing.JLabel currentWorldSize; private javax.swing.JCheckBox drawSightLines; private javax.swing.JCheckBox drawViewCones; private javax.swing.JCheckBox enableCorpsesCheckbox; private javax.swing.JMenuItem exitButton; private javax.swing.JSlider fpsLimitSlider; private javax.swing.JSlider hpDecaySlider; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JButton loadBrainBtn; private javax.swing.JComboBox logLevelBox; private javax.swing.JPanel logPane; private javax.swing.JTextArea logTextArea; private javax.swing.JSlider maxTicksSlider; private javax.swing.JMenuBar menuBar; private javax.swing.JCheckBox multithreadingCheckbox; private javax.swing.JSlider mutationFactorSlider; private javax.swing.JSlider nCreaturesSlider; private javax.swing.JSlider nMutatedBrainsSlider; private javax.swing.JSlider nMutatedConnectionsSlider; private javax.swing.JSlider nMutatedNeuronsSlider; private javax.swing.JSlider nPlantsSlider; private javax.swing.JToggleButton pauseButton; private javax.swing.JMenuItem pauseMenuButton; private javax.swing.JButton saveBrainBtn; private javax.swing.JSlider sightRangeSlider; private javax.swing.JMenuItem startButton; private javax.swing.JLabel status; private javax.swing.JTabbedPane tabs; private javax.swing.JCheckBox toggleFPSLimitCheckbox; private javax.swing.JSlider topSizeSlider; private javax.swing.JSlider worldSizeSlider; // End of variables declaration//GEN-END:variables }