-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created main method to start application, started filling in the simu…
…lator
- Loading branch information
1 parent
f184e6e
commit fe468d9
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |