From 81da9e247a8c44a4eb62856e487933f19615018a Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 29 Sep 2021 23:32:17 +0200 Subject: [PATCH] Random Bug Found. method nextGen() could be the cought --- src/game/Clock.java | 2 +- src/game/Control.java | 33 ++++++++++++++++++++------------- src/game/StartMode.java | 2 +- src/gui/GUI.java | 5 ++++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/game/Clock.java b/src/game/Clock.java index db18d8f..206abde 100644 --- a/src/game/Clock.java +++ b/src/game/Clock.java @@ -24,7 +24,7 @@ public class Clock extends Thread{ } }; - t.scheduleAtFixedRate(tt, 1, 120); + t.scheduleAtFixedRate(tt, 1, 100000); } diff --git a/src/game/Control.java b/src/game/Control.java index 4cdbec7..e12382c 100644 --- a/src/game/Control.java +++ b/src/game/Control.java @@ -61,22 +61,27 @@ public class Control { } private void buildManuelGame() { - + System.out.println("Test"); } private void generateTask1() { - for (int x = 0; x < 6; x++) { - for (int y = 0; y < 6; y++) { - cells[x][y] = false; + for (int x = 0; x < xSize; x++) { + for (int y = 0; y < ySize; y++) { + cells[x][y] = true; } } - cells[1][2] = true; - cells[2][2] = true; - cells[2][4] = true; - cells[3][1] = true; - cells[3][3] = true; - cells[4][3] = true; +// cells[1][2] = true; +// cells[2][2] = true; +// cells[2][4] = true; +// cells[3][1] = true; +// cells[3][3] = true; +// cells[4][3] = true; + +// cells[1][0] = true; +// cells[1][1] = true; +// cells[1][2] = true; + syncCells(); } @@ -86,7 +91,7 @@ public class Control { int x = rand(0, this.xSize); int y = rand(0, this.ySize); if (!cells[x][y]) { - this.cells[x][y] = true; + cells[x][y] = true; } else { i--; } @@ -103,6 +108,10 @@ public class Control { } } + public boolean[][] getCells() { + return cells; + } + public boolean[][] nextGen() { gen ++; System.out.println("Generation:" + gen); @@ -136,8 +145,6 @@ public class Control { } } - - return cells; } diff --git a/src/game/StartMode.java b/src/game/StartMode.java index 86ccd66..d05fcb8 100644 --- a/src/game/StartMode.java +++ b/src/game/StartMode.java @@ -2,6 +2,6 @@ package game; public enum StartMode { - Manuel, Randomized, Task1, + Manuel, Randomized, Task1, Blinker, Toad } diff --git a/src/gui/GUI.java b/src/gui/GUI.java index f2e3148..5d5af23 100644 --- a/src/gui/GUI.java +++ b/src/gui/GUI.java @@ -223,7 +223,9 @@ public class GUI { modeBox = new JComboBox(); modeBox.setBounds(180, 257, 100, 20); addComboBoxEntry(modeBox, "Randomized"); - addComboBoxEntry(modeBox, "CTTask1"); + addComboBoxEntry(modeBox, "Task1"); + addComboBoxEntry(modeBox, "Blinker"); + addComboBoxEntry(modeBox, "Toad"); startButton = new JButton(); @@ -343,6 +345,7 @@ public class GUI { jfGame.setLocationRelativeTo(null); jfGame.setVisible(true); + } private void initGameComponents() {