Skip to content

Commit

Permalink
updated application
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelimza committed Sep 4, 2018
1 parent 85385a6 commit 65abc31
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
Binary file modified Application/GA2.exe
Binary file not shown.
Binary file modified Application/lib/GA2.jar
Binary file not shown.
18 changes: 13 additions & 5 deletions Application/source/Car.pde
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ class Car {
posCopy.add(heading);
//checking if the head of the posCopy vector lies in a wall
if (myMap.pixels[(int)posCopy.x + ((int)posCopy.y) * mapWidth] == -16777216) {
//fill(255, 0, 0);
//ellipse(posCopy.x, posCopy.y, 5, 5);
if (debugMode) {
fill(255, 0, 0);
ellipse(posCopy.x, posCopy.y, 5, 5);
}
//setting the proximity value to the iteration number aka distance in the heading direction
proximity[index][0] = i / 100.0;
return;
Expand All @@ -172,15 +174,21 @@ class Car {
heading.mult(100);
stroke(200, 100, 60);
//drawing for the -30 degree sensor
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 0);
//drawing for the +30 degree sensor
heading.rotate(PI / 3);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 2);
//drawing for the 0 degree sensor
heading.rotate(-PI / 6);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 1);
//println(proximity[0][0] + ", " + proximity[1][0] + ", " + proximity[2][0]);
}
Expand Down
20 changes: 15 additions & 5 deletions Application/source/GA2.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public void draw() {
line(828, 0, 828, 600);
fill(187, 252, 184, 150);
text("Gen: " + ga.generation, 0, 0);
text("Press 'd' to toggle", 842, 300);
text("debug mode.", 872, 330);
for (int i = 1; i < cars.length; i++) {
cars[i].update();
cars[i].show();
Expand Down Expand Up @@ -267,8 +269,10 @@ public void findDistance(PVector heading, int index) {
posCopy.add(heading);
//checking if the head of the posCopy vector lies in a wall
if (myMap.pixels[(int)posCopy.x + ((int)posCopy.y) * mapWidth] == -16777216) {
//fill(255, 0, 0);
//ellipse(posCopy.x, posCopy.y, 5, 5);
if (debugMode) {
fill(255, 0, 0);
ellipse(posCopy.x, posCopy.y, 5, 5);
}
//setting the proximity value to the iteration number aka distance in the heading direction
proximity[index][0] = i / 100.0f;
return;
Expand All @@ -283,15 +287,21 @@ public void drawSensors() {
heading.mult(100);
stroke(200, 100, 60);
//drawing for the -30 degree sensor
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 0);
//drawing for the +30 degree sensor
heading.rotate(PI / 3);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 2);
//drawing for the 0 degree sensor
heading.rotate(-PI / 6);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 1);
//println(proximity[0][0] + ", " + proximity[1][0] + ", " + proximity[2][0]);
}
Expand Down
2 changes: 2 additions & 0 deletions Application/source/GA2.pde
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void draw() {
line(828, 0, 828, 600);
fill(187, 252, 184, 150);
text("Gen: " + ga.generation, 0, 0);
text("Press 'd' to toggle", 842, 300);
text("debug mode.", 872, 330);
for (int i = 1; i < cars.length; i++) {
cars[i].update();
cars[i].show();
Expand Down
18 changes: 13 additions & 5 deletions Car.pde
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ class Car {
posCopy.add(heading);
//checking if the head of the posCopy vector lies in a wall
if (myMap.pixels[(int)posCopy.x + ((int)posCopy.y) * mapWidth] == -16777216) {
//fill(255, 0, 0);
//ellipse(posCopy.x, posCopy.y, 5, 5);
if (debugMode) {
fill(255, 0, 0);
ellipse(posCopy.x, posCopy.y, 5, 5);
}
//setting the proximity value to the iteration number aka distance in the heading direction
proximity[index][0] = i / 100.0;
return;
Expand All @@ -172,15 +174,21 @@ class Car {
heading.mult(100);
stroke(200, 100, 60);
//drawing for the -30 degree sensor
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 0);
//drawing for the +30 degree sensor
heading.rotate(PI / 3);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 2);
//drawing for the 0 degree sensor
heading.rotate(-PI / 6);
//line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
if (debugMode) {
line(pos.x, pos.y, pos.x + heading.x, pos.y + heading.y);
}
findDistance(heading.copy(), 1);
//println(proximity[0][0] + ", " + proximity[1][0] + ", " + proximity[2][0]);
}
Expand Down
2 changes: 2 additions & 0 deletions GA2.pde
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void draw() {
line(828, 0, 828, 600);
fill(187, 252, 184, 150);
text("Gen: " + ga.generation, 0, 0);
text("Press 'd' to toggle", 842, 300);
text("debug mode.", 872, 330);
for (int i = 1; i < cars.length; i++) {
cars[i].update();
cars[i].show();
Expand Down

0 comments on commit 65abc31

Please sign in to comment.