Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void start_local_search(double x, double y) {
- int cx = (int) round(x);
- int cy = (int) round(y);
- for (int r = 1;; r += 2) {
- int current_x = cx - r / 2;
- int current_y = cy - r / 2;
- do {
- reply_t reply = activate(current_x, current_y);
- if (!reply.blocked && epsilon_equals(reply.value, 0)) {
- cout << "found " << current_x << " " << current_y << endl;
- return;
- }
- if (current_x == cx - r / 2 && current_y < cy + r / 2) {
- current_y++;
- } else if (current_y == cy + r / 2 && current_x < cx + r / 2) {
- current_x++;
- } else if (current_x == cx + r / 2 && current_y > cy - r / 2) {
- current_y--;
- } else {
- current_x--;
- }
- } while (current_x != cx - r / 2 || current_y != cy - r / 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement