-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessing.java
More file actions
189 lines (176 loc) · 5.27 KB
/
Copy pathProcessing.java
File metadata and controls
189 lines (176 loc) · 5.27 KB
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
import java.util.Random;
import org.jfugue.player.Player;
import processing.core.PApplet;
public class Processing extends PApplet{
private Player player= new Player();
private Square start = new Square(4, 4);
private int side = 5;
private Knight test = new Knight(start, side, side);
private int h=0;
private Square[] tour = test.solve();
private Random randy = new Random();
public void settings(){
size(600, 600);
}
public void setup(){
frameRate(1);
background(0,0,0);
noStroke();
for (int r=0; r<side;r++) {
if (r%2==0) {
for (int k=0; k<side; k++) {
if (k%2==1) {
fill(60,85,199);
rect(k*width/side,r*width/side,width/side,width/side);
}
else {
fill(203,240,247);
rect(k*width/side,r*width/side,width/side,width/side);
}
}
}
else {
for (int k=0; k<side; k++) {
if (k%2==0) {
fill(60,85,199);
rect(k*width/side,r*width/side,width/side,width/side);
}
else {
fill(203,240,247);
rect(k*width/side,r*width/side,width/side,width/side);
}
}
}
}
if (h>tour.length) {
player.play("I[Trumpet] Cq Cqq Cqqq");
}
}
public void light(int h) {
for (h=0; h<tour.length;h++) {
for (int r=0; r<side;r++) {
if (r%2==0) {
for (int k=0; k<side; k++) {
if (k%2==1) {
fill(20,29,107);
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
else {
fill(20,29,107);
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
}
}
else {
for (int k=0; k<side; k++) {
if (k%2==0) {
fill(20,29,107);
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
else {
fill(20,29,107);
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
}
}
// delay(500);
}
// delay(1000);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
PApplet.main("Processing");
}
public void draw() {
//repeating unless noloop() enabled
// noLoop();
// System.out.println(test.solve()[9]);
// System.out.println(Arrays.toString(test.solve()));
// player.play("C");
if (h<tour.length){
player.play("I14 Aqq");
for (int r=0; r<side;r++) {
if (r%2==0) {
for (int k=0; k<side; k++) {
if (k%2==1) {
fill(20,29,107);
stroke(255,255,255);
rect(tour[h].getCol()*width/side,tour[h].getRow()*width/side,width/side,width/side);
}
else {
fill(20,29,107);
rect(tour[h].getCol()*width/side,tour[h].getRow()*width/side,width/side,width/side);
}
}
}
else {
for (int k=0; k<side; k++) {
if (k%2==0) {
fill(20,29,107);
rect(tour[h].getCol()*width/side,tour[h].getRow()*width/side,width/side,width/side);
}
else {
fill(20,29,107);
rect(tour[h].getCol()*width/side,tour[h].getRow()*width/side,width/side,width/side);
}
}
}
// delay(500);
}}
// delay(1000);
h++;
if (h==tour.length) {
// noLoop();
// delay(500);
rect(0,0,width,width);
// delay(500);
textSize(24);
fill(255,255,255);
textAlign(CENTER,CENTER);
text("The Knight's Tour is Complete", width/2, width/2);
// player.play("V0 I[Trumpet] G3q. G3i G3sss G3i G3q E3i G3q E3i G3qqq V1 I[Trumpet] C4q. C4i C4sss C4i E3i D3i E3ii D3i E3i E3qqq V3 I[Trumpet] G4q. G4i G4sss G4i C4i B4q C4i B4q C4qqq");
player.play("V0 I[Trumpet] G5q. G5i G5sss G5i G5q E5i G5q E5i G5qqq V1 I[Trumpet] C5q. C5i C5sss C5i E5i D5i E5ii D5i E5i E5qqq V3 I[Trumpet] G4q. G4i G4sss G4i C5i B4q C5i B4q C5qqq");
h++;
}
if(h>tour.length) {
noStroke();
frameRate(3);
for (h=0; h<tour.length;h++) {
for (int r=0; r<side;r++) {
if (r%2==0) {
for (int k=0; k<side; k++) {
if (k%2==1) {
fill(randy.nextInt(255),randy.nextInt(255),randy.nextInt(255));
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
else {
fill(randy.nextInt(255),randy.nextInt(255),randy.nextInt(255));
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
}
}
else {
for (int k=0; k<side; k++) {
if (k%2==0) {
fill(randy.nextInt(255),randy.nextInt(255),randy.nextInt(255));
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
else {
fill(randy.nextInt(255),randy.nextInt(255),randy.nextInt(255));
rect(test.solve()[h].getCol()*width/side,test.solve()[h].getRow()*width/side,width/side,width/side);
}
}
}
}
}
fill(255,255,255);
text("The Knight's Tour is Complete", width/2, width/2);
// player.play("I[Trumpet] Cq Cqq Cqqq");
}
// throw new ArrayIndexOutOfBoundsException("Knight's Tour's is Complete");
// light();
// delay(500);
// println(frameCount);
}
}