You are not logged in.

  • Login

1

Sunday, October 21st 2012, 4:24pm

Kennt sich jemand mit Processing aus?

Hallo werte Masters-Gemeinde.

Kennt sich zufällig jemand mit der Programmiersprache Processing aus?
Ich habe hier eine Aufgabe gefasst, bei der ich keinen Schimmer habe wie ich diese lösen soll. (Bin Studienanfänger und wir hatten bis jetzt circa 3 Lektionen zu Processing - die Tutorials auf der Processing-HP habe ich abgeklappert, bin aber nicht fündig geworden). Im Anhang habe ich die Aufgabenstellung als Bild angefügt. Ich wäre um jede Hilfe dankbar, stehe gerade auf einem ziemlich verlorenen Posten, da wir in einem anderen Kurs gerade erst diese Woche Arrays (Java) behandeln und das ganze - für mich als gescheiterter Geisteswissenschaftler - doch ziemliches Neuland ist.



Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
int aufgabe = A; // A, B, C, D, E 

// Aufgabe 1a)
void setPixel(int x, int y, color pColor) {
  int index = 0;
  loadPixels();
  //=========//

  // Code!

  //=========//
  updatePixels();
}

// Aufgabe 1b)
int[] getWindow(int[] intArray, int windowSize, int offset) {
  int[] window = new int[windowSize];
  //========//

  // Code!

  //========//
  return window;
}

// Aufgabe 1c)
int binaryToDec(int[] bin) {
  int out = 0; 
  //=========//

  // Code!

  //=========//
  return out;
}

// Aufgabe 1d)
int interpretPattern(int[] window) {
  int out = 0; 
  //=========//

  // Code!

  //=========//
  return out;
}

// Aufgabe 1e)
int[] timeStep(int[] in) {
  int[] out = new int[in.length];
  //=========//

  // Code!

  //=========//
  return out;
}

//==================//
// Dont touch this! //
//==================//

public static final int SIZE = 257;

public static final int A = 0;
public static final int B = 1;
public static final int C = 2;
public static final int D = 3;
public static final int E = 4;

int[] rule90 = new int[] { 
  0, 1, 0, 1, 1, 0, 1, 0
};

int[] state;
int lineCount = 0;

void setup() {
  size(SIZE, SIZE);
  //frameRate(30);
  background(color(0, 0, 0));
  state = new int[width];
  state[width/2] = 1;
}

void draw() {
  switch(aufgabe) {
  case A:
	caseA();
	break;
  case B:
	caseB();
	break;
  case C:
	caseC();
	break;
  case D:
	caseD();
	break;
  case E:
	caseE();
	break;
  }
}

void caseA() {
  for (int q = -1; q < width+1; q++) {
	setPixel(q, height/2, color(255, 255, 255));
  }
  noLoop();
}

void caseB() {
  background(color(64, 64, 64));
  int[] testArray =  new int[width];
  int windowSize = 25;
  int[] window;
  for (int q = 0; q < testArray.length; q+=(q/4+1)) {
	testArray[q] = 1;
	for (int r = 0; r < height; r++) {
  	setPixel(q, r, color(128, 128, 128));
	}
  }
  for (int q = 0; q < width; q++) {
	window = getWindow(testArray, windowSize, q);
	for (int r = 0; r < window.length; r++) {
  	if (window[r] == 1)
    	setPixel(q+r-windowSize/2, q, color(0, 0, 0));
  	else
    	setPixel(q+r-windowSize/2, q, color(255, 255, 255));
	}
  }
  noLoop();
}

void caseC() {
  text(String.format("0b00101010 = %d", binaryToDec(new int[] { 
	0, 0, 1, 0, 1, 0, 1, 0
  }
  )), 
  10, 30);
  noLoop();
}

void caseD() {
  fill(255, 255, 255);
  text(String.format("000 ? %b", interpretPattern(new int[] { 
	0, 0, 0
  }
  ) == rule90[0]), 10, 30);
  text(String.format("001 ? %b", interpretPattern(new int[] { 
	0, 0, 1
  }
  ) == rule90[1]), 10, 50);
  text(String.format("010 ? %b", interpretPattern(new int[] { 
	0, 1, 0
  }
  ) == rule90[2]), 10, 70);
  text(String.format("011 ? %b", interpretPattern(new int[] { 
	0, 1, 1
  }
  ) == rule90[3]), 10, 90);
  text(String.format("100 ? %b", interpretPattern(new int[] { 
	1, 0, 0
  }
  ) == rule90[4]), 10, 110);
  text(String.format("101 ? %b", interpretPattern(new int[] { 
	1, 0, 1
  }
  ) == rule90[5]), 10, 130);
  text(String.format("110 ? %b", interpretPattern(new int[] { 
	1, 1, 0
  }
  ) == rule90[6]), 10, 150);
  text(String.format("111 ? %b", interpretPattern(new int[] { 
	1, 1, 1
  }
  ) == rule90[7]), 10, 170);
  noLoop();
}

void caseE() {
  if (lineCount < height) {
	for (int q = 0; q < width; q++) {
  	if (state[q] == 1)
    	setPixel(q, lineCount, color(255, 255, 255));
	}
	state = timeStep(state);
  }
  else {
	lineCount = -1;
	for (int q = 0; q < rule90.length; q++) {
  	rule90[q] = (int)(Math.random()*2);
	}
	for (int q = 0; q < state.length; q++) {
  	state[q] = (int)(Math.random()*2);
	}
	background(color(0, 0, 0));
  }
  lineCount++;
}
[*HS*] Anti has attached the following file:
  • procesueb4.jpg (187.55 kB - 109 times downloaded - latest: Jun 14th 2023, 10:48am)


AoCBox - think outside the box!

Juzam

Sage

Posts: 3,875

Location: Flensburg

Occupation: GER

  • Send private message

2

Sunday, October 21st 2012, 4:36pm

Unterscheidet sich ja kaum von C.
Wie sollen die denn umgerechnet werden(Aufgabe 1a)? X/Y Koordinaten dann im Array als [XY]? Das kannste ja mit ner Schleife machen.
Lernen wir besser uns freuen,
so verlernen wir am besten,
anderen weh zu tun.
(Nietzsche)

3

Sunday, October 21st 2012, 4:47pm

Die Aufgabe 1 hat recht wenig mit dieser zu tun. Da ging es halt um Bilder-Import. Keine Ahnung wieso die diese Aufgabe auch so genannt haben.

Habe keine anderen Angaben zu der Aufgabe gekriegt. Alle verfügbaren Infos habe ich als Bild angehängt.


AoCBox - think outside the box!

Posts: 3,935

Location: Berlin

Occupation: /dev/random

  • Send private message

4

Sunday, October 21st 2012, 5:18pm

Unterscheidet sich ja kaum von C.

Processing ist eine vereinfachte Version von Java ;).

Juzam

Sage

Posts: 3,875

Location: Flensburg

Occupation: GER

  • Send private message

5

Sunday, October 21st 2012, 5:39pm

Auch gut ;)
Außer ein paar Eclipse Programme zu bearbeiten, hatte ich bisher nicht viel mit Java zu tun. Eher C/C++.
Lernen wir besser uns freuen,
so verlernen wir am besten,
anderen weh zu tun.
(Nietzsche)

kOa_Mjöllnir

Intermediate

Posts: 502

Location: Hansestadt Rostock

Occupation: GER

  • Send private message

6

Monday, October 22nd 2012, 2:26am

http://pastebin.com/NTGuVKxQ Aufgabe A als Start. Wenn du es ausführst, siehst du eine weiße Linie.

Similar threads