import java.util.List; import java.util.ArrayList; public class Agent { List sensorList; int col, row; int step; public Agent(List sensorList, int col, int row) { this.sensorList = new ArrayList(); this.sensorList.addAll(sensorList); this.col = col; this.row = row; } public void step() { for (Sensor sensor : sensorList) { if (sensor.getType() < 2) { // LEFT (0) or RIGHT (1) int id = sensor.getType() == 0 ? col * 2 : col * 2 + 1; sensor.setTargetAngle((float) (Math.PI / 2 * Math.sin(Math.PI / 4 * id - step * Math.PI / 100)), (float) 10000); } else { // UP (2) or DOWN (3) sensor.setTargetAngle((float) 0, (float) 1000); } } step++; } }