PDA

View Full Version : Node network

Animekitty
17th-July-2013, 07:36 AM
This is a picture from the code in the spoiler. I would like your opinion on what it represents as a computational construct. Currently it has no learning rules and is a little bit blurry as a png file.

http://www.intpforum.com/picture.php?albumid=198&pictureid=1992

import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;

public class Colors extends JComponent implements Runnable {
int[][] Data1 = new int[300][300];
int[][] Data2 = new int[300][300];

public Colors() {
generateData();
}

public void run() {
while (true) {
repaint();
changeData();
try {
}
catch (InterruptedException e) {}
}
}

public void generateData() {
Random generator = new Random();

for (int x=0; x<300; x++) {
for (int y=0; y<300; y++) {
Data1[x][y] = generator.nextInt(255);
Data2[x][y] = generator.nextInt(255);
}
}
}

public void changeData() {

Random generator = new Random();

for (int x = 1; x < 299; x++) {
for (int y = 1; y < 299; y++) {
Data1[x][y] = (Data2[x-1][y-1]+
Data2[x][y-1]+
Data2[x][y+1]+
Data2[x-1][y]+
Data2[x-1][y+1]+
Data2[x+1][y]+
Data2[x+1][y-1]+
Data2[x+1][y+1])/9;

if(Data1[x][y]>=Data2[x][y]){
Data2[x][y]=Data1[x][y];
}else{
Data2[x][y] = generator.nextInt(255);
}
}
}
for (int x = 1; x < 299; x++) {
for (int y = 1; y < 299; y++) {
Data2[x][y] = (Data1[x-1][y-1]+
Data1[x][y-1]+
Data1[x][y+1]+
Data1[x-1][y]+
Data1[x-1][y+1]+
Data1[x+1][y]+
Data1[x+1][y-1]+
Data1[x+1][y+1])/9;

if(Data2[x][y]>=Data1[x][y]){
Data1[x][y]=Data2[x][y];
}else{
Data1[x][y] = generator.nextInt(255);
}
}
}
}

public void paint(Graphics g) {
for (int x = 0; x < 300; x++) {
for (int y = 0; y < 300; y++) {
g.setColor(new Color(0,Data1[x][y],0));
g.fillRect(x, y, 1, 1);
g.setColor(new Color(0,0,0));
g.drawRect(0, 0, 299, 299);
}
}
}

public static void main(String[] args) {
JFrame f = new JFrame("Colors");
f.setSize(333, 328);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}

walfin
17th-July-2013, 06:24 PM
1. You are averaging the pixels around each pixel? But you are dividing by 9, not 8. Is that intentional?
2. Suggest using BufferedImage rather than 1x1 fillRect calls.

Not sure what you're trying to represent though. A population with a hidden influence?

Animekitty
17th-July-2013, 06:56 PM
1. You are averaging the pixels around each pixel? But you are dividing by 9, not 8. Is that intentional?
2. Suggest using BufferedImage rather than 1x1 fillRect calls.

Not sure what you're trying to represent though. A population with a hidden influence?

I find that when I run the program as is it reminds me of neural spiking. If run with 8 instead of 9 it looks like mold. I'm not a programmer so this as far as I can go.

I mostly don't know how to serialize my ideas. They are all parallelised and visual.