| 27 | } |
| 28 | |
| 29 | static SnakeBody move_snake(SnakeBody&& body, const std::tuple<Direction, size_t>& direction_and_length) |
| 30 | { |
| 31 | auto head = body.back(); |
| 32 | |
| 33 | const auto& [direction, length] = direction_and_length; |
| 34 | |
| 35 | if (length == body.size()) // no any changes |
| 36 | std::rotate(body.begin(), body.begin() + 1, body.end()); |
| 37 | else |
| 38 | body.push_back(head); |
| 39 | |
| 40 | head.x += direction.x; |
| 41 | head.x = wrap_coordinate(head.x, s_columns_count); |
| 42 | |
| 43 | head.y += direction.y; |
| 44 | head.y = wrap_coordinate(head.y, s_rows_count); |
| 45 | |
| 46 | body.back() = head; |
| 47 | |
| 48 | return std::move(body); |
| 49 | } |
| 50 | |
| 51 | static bool is_snake_eat_self(const SnakeBody& body) |
| 52 | { |
nothing calls this directly
no test coverage detected