Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Significant improvement after tweaking a lot of parameters.

  • Loading branch information...
commit 4c2c68970e29f8babacb18cafb990a12f1def07f 1 parent 46be0fc
@muraliavarma authored
View
6 murali_varma_hw2/Creature.pde
@@ -22,6 +22,8 @@ class Creature {
idx = i;
posX = random(1);
posY = random(1);
+ velX = WANDERING_WEIGHT * (1 - random(2));
+ velY = WANDERING_WEIGHT * (1 - random(2));
neighborsFC = new ArrayList();
neighborsCA = new ArrayList();
@@ -41,8 +43,8 @@ class Creature {
velY += forceY;
//clamp velocities
- velX = max(-0.001, min(velX, 0.001));
- velY = max(-0.001, min(velY, 0.001));
+ velX = max(-0.01, min(velX, 0.01));
+ velY = max(-0.01, min(velY, 0.01));
posX += velX;
posY += velY;
View
BIN  murali_varma_hw2/build-tmp/murali_varma_hw2$Creature.class
Binary file not shown
View
BIN  murali_varma_hw2/build-tmp/murali_varma_hw2.class
Binary file not shown
View
24 murali_varma_hw2/build-tmp/source/murali_varma_hw2.java
@@ -23,25 +23,25 @@
final int NUM_CREATURES = 100;
-final float EPSILON = 0.001f;
+final float EPSILON = 0.01f;
-final float FLOCK_CENTERING_RADIUS = 0.2f;
-final float COLLISION_AVOIDANCE_RADIUS = 0.1f;
+final float FLOCK_CENTERING_RADIUS = 0.1f;
+final float COLLISION_AVOIDANCE_RADIUS = 0.05f;
final float VELOCITY_MATCHING_RADIUS = 0.1f;
-final float FLOCKING_CENTERING_WEIGHT = 0.01f;
-final float COLLISION_AVOIDANCE_WEIGHT = 0.02f;
-final float VELOCITY_MATCHING_WEIGHT = 0.02f;
+final float FLOCKING_CENTERING_WEIGHT = 0.0001f;
+final float COLLISION_AVOIDANCE_WEIGHT = 0.001f;
+final float VELOCITY_MATCHING_WEIGHT = 0.1f;
final float WANDERING_WEIGHT = 0.0002f;
int edgeBehavior = REFLECT_MODE;
int backgroundAlpha = 100; //0 for full trail, 255 for no trail
//flock centering, velocity matching, collision avoidance, wandering force
-boolean flockCenteringForce = false;
-boolean velocityMatchingForce = false;
+boolean flockCenteringForce = true;
+boolean velocityMatchingForce = true;
boolean collisionAvoidanceForce = true;
-boolean wanderingForce = false;
+boolean wanderingForce = true;
public void setup() {
size(SCREEN_WIDTH + CONTROLS_WIDTH, SCREEN_HEIGHT);
@@ -137,6 +137,8 @@ else if(key == 'w') {
idx = i;
posX = random(1);
posY = random(1);
+ velX = WANDERING_WEIGHT * (1 - random(2));
+ velY = WANDERING_WEIGHT * (1 - random(2));
neighborsFC = new ArrayList();
neighborsCA = new ArrayList();
@@ -156,8 +158,8 @@ public void update() {
velY += forceY;
//clamp velocities
- velX = max(-0.001f, min(velX, 0.001f));
- velY = max(-0.001f, min(velY, 0.001f));
+ velX = max(-0.01f, min(velX, 0.01f));
+ velY = max(-0.01f, min(velY, 0.01f));
posX += velX;
posY += velY;
View
18 murali_varma_hw2/murali_varma_hw2.pde
@@ -8,25 +8,25 @@ final int TOROIDAL_MODE = 1;
final int NUM_CREATURES = 100;
-final float EPSILON = 0.001;
+final float EPSILON = 0.01;
-final float FLOCK_CENTERING_RADIUS = 0.2;
-final float COLLISION_AVOIDANCE_RADIUS = 0.1;
+final float FLOCK_CENTERING_RADIUS = 0.1;
+final float COLLISION_AVOIDANCE_RADIUS = 0.05;
final float VELOCITY_MATCHING_RADIUS = 0.1;
-final float FLOCKING_CENTERING_WEIGHT = 0.01;
-final float COLLISION_AVOIDANCE_WEIGHT = 0.02;
-final float VELOCITY_MATCHING_WEIGHT = 0.02;
+final float FLOCKING_CENTERING_WEIGHT = 0.0001;
+final float COLLISION_AVOIDANCE_WEIGHT = 0.001;
+final float VELOCITY_MATCHING_WEIGHT = 0.1;
final float WANDERING_WEIGHT = 0.0002;
int edgeBehavior = REFLECT_MODE;
int backgroundAlpha = 100; //0 for full trail, 255 for no trail
//flock centering, velocity matching, collision avoidance, wandering force
-boolean flockCenteringForce = false;
+boolean flockCenteringForce = true;
+boolean velocityMatchingForce = true;
boolean collisionAvoidanceForce = true;
-boolean velocityMatchingForce = false;
-boolean wanderingForce = false;
+boolean wanderingForce = true;
void setup() {
size(SCREEN_WIDTH + CONTROLS_WIDTH, SCREEN_HEIGHT);
Please sign in to comment.
Something went wrong with that request. Please try again.