Compare commits
2 Commits
5b440bc7db
...
d3abaf61a7
Author | SHA1 | Date | |
---|---|---|---|
d3abaf61a7 | |||
d46e2d8163 |
@ -107,7 +107,7 @@ async fn get_move(request: Json<Request>) -> response::Json<Response> {
|
||||
|
||||
let action = actions.into_iter().max_by_key(|action| {
|
||||
let action_data = action_data[usize::from(*action)];
|
||||
action_data.0 / action_data.1
|
||||
(action_data.0 / action_data.1, action_data.0 % action_data.1)
|
||||
});
|
||||
|
||||
if let Some(action) = action {
|
||||
|
@ -459,6 +459,17 @@ impl Board {
|
||||
.iter()
|
||||
.all(|snake| self.coord_to_linear(snake.tail()) != *i)
|
||||
})
|
||||
.filter(|i| {
|
||||
self.snakes
|
||||
.iter()
|
||||
.flat_map(|snake| {
|
||||
let head = snake.head();
|
||||
enum_iterator::all::<Direction>()
|
||||
.map(move |direction| head.wrapping_apply(direction))
|
||||
.filter(|tile| self.is_in_bounds(*tile))
|
||||
})
|
||||
.all(|action| *i != self.coord_to_linear(action))
|
||||
})
|
||||
.filter(|i| !self.food[*i])
|
||||
.choose_multiple(&mut thread_rng(), needed_food);
|
||||
for index in food_spots {
|
||||
|
Loading…
x
Reference in New Issue
Block a user