Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » running in eclipse vs terminal(problem)
running in eclipse vs terminal [message #1858096] Wed, 15 March 2023 16:26 Go to next message
Warren Trammell is currently offline Warren TrammellFriend
Messages: 3
Registered: March 2023
Junior Member
I am a 99 yer old WW2 vet who dabbles on a Mac
My latest code runs in Terminal in less than 3 minutes and when complied and run in eclipse takes over 20 minutes. Any thoughts?????./

package able;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.time.LocalTime;

public class Able extends JPanel {
private static final long serialVersionUID = 1L;
static int X = 379;
static int Y = 195;
static int z = 0;
static int Z = 0;
static int LOR = 1;
static int finish = 1000;
static int start = 0;
static int[][] grid = new int[Y][X];
static int[][] future = new int[Y][X];
static int[][] temp = new int[10][40];
static int[][] temp0 = new int[10][40];
static int[][] temp1 = new int[10][40];
static int[][] temp2 = new int[10][40];
static int[][] temp3 = new int[10][40];
static Color[] colorBase = new Color[7];
static int pass;
static double time1;
static double time2;
static boolean Run = true;
static boolean jump;
static boolean[] cnt = new boolean[90];

public static void main(String[] args) throws InterruptedException {
for (int a = 30; a < 90; a++)
cnt[a] = true;
Scanner scan = new Scanner(System.in);
int red = 255;
int green = 255;
int blue = 255;
colorBase[0] = new Color(red, green, blue);
red = 169;
green = 39;
blue = 19;
colorBase[1] = new Color(red, green, blue);
red = 255;
green = 0;
blue = 0;
colorBase[2] = new Color(red, green, blue);
red = 255;
green = 0;
blue = 0;
colorBase[3] = new Color(red, green, blue);
red = 0;
green = 0;
blue = 255;
colorBase[4] = new Color(red, green, blue);
red = 0;
green = 0;
blue = 0;
colorBase[5] = new Color(red, green, blue);
red = 235;
green = 235;
blue = 235;
colorBase[6] = new Color(red, green, blue);
System.out.print(" Enter 0 to start at beginning!");
System.out.println(" Enter 1 to restart ");
int ans = scan.nextInt();
if (ans == 0) {
Run = true;
start = 0;
}
if (ans == 1) {
Run = false;
start = finish;
finish = finish + 20;
}

if (Run) {
temp0[5][1] = 1;
temp0[5][2] = 1;
temp0[6][2] = 1;
temp0[5][8] = 1;
temp0[6][8] = 1;
temp0[7][8] = 1;
temp0[4][9] = 1;
temp0[5][9] = 1;
temp0[7][9] = 1;
temp0[8][9] = 1;
temp0[4][10] = 1;
temp0[5][10] = 1;
temp0[7][10] = 1;
temp0[8][10] = 1;
temp0[4][11] = 1;
temp0[5][11] = 1;
temp0[6][11] = 1;
temp0[7][11] = 1;
temp0[8][11] = 1;
temp0[3][12] = 1;
temp0[4][12] = 1;
temp0[8][12] = 1;
temp0[9][12] = 1;
temp0[5][15] = 1;
temp0[6][15] = 1;
temp0[4][16] = 1;
temp0[5][16] = 1;
temp0[6][16] = 1;
temp0[7][16] = 1;
temp0[8][16] = 1;
temp0[4][17] = 1;
temp0[6][18] = 1;
temp0[7][18] = 1;
temp0[8][18] = 1;
temp0[8][19] = 1;
temp0[6][20] = 1;
temp0[7][20] = 1;
temp0[6][21] = 1;
temp0[7][21] = 1;
temp0[1][24] = 1;
temp0[2][24] = 1;
temp0[6][24] = 1;
temp0[7][24] = 1;
temp0[1][25] = 1;
temp0[3][25] = 1;
temp0[5][25] = 1;
temp0[7][25] = 1;
temp0[2][26] = 1;
temp0[3][26] = 1;
temp0[4][26] = 1;
temp0[5][26] = 1;
temp0[6][26] = 1;
temp0[3][27] = 1;
temp0[4][27] = 1;
temp0[5][27] = 1;
temp0[4][28] = 1;
temp0[3][35] = 1;
temp0[4][35] = 1;
temp0[3][36] = 1;
temp0[4][36] = 1;

// Set UL grid to pattern
for (int b = 0; b < 10; b++) {
for (int a = 0; a < 40; a++) {
grid[b][a + 2] = temp0[b][a];
}
}
} else
System.exit(9);
JFrame f = new JFrame();
f.getContentPane().setLayout(new FlowLayout());
BufferedImage image = new BufferedImage(1925, 1000, BufferedImage.TYPE_INT_RGB);
f.add(new JLabel(new ImageIcon(image)));
f.pack();
// display pattern grid
for (int b = 0; b < Y; b++) {
for (int a = 0; a < X; a++) {
for (int y = (5 * b); y < (5 * b) + 5; y++) {
for (int x = (5 * a); x < (5 * a) + 5; x++) {
if (grid[b][a] == 0)
image.setRGB(x, y, colorBase[0].getRGB());
if (grid[b][a] == 1)
image.setRGB(x, y, colorBase[LOR].getRGB());
}
}
}
}
f.setVisible(true);
flop(40, 10, temp0, temp1);
flip(40, 10, temp0, temp2);
flop(40, 10, temp2, temp3);
LocalTime oneObj = LocalTime.now();
System.out.println(oneObj);
for (z = start; z < finish; z++) {
// Loop through every cell
jump = false;
for (int y = 1; y < Y - 1; y++) {
for (int x = 1; x < X - 1; x++) {
// finding # Of neighbors that are alive
int aliveNeighbours = 0;
for (int i = -1; i <= 1; i++)
for (int j = -1; j <= 1; j++)
aliveNeighbours += grid[y + i][x + j];
// Consider Ref Cell as it was counted
if (grid[y][x] == 1)
aliveNeighbours -= grid[y][x];
// Implementing the Rules of Life
// Cell is lonely and dies
if ((grid[y][x] == 1) && (aliveNeighbours < 2))
future[y][x] = 0;
// Cell dies due to over population
else if ((grid[y][x] == 1) && (aliveNeighbours > 3))
future[y][x] = 0;
// A new cell is born
else if ((grid[y][x] == 0) && (aliveNeighbours == 3))
future[y][x] = 1;
// Remains the same
else
future[y][x] = grid[y][x];
}
}
for (int b = 0; b < Y; b++) {
for (int a = 0; a < X; a++) {
// setting future to grid
grid[b][a] = future[b][a];
}
}
if (z > 729) {
if (grid[190][204] == 1) {
for (int y = 188; y <= 192; y++) {
for (int x = 202; x <= 206; x++) {
grid[y][x] = 0;
}
}
grid[188][207] = 1;
grid[188][208] = 1;
grid[189][206] = 1;
grid[189][208] = 1;
grid[190][208] = 1;
if (cnt[0]) {
System.out.println("One " + z);
cnt[0] = false;
}
}
if (z > 1310) {
if (grid[44][354] == 1) {
for (int y = 42; y <= 46; y++) {
for (int x = 352; x <= 356; x++) {
grid[y][x] = 0;
}
}
grid[40][355] = 1;
grid[40][356] = 1;
grid[41][355] = 1;
grid[41][357] = 1;
grid[42][355] = 1;
if (cnt[1]) {
System.out.println("Two " + z);
cnt[1] = false;
}
}
if (z > 1444) {
if (grid[7][321] == 1) {
for (int y = 5; y <= 9; y++) {
for (int x = 319; x <= 323; x++) {
grid[y][x] = 0;
}
}
grid[5][316] = 1;
grid[6][316] = 1;
grid[6][318] = 1;
grid[7][316] = 1;
grid[7][317] = 1;
if (cnt[2]) {
System.out.println("Three " + z);
cnt[2] = false;
}
}
if (z > 2022) {
if (grid[151][171] == 1) {
for (int y = 149; y <= 153; y++) {
for (int x = 169; x <= 173; x++) {
grid[y][x] = 0;
}
}
grid[157][163] = 1;
grid[158][163] = 1;
grid[158][165] = 1;
grid[159][163] = 1;
grid[159][164] = 1;
if (cnt[3]) {
System.out.println("Four " + z);
cnt[3] = false;
}
}
if (z > 2146) {
if (grid[190][132] == 1) {
for (int y = 188; y <= 192; y++) {
for (int x = 130; x <= 134; x++) {
grid[y][x] = 0;
}
}
grid[188][128] = 1;
grid[188][129] = 1;
grid[189][128] = 1;
grid[189][130] = 1;
grid[190][128] = 1;
if (cnt[4]) {
System.out.println("Five " + z);
cnt[4] = false;
}
}
if (z > 2634) {
if (grid[66][6] == 1) {
for (int y = 64; y <= 68; y++) {
for (int x = 4; x <= 8; x++) {
grid[y][x] = 0;
}
}
grid[63][6] = 1;
grid[63][7] = 1;
grid[64][5] = 1;
grid[64][7] = 1;
grid[65][7] = 1;
if (cnt[5]) {
System.out.println("Six " + z);
cnt[5] = false;
}
}
if (z > 2772) {
if (grid[29][42] == 1) {
for (int y = 27; y <= 31; y++) {
for (int x = 40; x <= 44; x++) {
grid[y][x] = 0;
}
}
grid[22][48] = 1;
grid[22][49] = 1;
grid[23][47] = 1;
grid[23][49] = 1;
grid[24][49] = 1;
if (cnt[6]) {
System.out.println("Seven " + z);
cnt[6] = false;
}
}
if (z > 2840) {
if (grid[5][66] == 1) {
for (int y = 3; y <= 7; y++) {
for (int x = 64; x <= 68; x++) {
grid[y][x] = 0;
}
}
grid[5][69] = 1;
grid[6][67] = 1;
grid[6][69] = 1;
grid[7][68] = 1;
grid[7][69] = 1;
if (cnt[7]) {
System.out.println("Eight " + z);
cnt[7] = false;
}
}
if (z > 3320) {
if (grid[127][189] == 1) {
for (int y = 125; y <= 129; y++) {
for (int x = 187; x <= 191; x++) {
grid[y][x] = 0;
}
}
grid[134][200] = 1;
grid[135][198] = 1;
grid[135][200] = 1;
grid[136][199] = 1;
grid[136][200] = 1;
if (cnt[8]) {
System.out.println("Nine " + z);
cnt[8] = false;
}
}
if (z > 3426) {
if (grid[162][227] == 1) {
for (int y = 160; y <= 164; y++) {
for (int x = 225; x <= 229; x++) {
grid[y][x] = 0;
}
}
grid[170][237] = 1;
grid[171][235] = 1;
grid[171][237] = 1;
grid[172][236] = 1;
grid[172][237] = 1;
if (cnt[9]) {
System.out.println("Ten " + z);
cnt[9] = false;
}
}
if (z > 3498) {
if (grid[190][255] == 1) {
for (int y = 188; y <= 192; y++) {
for (int x = 253; x <= 257; x++) {
grid[y][x] = 0;
}
}
grid[188][258] = 1;
grid[188][259] = 1;
grid[189][257] = 1;
grid[189][259] = 1;
grid[190][259] = 1;
if (cnt[10]) {
System.out.println("Eleven " + z);
cnt[10] = false;
}
}
if (z > 3919) {
if (grid[84][365] == 1) {
for (int y = 82; y <= 86; y++) {
for (int x = 363; x <= 367; x++) {
grid[y][x] = 0;
}
}
grid[80][363] = 1;
grid[80][364] = 1;
grid[81][363] = 1;
grid[81][365] = 1;
grid[82][363] = 1;
if (cnt[11]) {
System.out.println("Twelve " + z);
cnt[11] = false;
}
}
if (z > 4006) {
if (grid[58][342] == 1) {
for (int y = 56; y <= 60; y++) {
for (int x = 340; x <= 344; x++) {
grid[y][x] = 0;
}
}
grid[49][332] = 1;
grid[49][333] = 1;
grid[50][332] = 1;
grid[50][334] = 1;
grid[51][332] = 1;
if (cnt[12]) {
System.out.println("Thirteen " + z);
cnt[12] = false;
}
}
if (z > 4110) {
if (grid[23][306] == 1) {
for (int y = 21; y <= 25; y++) {
for (int x = 304; x <= 308; x++) {
grid[y][x] = 0;
}
}
grid[13][296] = 1;
grid[13][297] = 1;
grid[14][296] = 1;
grid[14][298] = 1;
grid[15][296] = 1;
if (cnt[13]) {
System.out.println("Fourteen " + z);
cnt[13] = false;
}
}
if (z > 4141) {
if (grid[5][289] == 1) {
for (int y = 3; y <= 7; y++) {
for (int x = 287; x <= 291; x++) {
grid[y][x] = 0;
}
}
grid[5][285] = 1;
grid[6][285] = 1;
grid[6][287] = 1;
grid[7][285] = 1;
grid[7][286] = 1;
if (cnt[14]) {
System.out.println("Fifteen " + z);
cnt[14] = false;
}
}
if (z > 4557) {
if (grid[111][181] == 1) {
for (int y = 109; y <= 113; y++) {
for (int x = 179; x <= 183; x++) {
grid[y][x] = 0;
}
}
grid[120][172] = 1;
grid[121][172] = 1;
grid[121][174] = 1;
grid[122][172] = 1;
grid[122][173] = 1;
if (cnt[15]) {
System.out.println("Sixteen " + z);
cnt[15] = false;
}
}
if (z > 4615) {
if (grid[136][157] == 1) {
for (int y = 134; y <= 138; y++) {
for (int x = 155; x <= 159; x++) {
grid[y][x] = 0;
}
}
grid[146][146] = 1;
grid[147][146] = 1;
grid[147][148] = 1;
grid[148][146] = 1;
grid[148][147] = 1;
if (cnt[16]) {
System.out.println("Seventeen " + z);
cnt[16] = false;
}
}
if (z > 4721) {
if (grid[174][119] == 1) {
for (int y = 172; y <= 176; y++) {
for (int x = 117; x <= 121; x++) {
grid[y][x] = 0;
}
}
grid[181][110] = 1;
grid[182][110] = 1;
grid[182][112] = 1;
grid[183][110] = 1;
grid[183][111] = 1;
if (cnt[17]) {
System.out.println("Eighteen " + z);
cnt[17] = false;
}
}
if (z > 4748) {
if (grid[190][104] == 1) {
for (int y = 188; y <= 192; y++) {
for (int x = 102; x <= 106; x++) {
grid[y][x] = 0;
}
}
grid[188][100] = 1;
grid[188][101] = 1;
grid[189][100] = 1;
grid[189][102] = 1;
grid[190][100] = 1;
if (cnt[18]) {
System.out.println("Nineteen " + z);
cnt[18] = false;
}
}
if (z > 5126) {
if (grid[94][5] == 1) {
for (int y = 92; y <= 96; y++) {
for (int x = 3; x <= 7; x++) {
grid[y][x] = 0;
}
}
grid[91][6] = 1;
grid[91][7] = 1;
grid[92][5] = 1;
grid[92][7] = 1;
grid[93][7] = 1;
if (cnt[19]) {
System.out.println("Twenty " + z);
cnt[19] = false;
}
}
if (z > 5156) {
if (grid[84][15] == 1) {
for (int y = 82; y <= 86; y++) {
for (int x = 13; x <= 17; x++) {
grid[y][x] = 0;
}
}
grid[75][23] = 1;
grid[75][24] = 1;
grid[76][22] = 1;
grid[76][24] = 1;
grid[77][24] = 1;
if (cnt[20]) {
System.out.println("Twentyone "+ z);
cnt[20] = false;
}
}
if (z > 5276) {
if (grid[45][54] == 1) {
for (int y = 43; y <= 47; y++) {
for (int x = 52; x <= 56; x++) {
grid[y][x] = 0;
}
}
grid[36][65] = 1;
grid[36][66] = 1;
grid[37][64] = 1;
grid[37][66] = 1;
grid[38][66] = 1;
if (cnt[21]) {
System.out.println("Twentytwo "+ z);
cnt[21] = false;
}
}
if (z > 5329) {
if (grid[24][80] == 1) {
for (int y = 22; y <= 26; y++) {
for (int x = 78; x <= 82; x++) {
grid[y][x] = 0;
}
}
grid[13][89] = 1;
grid[13][90] = 1;
grid[14][88] = 1;
grid[14][90] = 1;
grid[15][90] = 1;
if (cnt[22]) {
System.out.println("Twentythree "+ z);
cnt[22] = false;
}
}
if (z > 5360) {
if (grid[5][97] == 1) {
for (int y = 3; y <= 7; y++) {
for (int x = 95; x <= 99; x++) {
grid[y][x] = 0;
}
}
grid[5][101] = 1;
grid[6][99] = 1;
grid[6][101] = 1;
grid[7][100] = 1;
grid[7][101] = 1;
if (cnt[23]) {
System.out.println("Twentyfour "+ z);
cnt[23] = false;
}
}
if (z > 5712) {
if (grid[95][189] == 1) {
for (int y = 93; y <= 97; y++) {
for (int x = 187; x <= 191; x++) {
grid[y][x] = 0;
}
}
grid[102][198] = 1;
grid[103][196] = 1;
grid[103][198] = 1;
grid[104][197] = 1;
grid[104][198] = 1;
if (cnt[24]) {
System.out.println("Twentyfive "+ z);
cnt[24] = false;
}
}
if (z > 5742) {
if (grid[111][206] == 1) {
for (int y = 109; y <= 113; y++) {
for (int x = 204; x <= 208; x++) {
grid[y][x] = 0;
}
}
grid[118][215] = 1;
grid[119][213] = 1;
grid[119][215] = 1;
grid[120][214] = 1;
grid[120][215] = 1;
if (cnt[25]) {
System.out.println(" Twentysix "+ z);
cnt[25] = false;
}
}
if (z > 5852) {
if (grid[147][243] == 1) {
for (int y = 145; y <= 149; y++) {
for (int x = 241; x <= 245; x++) {
grid[y][x] = 0;
}
}
grid[155][253] = 1;
grid[156][251] = 1;
grid[156][253] = 1;
grid[157][252] = 1;
grid[157][253] = 1;
if (cnt[26]) {
System.out.println("Twentyseven "+ z);
cnt[26] = false;
}
}
if (z > 5915) {
if (grid[173][268] == 1) {
for (int y = 171; y <= 175; y++) {
for (int x = 266; x <= 270; x++) {
grid[y][x] = 0;
}
}
grid[180][278] = 1;
grid[181][276] = 1;
grid[181][278] = 1;
grid[182][277] = 1;
grid[182][278] = 1;
if (cnt[27]) {
System.out.println(" Twentyeight "+ z);
cnt[27] = false;
}
}
if (z > 5946) {
if (grid[190][285] == 1) {
for (int y = 188; y <= 192; y++) {
for (int x = 283; x <= 287; x++) {
grid[y][x] = 0;
}
}
grid[188][288] = 1;
grid[188][289] = 1;
grid[189][287] = 1;
grid[189][289] = 1;
grid[190][289] = 1;
if (cnt[28]) {
System.out.println("Twentynine "+ z);
cnt[28] = false;
}
}
if (z > 6247) {
if (grid[114][365] == 1) {
for (int y = 112; y <= 116; y++) {
for (int x = 363; x <= 367; x++) {
grid[y][x] = 0;
}
}
grid[110][363] = 1;
grid[110][364] = 1;
grid[111][363] = 1;
grid[111][365] = 1;
grid[112][363] = 1;
if (cnt[29]) {
System.out.println("Thirty " + z);
cnt[29] = false; }
}
if (z > 6285) {
if (grid[101][353] == 1) {
for (int y = 99; y <= 103; y++) {
for (int x = 351; x <= 355; x++) {
grid[y][x] = 0;
}
}
grid[93][344] = 1;
grid[93][345] = 1;
grid[94][344] = 1;
grid[94][346] = 1;
grid[95][344] = 1;
if (cnt[30]) {
System.out.println("Thirtyone "+ z);
cnt[30] = false;
}
}
if (z > 6351) {
if (grid[77][327] == 1) {
for (int y = 75; y <= 79; y++) {
for (int x = 325; x <= 329; x++) {
grid[y][x] = 0;
}
}
grid[67][317] = 1;
grid[67][318] = 1;
grid[68][317] = 1;
grid[68][319] = 1;
grid[69][317] = 1;
if (cnt[31]) {
System.out.println("Thirtytwo "+ z);
cnt[31] = false;
}
}
if (z > 6463) {
if (grid[39][289] == 1) {
for (int y = 37; y <= 41; y++) {
for (int x = 287; x <= 291; x++) {
grid[y][x] = 0;
}
}
grid[30][280] = 1;
grid[30][281] = 1;
grid[31][280] = 1;
grid[31][282] = 1;
grid[32][280] = 1;
if (cnt[32]) {
System.out.println("Thirtythree "+ z);
cnt[32] = false;
}
}
if (z > 6489) {
if (grid[24][273] == 1) {
for (int y = 22; y <= 26; y++) {
for (int x = 271; x <= 275; x++) {
grid[y][x] = 0;
}
}
grid[15][267] = 1;
grid[15][268] = 1;
grid[16][267] = 1;
grid[16][269] = 1;
grid[17][267] = 1;
if (cnt[33]) {
System.out.println("Thirtyfour "+ z);
cnt[33] = false;
}
}
if (z > 6528) {
if (grid[5][258] == 1) {
for (int y = 3; y <= 7; y++) {
for (int x = 256; x <= 260; x++) {
grid[y][x] = 0;
}
}
grid[5][254] = 1;
grid[6][254] = 1;
grid[6][256] = 1;
grid[7][254] = 1;
grid[7][255] = 1;
if (cnt[34]) {
System.out.println("Thirtyfive " + z);
cnt[34] = false;
}
}
System.out.println("Got Here 6528 " );
if (z > 6822) {
if (grid[80][180] == 1) {
for (int y = 78; y <= 82; y++) {
for (int x = 178; x <= 182; x++) {
grid[y][x] = 0;
}
}
grid[87][171] = 1;
grid[88][171] = 1;
grid[88][173] = 1;
grid[89][171] = 1;
grid[89][172] = 1;
if (cnt[35]) {
System.out.println("Thirtysix "+ z);
cnt[35] = false;
}
}
System.out.println("Got Here 6822 " );
if (z > 6852) {
if (grid[96][163] == 1) {
for (int y = 94; y <= 98; y++) {
for (int x = 161; x <= 165; x++) {
grid[y][x] = 0;
}
}
grid[103][156] = 1;
grid[104][156] = 1;
grid[104][158] = 1;
grid[105][156] = 1;
grid[105][157] = 1;
if (cnt[36]) {
System.out.println("Thirtyseven "+ z);
cnt[36] = false;
}
}
System.out.println("Got Here 6852 " );
if (z > 6912) {
if (grid[120][141] == 1) {
for (int y = 118; y <= 122; y++) {
for (int x = 139; x <= 143; x++) {
grid[y][x] = 0;
}
}
grid[127][132] = 1;
grid[128][132] = 1;
grid[128][134] = 1;
grid[129][132] = 1;
grid[129][133] = 1;
if (cnt[37]) {
System.out.println("Thirtyeight "+ z);
cnt[37] = false;
}
}
System.out.println("Got Here 6912 " );
if (z == 6950) {
// Set LL grid to pattern
for (int b = 0; b < 10; b++) {
for (int a = 0; a < 40; a++) {
grid[b + 184][a + 2] = temp1[b][a];
}
}
// display pattern grid
for (int b = 0; b < Y; b++) {
for (int a = 0; a < X; a++) {
for (int y = (5 * b); y < (5 * b) + 5; y++) {
for (int x = (5 * a); x < (5 * a) + 5; x++) {
if (grid[b][a] == 0)
image.setRGB(x, y, colorBase[0].getRGB());
if (grid[b][a] == 1)
image.setRGB(x, y, colorBase[LOR].getRGB());
}
}
}
}
}





}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}



for (int b = 0; b < Y; b++) {
for (int a = 0; a < X; a++) {
for (int y = (5 * b); y < (5 * b) + 5; y++) {
for (int x = (5 * a); x < (5 * a) + 5; x++) {
if (grid[b][a] == 0)
image.setRGB(x, y, colorBase[0].getRGB());
if (grid[b][a] == 1)
image.setRGB(x, y, colorBase[LOR].getRGB());
if (grid[b][a] == 2)
image.setRGB(x, y, colorBase[2].getRGB());
}
}
}
}

f.add(new JLabel(new ImageIcon(image)));
f.setVisible(true);
}
scan.close();
System.out.println(" scan Closed!!!");

LocalTime treObj = LocalTime.now();
System.out.println(treObj);

try {
Thread.sleep(12000);
} catch (InterruptedException e) {
System.out.println(e);
}
System.exit(9);
}

public static void flip(int X, int Y, int C[][], int D[][]) {
// reverse array horizontally
for (int y = 0; y < Y; y++) {
for (int x = 0; x < X; x++) {
D[y][x] = C[y][(X - 1 - x)];
}
}
}

public static void flop(int X, int Y, int C[][], int D[][]) {
// reverse array Vertically0

for (int y = 0; y < Y; y++) {
for (int x = 0; x < X; x++) {
D[y][x] = C[(Y - 1 - y)][x];
}
}
}


}


Re: running in eclipse vs terminal [message #1858112 is a reply to message #1858096] Thu, 16 March 2023 07:48 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 149
Registered: October 2018
Senior Member
Hi there,

I am a 71+ year junior and I will try to help.(Only minor wars... Yom Kippur War etc. )

I copied the code from the post (Wow a lot of nesting code...)

This what I got:

index.php/fa/43026/0/

index.php/fa/43027/0/

I hope this is helpful.
Re: running in eclipse vs terminal [message #1858171 is a reply to message #1858112] Sun, 19 March 2023 18:42 Go to previous messageGo to next message
Warren Trammell is currently offline Warren TrammellFriend
Messages: 3
Registered: March 2023
Junior Member
Did you run it after compiling with eclipse? When I run it I eclipse I get a much longer run time then you show here plus there should be more in the display than you show here
Re: running in eclipse vs terminal [message #1858174 is a reply to message #1858171] Mon, 20 March 2023 07:05 Go to previous message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 149
Registered: October 2018
Senior Member
Hi there,

I get similar result (times, displayed graphics) in eclipse and when using java -jar able.jar.
I was intrigue by your "Game of Life" so I wrote my version, but I was intimidated by the loops, so I used object-oriented programming principle to make things simpler.

This is a sample:
index.php/fa/43035/0/

For GUI, I use JavaFX.

I have here a grid of 20,000 cells that each one knows about its neighbors and their status (dead or alive). So it is very easy to loop after each generation and apply the fate of each cell.

Regards





Previous Topic:Eclipse SDK 4.26 for Java spell check flags "@param " in javadoc as misspelled: how to fix
Next Topic:Unable to install addon on eclipse 2022-06
Goto Forum:
  


Current Time: Wed Jan 15 09:59:33 GMT 2025

Powered by FUDForum. Page generated in 0.03343 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top