From a2bc52b40a826fadc5dd9b380d83f2499608dc01 Mon Sep 17 00:00:00 2001 From: IceGawd <35550454+IceGawd@users.noreply.github.com> Date: Wed, 29 May 2019 13:40:01 -0700 Subject: [PATCH 1/3] Finished Final! (Basically) --- src/Game.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Game.java b/src/Game.java index 67dcb57..5467222 100644 --- a/src/Game.java +++ b/src/Game.java @@ -248,5 +248,24 @@ private void draw(Graphics g) { } } } + + ArrayList i = getState(); + for (int y = 0; y < 13; y++) { + for (int x = 0; x < 13; x++) { + if (i.get(y * 13 + x) == 0) { + g.setColor(Color.BLACK); + } + + g.drawRect(x * 10, y * 10, 10, 10); + } + } + for (int y = 0; y < 13; y++) { + for (int x = 0; x < 13; x++) { + if (i.get(y * 13 + x) == 1) { + g.setColor(Color.RED); + g.drawRect(x * 10, y * 10, 10, 10); + } + } + } } } From 22f813bbdea320d2aadca9d3e01ea3bcfe30b43d Mon Sep 17 00:00:00 2001 From: IceGawd <35550454+IceGawd@users.noreply.github.com> Date: Wed, 29 May 2019 13:40:33 -0700 Subject: [PATCH 2/3] Update GeneticAlgorithm.java --- src/GeneticAlgorithm.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/GeneticAlgorithm.java b/src/GeneticAlgorithm.java index d47a7f9..d2c041a 100644 --- a/src/GeneticAlgorithm.java +++ b/src/GeneticAlgorithm.java @@ -1,4 +1,3 @@ -import java.io.EOFException; import java.util.ArrayList; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -46,13 +45,16 @@ private void main() throws InterruptedException, ExecutionException { if (firstTime) { for(int i = 0; i < popSize; i++) { Individual ind = new Individual(numInputs); - + /*/ try { - ind.getNN().getFromFile("best.nn"); +// System.out.println(ind.getNN().getLayers()); +// System.out.println(NeuralNetwork.getFromFile("best.nn")); + ind.getNN().setLayers(NeuralNetwork.getFromFile("best.nn").getLayers()); } catch (EOFException e) { e.printStackTrace(); } - + /*/ +// System.out.println(ind.getNN().getLayers().get(0).get(0).getBias()); futures.add(service.submit(ind)); } firstTime = false; @@ -85,7 +87,8 @@ private void main() throws InterruptedException, ExecutionException { break; } } -// individuals.get(0).getNN().save("best.nn"); + + individuals.get(0).getNN().save("best.nn"); System.out.println("Generation Score: " + (mean / individuals.size())); System.out.println("Best Fitness: "+ (best)); System.out.println("Old best: " + (oldBest)); @@ -131,16 +134,16 @@ private void select() { // theBest.add(new Individual(m1)); // theBest.add(new Individual(m2)); // } - for (int i = 0; i < 3; i++) + for (int i = 0; i < initSize / 3 + 1; i++) theBest.add(individuals.get(i)); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < initSize * 2 / 3 + 1; i++) { NeuralNetwork m1 = NeuralNetwork.reproduce(individuals.get(i).getNN(), individuals.get(i+1).getNN(), mutationRate); theBest.add(new Individual(m1)); } while (theBest.size() < initSize) { - //System.out.println("WAITING HERE"); + System.out.println("WAITING HERE"); theBest.add(new Individual(numInputs)); } System.out.println(theBest); From 9cd3232ee0c3e43f39665faffbe446d0f97e4dae Mon Sep 17 00:00:00 2001 From: IceGawd <35550454+IceGawd@users.noreply.github.com> Date: Wed, 29 May 2019 13:41:13 -0700 Subject: [PATCH 3/3] pat patpatpat