increase sensor distance

This commit is contained in:
Felix Pankratz 2024-12-13 19:50:48 +01:00
parent b5a5c9b146
commit 494d0d1283

View File

@ -80,7 +80,8 @@ void init_agents() {
AGENT_MOVE_DISTANCE = 1; //random(1, 3); AGENT_MOVE_DISTANCE = 1; //random(1, 3);
AGENT_MOVE_ANGLE = random(0, 334) / 1000.0; AGENT_MOVE_ANGLE = random(0, 334) / 1000.0;
AGENT_SENSOR_ANGLE = random(0, 334) / 1000.0; AGENT_SENSOR_ANGLE = random(0, 334) / 1000.0;
AGENT_SENSOR_DISTANCE = random(100, 400) / 1000.0; //AGENT_SENSOR_DISTANCE = random(100, 400) / 1000.0;
AGENT_SENSOR_DISTANCE = random(3000, 5000) / 1000.0;
for(int a = 0; a < NUM_AGENTS; a++) { for(int a = 0; a < NUM_AGENTS; a++) {
float angle = ((PI * 2) / NUM_AGENTS) * a; float angle = ((PI * 2) / NUM_AGENTS) * a;
//agents[a].x_position = 31 + round(10*sin(angle)); //agents[a].x_position = 31 + round(10*sin(angle));
@ -290,7 +291,10 @@ void loop() {
} else { } else {
agents[a].heading += (random(-1,2) *2 - 1 ) * 30 / 100.0 * PI*2; agents[a].heading += (random(-1,2) *2 - 1 ) * 30 / 100.0 * PI*2;
} }
// sample step }
// sample step
for(int a = 0; a < NUM_AGENTS; a++) {
//matrix->drawPixel(agents[a].x_position, agents[a].y_position, matrix->color565(0, 0, attractant[agents[a].x_position][agents[a].y_position]));
int front_x = round(agents[a].x_position + cos(agents[a].heading) * AGENT_SENSOR_DISTANCE); int front_x = round(agents[a].x_position + cos(agents[a].heading) * AGENT_SENSOR_DISTANCE);
int front_y = round(agents[a].y_position + sin(agents[a].heading) * AGENT_SENSOR_DISTANCE); int front_y = round(agents[a].y_position + sin(agents[a].heading) * AGENT_SENSOR_DISTANCE);
int left_x = round(agents[a].x_position + cos(agents[a].heading - (AGENT_SENSOR_ANGLE * (PI * 2))) * AGENT_SENSOR_DISTANCE); int left_x = round(agents[a].x_position + cos(agents[a].heading - (AGENT_SENSOR_ANGLE * (PI * 2))) * AGENT_SENSOR_DISTANCE);