diff --git a/Lframe_0_delay-0.1s.gif b/Lframe_0_delay-0.1s.gif
new file mode 100644
index 0000000..77a5cc8
Binary files /dev/null and b/Lframe_0_delay-0.1s.gif differ
diff --git a/Lframe_1_delay-0.1s.gif b/Lframe_1_delay-0.1s.gif
new file mode 100644
index 0000000..95d6e63
Binary files /dev/null and b/Lframe_1_delay-0.1s.gif differ
diff --git a/Lframe_2_delay-0.1s.gif b/Lframe_2_delay-0.1s.gif
new file mode 100644
index 0000000..d0b6dcd
Binary files /dev/null and b/Lframe_2_delay-0.1s.gif differ
diff --git a/Lframe_3_delay-0.1s.gif b/Lframe_3_delay-0.1s.gif
new file mode 100644
index 0000000..95d6e63
Binary files /dev/null and b/Lframe_3_delay-0.1s.gif differ
diff --git a/_classpath.xml b/_classpath.xml
new file mode 100644
index 0000000..d655412
--- /dev/null
+++ b/_classpath.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/_project.xml b/_project.xml
new file mode 100644
index 0000000..eab011b
--- /dev/null
+++ b/_project.xml
@@ -0,0 +1,17 @@
+
+
+ Full algorithm
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/best.nn b/best.nn
index 1544120..e483a6f 100644
Binary files a/best.nn and b/best.nn differ
diff --git a/best2.nn b/best2.nn
new file mode 100644
index 0000000..b775540
Binary files /dev/null and b/best2.nn differ
diff --git a/bin/.gitignore b/bin/.gitignore
deleted file mode 100644
index f5d4628..0000000
--- a/bin/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-/gui$1.class
-/gui$2.class
-/gui$3.class
-/gui$4.class
-/gui.class
-/gui$5.class
-/gui$6.class
-/Gui$1.class
-/Gui$2.class
-/Gui$3.class
-/Gui$4.class
-/Gui$5.class
-/Gui.class
-/Gui$6.class
diff --git a/bin/Game$1.class b/bin/Game$1.class
index 7a83639..a1cbafa 100644
Binary files a/bin/Game$1.class and b/bin/Game$1.class differ
diff --git a/bin/Game$2.class b/bin/Game$2.class
index 57fef85..596ad2d 100644
Binary files a/bin/Game$2.class and b/bin/Game$2.class differ
diff --git a/bin/Game.class b/bin/Game.class
index 1602dba..b2441c9 100644
Binary files a/bin/Game.class and b/bin/Game.class differ
diff --git a/bin/GameGrid.class b/bin/GameGrid.class
index 592b04f..bdb5cea 100644
Binary files a/bin/GameGrid.class and b/bin/GameGrid.class differ
diff --git a/bin/GenerationUpdate.class b/bin/GenerationUpdate.class
new file mode 100644
index 0000000..db2a5b3
Binary files /dev/null and b/bin/GenerationUpdate.class differ
diff --git a/bin/GeneticAlgorithm.class b/bin/GeneticAlgorithm.class
index 3ba1c49..31fc8a6 100644
Binary files a/bin/GeneticAlgorithm.class and b/bin/GeneticAlgorithm.class differ
diff --git a/bin/Gui$1.class b/bin/Gui$1.class
new file mode 100644
index 0000000..994d88b
Binary files /dev/null and b/bin/Gui$1.class differ
diff --git a/bin/Gui$2.class b/bin/Gui$2.class
new file mode 100644
index 0000000..7329a7b
Binary files /dev/null and b/bin/Gui$2.class differ
diff --git a/bin/Gui$3.class b/bin/Gui$3.class
new file mode 100644
index 0000000..2b8fc45
Binary files /dev/null and b/bin/Gui$3.class differ
diff --git a/bin/Gui$4.class b/bin/Gui$4.class
new file mode 100644
index 0000000..e22af43
Binary files /dev/null and b/bin/Gui$4.class differ
diff --git a/bin/Gui$5.class b/bin/Gui$5.class
new file mode 100644
index 0000000..655f916
Binary files /dev/null and b/bin/Gui$5.class differ
diff --git a/bin/Gui$6.class b/bin/Gui$6.class
new file mode 100644
index 0000000..7edf458
Binary files /dev/null and b/bin/Gui$6.class differ
diff --git a/bin/Gui.class b/bin/Gui.class
new file mode 100644
index 0000000..3c674b1
Binary files /dev/null and b/bin/Gui.class differ
diff --git a/bin/LevelMaker$1.class b/bin/LevelMaker$1.class
index 966e8d3..cd6e27e 100644
Binary files a/bin/LevelMaker$1.class and b/bin/LevelMaker$1.class differ
diff --git a/bin/LevelMaker$2.class b/bin/LevelMaker$2.class
index e58c497..6e2ab31 100644
Binary files a/bin/LevelMaker$2.class and b/bin/LevelMaker$2.class differ
diff --git a/bin/LevelMaker$3.class b/bin/LevelMaker$3.class
index 814811a..16474de 100644
Binary files a/bin/LevelMaker$3.class and b/bin/LevelMaker$3.class differ
diff --git a/bin/LevelMaker$4.class b/bin/LevelMaker$4.class
index 8e8ecc9..bd97e5b 100644
Binary files a/bin/LevelMaker$4.class and b/bin/LevelMaker$4.class differ
diff --git a/bin/LevelMaker$5.class b/bin/LevelMaker$5.class
new file mode 100644
index 0000000..a3e9b39
Binary files /dev/null and b/bin/LevelMaker$5.class differ
diff --git a/bin/LevelMaker.class b/bin/LevelMaker.class
index 2c4d15e..41b80a9 100644
Binary files a/bin/LevelMaker.class and b/bin/LevelMaker.class differ
diff --git a/bin/Mario.class b/bin/Mario.class
index 5ba8ee3..a146d87 100644
Binary files a/bin/Mario.class and b/bin/Mario.class differ
diff --git a/bin/NeuralNetworkTester.class b/bin/NeuralNetworkTester.class
index e5f9e0d..d9e3c0c 100644
Binary files a/bin/NeuralNetworkTester.class and b/bin/NeuralNetworkTester.class differ
diff --git a/bin/Trainer.class b/bin/Trainer.class
index 0a8dc33..567707f 100644
Binary files a/bin/Trainer.class and b/bin/Trainer.class differ
diff --git a/data b/data
index d15196b..a2e47ca 100644
--- a/data
+++ b/data
@@ -6,10 +6,6 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
@@ -37,4 +33,8 @@
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1
\ No newline at end of file
+0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
\ No newline at end of file
diff --git a/frame_0_delay-0.1s.gif b/frame_0_delay-0.1s.gif
new file mode 100644
index 0000000..c57b906
Binary files /dev/null and b/frame_0_delay-0.1s.gif differ
diff --git a/frame_1_delay-0.1s.gif b/frame_1_delay-0.1s.gif
new file mode 100644
index 0000000..6cf6d7a
Binary files /dev/null and b/frame_1_delay-0.1s.gif differ
diff --git a/frame_2_delay-0.1s.gif b/frame_2_delay-0.1s.gif
new file mode 100644
index 0000000..f1e016b
Binary files /dev/null and b/frame_2_delay-0.1s.gif differ
diff --git a/frame_3_delay-0.1s.gif b/frame_3_delay-0.1s.gif
new file mode 100644
index 0000000..322e177
Binary files /dev/null and b/frame_3_delay-0.1s.gif differ
diff --git a/src/Game.java b/src/Game.java
index 67dcb57..60c2164 100644
--- a/src/Game.java
+++ b/src/Game.java
@@ -5,8 +5,10 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
@@ -20,7 +22,7 @@ public class Game {
private JPanel panel;
private Mario m = new Mario(0, 624);
private Keyboard keys = new Keyboard(m);
- private int[][] tilelayout = new int[13][14];
+ private static int[][] tilelayout = new int[13][14];
private String[] tileID = {"AIR", "ground"};
private int offset = 0;
private double fitness = 0;
@@ -28,10 +30,10 @@ public class Game {
private int frames = 0;
public Individual indiv;
public static int me = 0;
- public static int maxFrames = 50;
- public boolean play = false;
+ public static int maxFrames = 10;
+ public static boolean play = false;
public BufferedReader in;
- private Timer repaint = new Timer(18, new ActionListener(){
+ private Timer repaint = new Timer(15, new ActionListener(){
public void actionPerformed(ActionEvent e) {
frame.repaint();
frames += 1;
@@ -61,6 +63,23 @@ public void actionPerformed(ActionEvent e) {
}
});
+ public static void setLevel(int[][] nl) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("data"));
+ for (int[] y : nl) {
+ String s = "";
+ for (int x : y) {
+ s += x + ", ";
+ }
+ s += "\n";
+ out.write(s);
+ }
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
public static void main(String[] args) {
new Game().start();
}
@@ -136,6 +155,10 @@ public void paintComponent(Graphics g) {
String str;
for (int x = 0; x < tilelayout[0].length; x++) {
str = in.readLine();
+ if (str == null) {
+ in = new BufferedReader(new FileReader("level.gg"));
+ str = in.readLine();
+ }
process(str, x);
}
} catch (IOException e) {
@@ -240,7 +263,7 @@ private void draw(Graphics g) {
if (tile != 0) {
Image img;
try {
- img = ImageIO.read(new File(tileID[tile] + ".png"));
+ img = ImageIO.read(new File(System.getProperty("user.dir") + "/" + tileID[tile] + ".png"));
g.drawImage(img, x * 48 - offset, y * 48, null);
} catch (IOException e) {
// Auto-generated catch block
diff --git a/src/GameGrid.java b/src/GameGrid.java
index e81f726..5ee9677 100644
--- a/src/GameGrid.java
+++ b/src/GameGrid.java
@@ -22,6 +22,13 @@ public GameGrid (int cols) {
}
}
+ public void addRandom(int num) {
+ for (int i=0; i"+text+"