-
Notifications
You must be signed in to change notification settings - Fork 6
/
FallChallenge2023.java
153 lines (128 loc) · 5.76 KB
/
FallChallenge2023.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import java.util.*;
// Define the data structures as records
record Vector(int x, int y) {
}
record FishDetail(int color, int type) {
}
record Fish(int fishId, Vector pos, Vector speed, FishDetail detail) {
}
record Drone(int droneId, Vector pos, boolean dead, int battery, List<Integer> scans) {
}
record RadarBlip(int fishId, String dir) {
}
class Player {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Map<Integer, FishDetail> fishDetails = new HashMap<>();
List<Integer> numberY = List.of(500, 9400);
List<Integer> numberX = List.of(600, 2000, 3000, 5000, 6000, 7000, 8000);
Map<Integer, List<Integer>> numberXForDrone = new HashMap<Integer, List<Integer>>() {{
put(0, List.of(600, 2000, 3000, 5000, 6000, 7000, 8000));
put(1, List.of(2000, 3000, 5000, 6000, 7000, 8000, 600));
put(2, List.of(3000, 5000, 6000, 7000, 8000, 600, 2000));
put(3, List.of(5000, 6000, 7000, 8000, 600, 2000, 3000));
put(4, List.of(6000, 7000, 8000, 600, 2000, 3000, 5000));
put(5, List.of(7000, 8000, 600, 2000, 3000, 5000, 6000));
put(6, List.of(8000, 600, 2000, 3000, 5000, 6000, 7000));
put(7, List.of(600, 2000, 3000, 5000, 6000, 7000, 8000));
}};
int fishCount = in.nextInt();
for (int i = 0; i < fishCount; i++) {
int fishId = in.nextInt();
int color = in.nextInt();
int type = in.nextInt();
fishDetails.put(fishId, new FishDetail(color, type));
}
int tour = 0;
int tourX = 0;
int tourY = 0;
int[] posY = {numberY.get(tourY), numberY.get(tourY), numberY.get(tourY), numberY.get(tourY)};
int[] posX = {numberX.get(tourX), numberX.get(tourX), numberX.get(tourX), numberX.get(tourX)};
// game loop
while (true) {
tour++;
List<Integer> myScans = new ArrayList<>();
List<Integer> foeScans = new ArrayList<>();
Map<Integer, Drone> droneById = new HashMap<>();
List<Drone> myDrones = new ArrayList<>();
List<Drone> foeDrones = new ArrayList<>();
List<Fish> visibleFishes = new ArrayList<>();
Map<Integer, List<RadarBlip>> myRadarBlips = new HashMap<>();
int myScore = in.nextInt();
int foeScore = in.nextInt();
int myScanCount = in.nextInt();
for (int i = 0; i < myScanCount; i++) {
int fishId = in.nextInt();
myScans.add(fishId);
}
int foeScanCount = in.nextInt();
for (int i = 0; i < foeScanCount; i++) {
int fishId = in.nextInt();
foeScans.add(fishId);
}
int myDroneCount = in.nextInt();
for (int i = 0; i < myDroneCount; i++) {
int droneId = in.nextInt();
int droneX = in.nextInt();
int droneY = in.nextInt();
boolean dead = in.nextInt() == 1;
int battery = in.nextInt();
Vector pos = new Vector(droneX, droneY);
Drone drone = new Drone(droneId, pos, dead, battery, new ArrayList<>());
droneById.put(droneId, drone);
myDrones.add(drone);
myRadarBlips.put(droneId, new ArrayList<>());
}
int foeDroneCount = in.nextInt();
for (int i = 0; i < foeDroneCount; i++) {
int droneId = in.nextInt();
int droneX = in.nextInt();
int droneY = in.nextInt();
boolean dead = in.nextInt() == 1;
int battery = in.nextInt();
Vector pos = new Vector(droneX, droneY);
Drone drone = new Drone(droneId, pos, dead, battery, new ArrayList<>());
droneById.put(droneId, drone);
foeDrones.add(drone);
}
int droneScanCount = in.nextInt();
for (int i = 0; i < droneScanCount; i++) {
int droneId = in.nextInt();
int fishId = in.nextInt();
droneById.get(droneId).scans().add(fishId);
}
int visibleFishCount = in.nextInt();
for (int i = 0; i < visibleFishCount; i++) {
int fishId = in.nextInt();
int fishX = in.nextInt();
int fishY = in.nextInt();
int fishVx = in.nextInt();
int fishVy = in.nextInt();
Vector pos = new Vector(fishX, fishY);
Vector speed = new Vector(fishVx, fishVy);
FishDetail detail = fishDetails.get(fishId);
visibleFishes.add(new Fish(fishId, pos, speed, detail));
}
int myRadarBlipCount = in.nextInt();
for (int i = 0; i < myRadarBlipCount; i++) {
int droneId = in.nextInt();
int fishId = in.nextInt();
String radar = in.next();
myRadarBlips.get(droneId).add(new RadarBlip(fishId, radar));
}
for (Drone drone : myDrones) {
int light = tour % 5 == 1 ? 1 : 0;
int x = drone.pos().x();
int y = drone.pos().y();
if (x == posX[drone.droneId()]) {
tourX = (tourX + 1) % 7;
posX[drone.droneId()] = numberXForDrone.get(drone.droneId()).get(tourX);
} else if (y == posY[drone.droneId()]) {
tourY = (tourY + 1) % 2;
posY[drone.droneId()] = numberY.get(tourY);
}
System.out.println(String.format("MOVE %d %d %d", posX[drone.droneId()], posY[drone.droneId()], light));
}
}
}
}