Skip to content

Commit 4845ddc

Browse files
committed
Revert drill
1 parent 4f1a284 commit 4845ddc

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

src/solve.rs

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fn find_shortest_path(
1717
start: Point,
1818
bodies_diff: &[Point],
1919
booster_map: &Matrix<Option<BoosterType>>,
20-
drill_mode: bool,
2120
) -> Vec<Move> {
2221
let mut rng = thread_rng();
2322
let mut moves = [
@@ -46,7 +45,7 @@ fn find_shortest_path(
4645
});
4746

4847
let is_booster = match booster_map.get(c) {
49-
Some(Some(_)) => true,
48+
Some(Some(BoosterType::NewHand)) => true,
5049
_ => false,
5150
};
5251

@@ -74,12 +73,9 @@ fn find_shortest_path(
7473
for m in &moves {
7574
let nc = c.move_with(m);
7675
if let Some(None) = data.get(nc) {
77-
match (valid.get(nc), drill_mode) {
78-
(Some(true), _) | (Some(false), true) => {
79-
data.set(nc, Some((m.clone(), cost + 1)));
80-
queue.push_back(nc);
81-
}
82-
_ => {}
76+
if let Some(true) = valid.get(nc) {
77+
data.set(nc, Some((m.clone(), cost + 1)));
78+
queue.push_back(nc);
8379
}
8480
}
8581
}
@@ -93,7 +89,6 @@ fn update_point(
9389
passed: &mut Matrix<bool>,
9490
booster_map: &mut Matrix<Option<BoosterType>>,
9591
hand_count: &mut usize,
96-
drill_count: &mut usize,
9792
remaining: &mut usize,
9893
) {
9994
bodies_diff.iter().map(|diff| point + *diff).for_each(|b| {
@@ -105,7 +100,7 @@ fn update_point(
105100
if let Some(Some(kind)) = booster_map.get(point) {
106101
match kind {
107102
BoosterType::NewHand => *hand_count += 1,
108-
BoosterType::Drill => *drill_count += 1,
103+
BoosterType::Drill => {}
109104
_ => {}
110105
}
111106
booster_map.set(point, None);
@@ -161,7 +156,6 @@ pub fn solve_small(task: Task) -> Vec<Command> {
161156
]);
162157

163158
let mut hand_count = 0;
164-
let mut drill_count = 0;
165159

166160
while remaining > 0 {
167161
while hand_count > 0 && !new_bodies.is_empty() {
@@ -176,7 +170,6 @@ pub fn solve_small(task: Task) -> Vec<Command> {
176170
&mut passed,
177171
&mut booster_map,
178172
&mut hand_count,
179-
&mut drill_count,
180173
&mut remaining,
181174
);
182175
let moves = find_shortest_path(
@@ -187,32 +180,7 @@ pub fn solve_small(task: Task) -> Vec<Command> {
187180
current_point,
188181
&bodies_diff,
189182
&booster_map,
190-
false,
191183
);
192-
let moves = if drill_count > 0 {
193-
let drill_moves = find_shortest_path(
194-
width,
195-
height,
196-
&valid,
197-
&passed,
198-
current_point,
199-
&bodies_diff,
200-
&booster_map,
201-
true,
202-
);
203-
if drill_moves.len() * 2 <= moves.len()
204-
&& drill_moves.len() >= 10
205-
&& drill_moves.len() < 30
206-
{
207-
drill_count -= 1;
208-
res.push(Command::Drill);
209-
drill_moves
210-
} else {
211-
moves
212-
}
213-
} else {
214-
moves
215-
};
216184
for m in moves {
217185
current_point = current_point.move_with(&m);
218186
update_point(
@@ -221,7 +189,6 @@ pub fn solve_small(task: Task) -> Vec<Command> {
221189
&mut passed,
222190
&mut booster_map,
223191
&mut hand_count,
224-
&mut drill_count,
225192
&mut remaining,
226193
);
227194
res.push(Command::Move(m));

0 commit comments

Comments
 (0)