source: proiecte/SIMEO/SimeoDemo/Agent.java @ 168

Last change on this file since 168 was 168, checked in by (none), 14 years ago

Simeo: added initial proof of concept code.

File size: 722 bytes
Line 
1import java.util.List;
2import java.util.ArrayList;
3
4public class Agent {
5        List<Sensor> sensorList;
6        int col, row;
7        int step;
8       
9        public Agent(List<Sensor> sensorList, int col, int row) {
10                this.sensorList = new ArrayList<Sensor>();
11                this.sensorList.addAll(sensorList);
12                this.col = col;
13                this.row = row;
14        }
15
16        public void step() {
17                for (Sensor sensor : sensorList) {
18                        if (sensor.getType() < 2) {
19                                // LEFT (0) or RIGHT (1)
20                                int id = sensor.getType() == 0 ? col * 2 : col * 2 + 1;
21                                sensor.setTargetAngle((float) (Math.PI / 2 * Math.sin(Math.PI / 4 * id - step * Math.PI / 100)), (float) 10000);
22                        } else {
23                                // UP (2) or DOWN (3)
24                                sensor.setTargetAngle((float) 0, (float) 1000);
25                        }
26                }       
27                step++;
28        }
29}
30
31
Note: See TracBrowser for help on using the repository browser.