Skip to content

Commit

Permalink
Created main method to start application, started filling in the simu…
Browse files Browse the repository at this point in the history
…lator
  • Loading branch information
georgehtaylor1 committed Nov 7, 2016
1 parent f184e6e commit fe468d9
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/GeneticAlgorithm2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GeneticAlgorithm2 {

public static void main(String[] args) {

ParameterSet pset = null; //TODO: Create the parameter set

Simulator sim = new Simulator(pset);
JFrame frame = new JFrame("GeneticAlgorithms2");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel panel = (JPanel) frame.getContentPane();
panel.setPreferredSize(new Dimension(pset.getWindow_width(), pset.getWindow_height()));
panel.setLayout(null);

sim.setBounds(0, 0, pset.getWindow_width(), pset.getWindow_height());
sim.setIgnoreRepaint(true);

panel.add(sim);

frame.pack();
frame.setResizable(false);
frame.setVisible(true);
sim.createBufferStrategy(2);
new Thread(sim).start();

}

}
80 changes: 80 additions & 0 deletions src/ParameterSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

public class ParameterSet {

private int window_width;
private int window_height;

private int creature_size;
private int food_size;

private int creature_count;
private int food_count;

private int creature_speed;
private int creature_rotationSpeed;

public int getWindow_width() {
return window_width;
}

public void setWindow_width(int window_width) {
this.window_width = window_width;
}

public int getWindow_height() {
return window_height;
}

public void setWindow_height(int window_height) {
this.window_height = window_height;
}

public int getCreature_size() {
return creature_size;
}

public void setCreature_size(int creature_size) {
this.creature_size = creature_size;
}

public int getFood_size() {
return food_size;
}

public void setFood_size(int food_size) {
this.food_size = food_size;
}

public int getCreature_count() {
return creature_count;
}

public void setCreature_count(int creature_count) {
this.creature_count = creature_count;
}

public int getFood_count() {
return food_count;
}

public void setFood_count(int food_count) {
this.food_count = food_count;
}

public int getCreature_speed() {
return creature_speed;
}

public void setCreature_speed(int creature_speed) {
this.creature_speed = creature_speed;
}

public int getCreature_rotationSpeed() {
return creature_rotationSpeed;
}

public void setCreature_rotationSpeed(int creature_rotationSpeed) {
this.creature_rotationSpeed = creature_rotationSpeed;
}

}
40 changes: 40 additions & 0 deletions src/Simulator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.awt.Canvas;
import java.util.ArrayList;
import java.util.Random;

@SuppressWarnings("serial")
public class Simulator extends Canvas implements Runnable{

private ParameterSet params;
private Random rand;

private ArrayList<Creature> creatures;
private ArrayList<Food> food;

/**
* Default constructor for a simulator
* @param params The parameter set of the simulator
*/
public Simulator(ParameterSet params){
this.params = params;
rand = new Random(1); // Use a seed to make it deterministic
creatures = new ArrayList<Creature>();
food = new ArrayList<Food>();
}

@Override
public void run() {



}

public ParameterSet getParams() {
return params;
}

public void setParams(ParameterSet params) {
this.params = params;
}

}

0 comments on commit fe468d9

Please sign in to comment.