Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. void start_local_search(double x, double y) {
  2.     int cx = (int) round(x);
  3.     int cy = (int) round(y);
  4.     for (int r = 1;; r += 2) {
  5.         int current_x = cx - r / 2;
  6.         int current_y = cy - r / 2;
  7.         do {
  8.             reply_t reply = activate(current_x, current_y);
  9.             if (!reply.blocked && epsilon_equals(reply.value, 0)) {
  10.                 cout << "found " << current_x << " " << current_y << endl;
  11.                 return;
  12.             }
  13.             if (current_x == cx - r / 2 && current_y < cy + r / 2) {
  14.                 current_y++;
  15.             } else if (current_y == cy + r / 2 && current_x < cx + r / 2) {
  16.                 current_x++;
  17.             } else if (current_x == cx + r / 2 && current_y > cy - r / 2) {
  18.                 current_y--;
  19.             } else {
  20.                 current_x--;
  21.             }
  22.         } while (current_x != cx - r / 2 || current_y != cy - r / 2);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement