Deterministic Treasure Hunt in the Plane with Angular Hints

A mobile agent equipped with a compass and a measure of length has to find an inert treasure in the Euclidean plane. Both the agent and the treasure are modeled as points. In the beginning, the agent is at a distance at most $D>0$ from the treasure, but knows neither the distance nor any bound on it. Finding the treasure means getting at distance at most 1 from it. The agent makes a series of moves. Each of them consists in moving straight in a chosen direction at a chosen distance. In the beginning and after each move the agent gets a hint consisting of a positive angle smaller than $2\pi$ whose vertex is at the current position of the agent and within which the treasure is contained. We investigate the problem of how these hints permit the agent to lower the cost of finding the treasure, using a deterministic algorithm, where the cost is the worst-case total length of the agent's trajectory. It is well known that without any hint the optimal (worst case) cost is $\Theta(D^2)$. We show that if all angles given as hints are at most $\pi$, then the cost can be lowered to $O(D)$, which is optimal. If all angles are at most $\beta$, where $\beta<2\pi$ is a constant unknown to the agent, then the cost is at most $O(D^{2-\epsilon})$, for some $\epsilon>0$. For both these positive results we present deterministic algorithms achieving the above costs. Finally, if angles given as hints can be arbitrary, smaller than $2\pi$, then we show that cost $\Theta(D^2)$ cannot be beaten.


Introduction
Motivation. A tourist visiting an unknown town wants to find her way to the train station or a skier lost on a slope wants to get back to the hotel. Luckily, there are many people that can help. However, often they are not sure of the exact direction: when asked about it, they make a vague gesture with the arm swinging around the direction to the target, accompanying the hint with the words "somewhere there". In fact, they show an angle containing the target. Can such vague hints help the lost traveller to find the way to the target? The aim of the present paper is to answer this question.
The model and problem formulation. A mobile agent equipped with a compass and a measure of length has to find an inert treasure in the Euclidean plane. Both the agent and the treasure are modeled as points. In the beginning, the agent is at a distance at most D > 0 from the treasure, but knows neither the distance nor any bound on it. Finding the treasure means getting at distance at most 1 from it. In applications, from such a distance the treasure can be seen. The agent makes a series of moves. Each of them consists in moving straight in a chosen direction at a chosen distance. In the beginning and after each move the agent gets a hint consisting of a positive angle smaller than 2π whose vertex is at the current position of the agent and within which the treasure is contained. We investigate the problem of how these hints permit the agent to lower the cost of finding the treasure, using a deterministic algorithm, where the cost is the worst-case total length of the agent's trajectory. It is well known that the optimal cost of treasure hunt without hints is Θ(D 2 ). (The algorithm of cost O(D 2 ) is to trace a spiral with jump 1 starting at the initial position of the agent, and the lower bound Ω(D 2 ) follows from Proposition 5.1 which establishes this lower bound even assuming arbitrarily large angles smaller than 2π given as hints.) Our results. We show that if all angles given as hints are at most π, then the cost of treasure hunt can be lowered to O(D), which is optimal. Our real challenge here is in the fact that hints can be angles of size exactly π, in which case the design of a trajectory always leading to the treasure, while being cost-efficient in terms of traveled distance, is far from obvious.
If all angles are at most β, where β < 2π is a constant unknown to the agent, then we prove that the cost is at most O(D 2− ), for some > 0. Finally, we show that arbitrary angles smaller than 2π given as hints cannot be of significant help: using such hints the cost Θ(D 2 ) cannot be beaten.
For both our positive results we present deterministic algorithms achieving the above costs. Both algorithms work in phases "assuming" that the treasure is contained in increasing squares centered at the initial position of the agent. The common principle behind both algorithms is to move the agent to strategically chosen points in the current square, depending on previously obtained hints, and sometimes perform exhaustive search of small rectangles from these points, in order to guarantee that the treasure is not there. This is done in such a way that, in a given phase, obtained hints together with small rectangles exhaustively searched, eliminate a sufficient area of the square assumed in the phase to eventually permit finding the treasure.
In both algorithms, the points to which the agent travels and where it gets hints are chosen in a natural way, although very differently in each of the algorithms. The main difficulty is to prove that the distance travelled by the agent is within the promised cost. In the case of the first algorithm, it is possible to cheaply exclude large areas not containing the treasure, and thus find the treasure asymptotically optimally. For the second algorithm, the agent eliminates smaller areas at each time, due to less precise hints, and thus finding the treasure costs more.
Related work. The problem of treasure hunt, i.e., searching for an inert target by one or more mobile agents was investigated under many different scenarios. The environment where the treasure is hidden may be a graph or a plane, and the search may be deterministic or randomized. An early paper [4] showed that the best competitive ratio for deterministic treasure hunt on a line is 9. In [8] the authors generalized this problem, considering a model where, in addition to travel length, the cost includes a payment for every turn of the agent. The book [2] surveys both the search for a fixed target and the related rendezvous problem, where the target and the finder are both mobile and their role is symmetric: they both cooperate to meet. This book is concerned mostly with randomized search strategies. Randomized treasure hunt strategies for star search, where the target is on one of m rays, are considered in [13]. In [17,20] the authors study relations between the problems of treasure hunt and rendezvous in graphs. The authors of [3] study the task of finding a fixed point on the line and in the grid, and initiate the study of the task of searching for an unknown line in the plane. This research is continued, e.g., in [12,16]. In [19] the authors concentrate on game-theoretic aspects of the situation where multiple selfish pursuers compete to find a target, e.g., in a ring. The main result of [15] is an optimal algorithm to sweep a plane in order to locate an unknown fixed target, where locating means to get the agent originating at point O to a point P such that the target is in the segment OP . In [10] the authors consider the generalization of the search problem in the plane to the case of several searchers. Collective treasure hunt in the grid by several agents with bounded memory is investigated in [9,14]. In [5], treasure hunt with randomly faulty hints is considered in tree networks. By contrast, the survey [7] and the book [6] consider pursuit-evasion games, mostly on graphs, where pursuers try to catch a fugitive target trying to escape.

Preliminaries
Since for D ≤ 1 treasure hunt is solved immediately, in the sequel we assume D > 1. Since the agent has a compass, it can establish an orthogonal coordinate system with point O with coordinates (0, 0) at its starting position, the x-axis going East-West and the y-axis going North-South. Lines parallel to the x-axis will be called horizontal, and lines parallel to the y-axis will be called vertical. When the agent at a current point a decides to go to a previously computed point b (using a straight line), we describe this move simply as "Go to b". A hint given to the agent currently located at point a is formally described as an ordered pair (P 1 , P 2 ) of half-lines originating at a such that the angle clockwise from P 1 to P 2 (including P 1 and P 2 ) contains the treasure.
The line containing points A and B is denoted by (AB). A segment with extremities A and B is denoted by [AB] and its length is denoted |AB|. Throughout the paper, a polygon is defined as a closed polygon (i.e., together with the boundary). For a polygon S, we will denote by B(S) (resp. I(S)) the boundary of S (resp. the interior of S, i.e., the set S \ B(S)). A rectangle is defined as a non-degenerate rectangle, i.e., with all sides of strictly positive length. A rectangle with vertices A, B, C, D (in clockwise order) is denoted simply by ABCD. A rectangle is straight if one of its sides is vertical.
In our algorithms we use the following procedure RectangleScan(R) whose aim is to traverse a closed rectangle R (composed of the boundary and interior) with known coordinates, so that the agent initially situated at some point of R gets at distance at most 1 from every point of it and returns to the starting point. We describe the procedure for a straight rectangle whose vertical side is not shorter than the horizontal side. The modification of the procedure for arbitrarily positioned rectangles is straightforward. Let the vertices of the rectangle R be A, B, C and D, where A is the North-West vertex and the others are listed clockwise. Let a be the point at which the agent starts the procedure.
The idea of the procedure is to go to vertex A, then make a snake-like movement in which consecutive vertical segments are separated by a distance 1, and then go back to point a. The agent ignores all hints gotten during the execution of the procedure. Suppose that the horizontal side of R has length m and the vertical side has length n, with n ≥ m. Let k = m . Let a 0 , a 1 , . . . , a k be points on the North horizontal side of the rectangle, such that a 0 = A and the distance between consecutive points is 1. Let b 0 , b 1 , . . . , b k be points on the South horizontal side of the rectangle, such that b 0 = D and the distance between consecutive points is 1.
The pseudocode of procedure RectangleScan(R) is given in Algorithm 1.

Algorithm 1 Procedure RectangleScan(R)
1: if k is odd then 2: for i = 0 to k − 1 step 2 do 3: Go to ai; Go to bi; 4: Go to bi+1; Go to ai+1 5: end for 6: Go to a 7: else 8: for i = 0 to k − 2 step 2 do 9: Go to ai; Go to bi; 10: Go to bi+1; Go to ai+1 11: end for 12: Go to a k ; Go to b k 13: Go to a 14: end if Proposition 2.1. For every point p of the rectangle R, the agent is at distance at most 1 from p at some time of the execution of Procedure RectangleScan(R). The cost of the procedure is at most 5n · max(m, 2), where n ≥ m are the lengths of the sides of the rectangle.
Proof. During the execution of Procedure RectangleScan(R) the agent traverses all segments [a i , b i ], for i = 0, 1, . . . , k. Every point of R is at distance at most 1 from some point of this union. This proves the first assertion. The cost of vertical moves is upper bounded by (m + 1)n, the cost of horizontal moves is upper bounded by m, and the cost of getting from a to A and of returning back to a after the scan is upper bounded by 2(m + n). Hence the total cost of procedure RectangleScan(R) is at most (m + 1)n + m + 2(m + n) ≤ mn + 6n ≤ 5n · max(m, 2).

Angles at most π
In this section we consider the case when all angles given as hints are at most π. Without loss of generality we can assume that they are all equal to π, completing any smaller angle to π in an arbitrary way: this makes the situation even harder for the agent, as hints become less precise. For such hints we show Algorithm TreasureHunt1 that finds the treasure at cost O(D). This is of course optimal, as the treasure can be at any point at distance at most D from the starting point of the agent.
For angles of size π, every hint is in fact a half-plane whose boundary line L contains the current location of the agent. For simplicity, we will code such a hint as (L, right) or (L, lef t), whenever the line L is not horizontal, depending on whether the indicated half-plane is to the right (i.e., East) or to the left (i.e., West) of L. For any non-horizontal line L this is non-ambiguous. Likewise, when L is horizontal, we will code a hint as (L, up) or (L, down), depending on whether the indicated half-plane is up (i.e., North) from L or down (i.e., South) from L.
In view of the work on φ-self-approaching curves (cf. [1]) we first note that there is a big difference of difficulty between obtaining our result in the case when angles given as hints are bounded by some angle φ 0 strictly smaller than π and when they are at most π, as we assume. A φ-self-approaching curve is a planar oriented curve such that, for each point B on the curve, the rest of the curve lies inside a wedge of angle φ with apex in B. In [1], the authors prove the following property of these curves: for every φ < π there exists a constant c(φ) such that the length of any φ-self-approaching curve is at most c(φ) times the distance D between its endpoints. Hence, for hints bounded by some angle φ 0 strictly smaller than π, our result could possibly be derived from the existing literature: roughly speaking, the agent should follow a trajectory corresponding to any φ 0 -self-approaching curve to find the treasure at a cost linear in D. Even then, transforming the continuous scenario of self-approaching curves to our discrete scenario presents some difficulties. However, the crucial problem is this: the constant c(φ) from [1] diverges to infinity as φ approaches π, hence the result from [1] cannot be used when hints are arbitrary angles smaller than π. Moreover, the result of [1] holds only when φ < π (the authors also emphasize that for each φ ≥ π, the property is false), and thus the above derivation is no longer possible for our purpose when φ = π. Actually, this is the real difficulty of our problem: handling angles equal to π, i.e., half-planes.
We further observe that a rather straightforward treasure hunt algorithm of cost O(D log D), for hints being angles of size π, can be obtained using an immediate corollary of a theorem proven in [11] by Grünbaum: each line passing through the centroid of a convex polygon cuts the polygon into two convex polygons with areas differing by a factor of at most 5 4 . Suppose for simplicity that D is known. Starting from the square of side length 2D, centered at the initial position of the agent, this permits to reduce the search area from P to at most 5P 9 in a single move. Hence, after O(log D) moves, the search area is small enough to be exhaustively searched by procedure RectangleScan at cost O(D). However, the cost of each move during the reduction is not under control and can be only bounded by a constant multiple of D, thus giving the total cost bound O(D log D). By contrast, our algorithm controls both the remaining search area and the cost incurred in each move, yielding the optimal cost O(D).

High level idea of the algorithm
In Algorithm TreasureHunt1 the agent acts in phases j = 1, 2, 3, . . . where in each phase j the agent "supposes" that the treasure is in a straight square R j centered at the initial position of the agent, and of side length 2 j . When executing a phase j, the agent successively moves to distinct points with the aim of using the hints at these points to narrow the search area that initially corresponds to R j . In our algorithm, this narrowing is made in such a way that the remaining search area is always a straight rectangle. Often this straight rectangle is a strict superset of the intersection of all hints that the agent was given previously. This would seem to be a waste, as we are searching some areas that have been previously excluded. However, this loss is compensated by the ease of searching description and subsequent analysis of the algorithm, due to the fact that, at each stage, the search area is very regular.
During a phase, the agent proceeds to successive reductions of the search area by moving to distinct locations, until it obtains a rectangular search area that is small enough to be searched directly at low cost using procedure RectangleScan. In our algorithm, such a final execution of RectangleScan in a phase is triggered as soon as the rectangle has a side smaller than 4. If the treasure is not found by the end of this execution of procedure RectangleScan, the agent learns that the treasure cannot be in the supposed straight square R j and starts the next phase from scratch by forgetting all previously received hints. This forgetting again simplifies subsequent analysis. The algorithm terminates at the latest by the end of phase j 0 = log 2 D + 1, in which the supposed straight square R j 0 is large enough to contain the treasure. Hence, if the cost of a phase j is linear in 2 j , then the cost of the overall solution is linear in the distance D.
In order to give the reader deeper insights in the reasons why our solution is valid and has linear cost, we need to give more precise explanations on how the search area is reduced during a given phase j ≥ 2 (when j = 1, the agent makes no reduction and directly scans the small search area using procedure RectangleScan). Suppose that in phase j ≥ 2 the agent is at the center p of a search area corresponding to a straight rectangle R, every side of which has length between 4 and 2 j (note that this is the case at the beginning of the phase), and denote by A, B, C and D the vertices of R starting from the top left corner and going clockwise. In order to reduce rectangle R, the agent uses the hint at point p. The obtained hint denoted by (L 1 , x 1 ) can be of two types: either a good hint or a bad hint. A good hint is a hint whose line L 1 divides one of the sides of R into two segments such that the length y of the smaller one is at least 1. A bad hint is a hint that is not good.
If the received hint (L 1 , x 1 ) is good, then the agent narrows the search area to a rectangle R ⊂ R having the following three properties: 1. R \ R does not contain the treasure.
2. The difference between the perimeters of R and R is 2y ≥ 2.
3. The distance from p to the center of R is exactly y 2 .
and then moves to the center of R .
An illustration of such a reduction is depicted in Figure 1(a). The reduced search area R is the rectangle ABde.  If the agent receives a bad hint, say (L 1 , right), at the center of a rectangular search area R, we cannot apply the same method as the one used for a good hint: this is the reason for the distinction between good and bad hints. If we applied the same method as before, we could obtain a rectangular search area R such that the difference between the perimeters of R and R is at least 2y. However, in the context of a bad hint, the difference 2y may be very small (even null), and hence there is no significant reduction of the search area. In order to tackle this problem, when getting a bad hint at the center p of R, the agent moves to another point p which is situated in the half-plane (L 1 , right) at distance 2 from p, perpendicularly to L 1 . This point p is chosen in such a way that, regardless of what is the second hint, we can ensure that two important properties described below are satisfied.
The first property is that by combining the two hints, the agent can decrease the search area to a rectangle R ⊂ R whose perimeter is smaller by 2 compared to the perimeter of R, as it is the case for a good hint, and such that R \ R does not contain the treasure. This decrease follows either directly from the pair of hints, or indirectly after having scanned some relatively small rectangles using procedure RectangleScan. In the example depicted in Fig. 1 (b), after getting the second hint (L 2 , lef t), the agent executes procedure RectangleScan(ss d d) followed by RectangleScan(gg h h) and moves to the center of the new search area R that is the rectangle Agpm. Note that the part of R not excluded by the two hints and by the procedure RectangleScan executed in rectangles ss d d and gg h h is only the small quadrilateral bounded by line L 2 and the segments [AB], [s d ] and [gh]. However, in order to preserve the homogeneity of the process, we consider the entire new search area R which is a straight rectangle whose perimeter is smaller by at least 2, compared to that from R. This follows from the fact that no side of R has length smaller than 4. The agent finally moves to the center of R .
The second property is that all of this (i.e., the move from p to p , the possible scans of small rectangles and finally the move to the center of R ) is done at a cost linear in the difference of perimeters of R and R , as shown in Lemma 3.1. The two properties together ensure that, even with bad hints, the agent manages to reduce the search area in a significant way and at a small cost. So, regardless of whether hints are good or not, we can show that the cost of phase j is in O(2 j ) and the treasure is found during this phase if the initial square is large enough. The difficulty of the solution is in showing that the moves prescribed by our algorithm in the case of bad hints guarantee the two above properties, and thus ensure the correctness of the algorithm and the cost linear in D.

Algorithm and analysis
In this subsection we describe our algorithm in detail, prove its correctness and analyze its complexity. Due to many possible positions of the line L from the hint (L, x) obtained by the agent (the line L cutting horizontal or vertical sides of the current search area, the slope of L being positive or negative, and x being right, lef t, up or down), there are many cases that the algorithm should consider. However, many of these cases can be treated similarly to one another, due to symmetry considerations. Hence, in order to reduce the number of cases, we introduce some geometric transformations that enable us to consider only one representative case in each class. This case will be called a basic configuration.
We define a configuration as a couple (R, (L, x)), where R is a straight rectangle, and (L, x) is a hint, i.e., a half-plane such that the line L contains the center of R.
A configuration (R, (L, x)) is called lying iff the line L passes through a point that is in the interior of a vertical side of R. A configuration that is not lying is called standing. A configuration (R, (L, x)) is called perfect iff L is horizontal or vertical. A configuration that is not perfect is called imperfect.
A perfect lying (resp. standing) configuration (R, (L, x)) can be of two types: An imperfect configuration (R, (L, x)) can be of four types: • Type 1. The slope of L is negative and x = right • Type 2. The slope of L is negative and x = lef t • Type 3. The slope of L is positive and x = right • Type 4. The slope of L is positive and x = lef t The following proposition follows immediately from the above definitions. A configuration (R, (L, x)) is called critical iff the line L divides a side of R into two parts such that the length of the smaller part is less than 1 (possibly 0).
We will denote by Rot v,α the rotation by the angle α with center v, and by Sym P the axial symmetry with axis P .
The set of all configurations is denoted by C. Given a configuration (R, (L, x)), we denote by r and H, respectively, the center of R and the vertical line passing through r. For every i ∈ {0, 1, 2, 3}, we define the following functions that are intuitively rotations and axial symmetries of configurations.
Using the above functions, we now define the following eight elementary transformations φ i : C → C, for i ∈ {0, . . . , 7}.
We say that a configuration is basic iff it is either a lying perfect configuration of type 1 or a lying imperfect configuration of type 1.
The following proposition asserts that from every configuration we can obtain a basic configuration by at least one of the elementary transformations. This follows directly from the definitions.
For every configuration, the elementary transformation with the smallest index i for which the above proposition is true will be called the basic transformation of this configuration.
Note that, by applying to a configuration (R, (L, x)) its basic transformation φ k in order to obtain (R , (L , x )) = φ k ((R, (L, x))) , each point s of (L, x) is rotated and possibly symmetrically reflected to obtain a new point s in (L , x ). By a slight abuse of notation we will write s = φ k (s) and s = φ −1 k (s ), and, more generally, for any set of points S, we will write S = φ k (S) and S = φ −1 k (S ). Algorithm 2 gives a pseudo-code of our main algorithm. It uses the function ReduceRectangle described in Algorithm 3 that is the key technical tool permitting the agent to reduce its search area. The agent interrupts the execution of Algorithm 2 as soon as it gets at distance 1 from the treasure, at which point it can "see" it and thus treasure hunt stops. Figure 2: Illustration of the geometric objects used in Algorithm 3 and in the proof of Lemma 3.1. We show an example of a basic configuration (R , (L 1 , x 1 )) that is critical, in which R is the rectangle ABCD and x 1 = right. We also show projections and intersections points defined in Algorithm 3. The excluded area is shaded. Ri:= the straight square centered at O with sides of length 2 i 5: while Ri has no side with length smaller than 4 do 6: Ri:=ReduceRectangle(Ri) 7: end while 8: Execute RectangleScan(Ri) 9: Go to O 10: i:=i + 1 11: end loop We now proceed to the proof of correctness and the complexity analysis of our algorithm. In the following lemma, for every rectangle R, the function P erimeter(R) returns the perimeter of the rectangle R.
Lemma 3.1. Let R be a straight rectangle with no side of length less than 4. If the agent executes ReduceRectangle(R) from the center of R, then at the end of this execution the following properties are satisfied.
1. The function ReduceRectangle(R) returns a straight rectangle Rec, such that Rec ⊂ R, and either R \ Rec does not contain the treasure or the agent has seen the treasure.
3. The agent is at the center of rectangle Rec.
4. The agent travelled a distance of at most 21(P erimeter(R) − P erimeter(Rec)) during the execution of ReduceRectangle(R).
Proof. Most of the geometric objects used in the proof are explicitely defined in Algorithm 3: in particular, this is the case of intersections or orthogonal projections (e.g., those in lines 10 to 21). All other necessary objects will be defined within the proof. For the notation, refer to Fig. 2.
Consider the execution of function ReduceRectangle(R) starting at the center p of R, where R is a straight rectangle with no sides of length less than 4. Denote by z the position of the treasure in (L 1 , x 1 ). We have (R , (L 1 , x 1 )) = φ k ((R, (L 1 , x 1 ))). In view of Proposition 3.2, it is enough to prove that the following three properties hold when the agent executes the last line of Algorithm 3.
• P1. The variable N ewRectangle is set to a straight rectangle R such that R ⊂ R , and either R \ R does not contain φ k (z) or the agent has seen the treasure.
• P3. The agent travelled a distance of at most 21(P erimeter(R) − P erimeter(R )) during the execution of function ReduceRectangle(R).

Algorithm 3 Function ReduceRectangle(R)
1: p := the center of rectangle R 2: Let (L1, x1) and φ k be respectively the hint obtained at p and the basic transformation of (R, (L1, x1)) 3: Let (R , (L 1 , x 1 )) be the configuration such that (R , (L 1 , x 1 )) = φ k ((R, (L1, x1))) 4: Let A,B,C and D be the vertices of R in clockwise order, starting from the top-left corner 5: Let a (resp. d) be the intersection between L 1 and (AD) (resp. (BC)) 6: Let e be the orthogonal projection of d onto segment [AD] 7: if (R , (L 1 , x 1 )) is not critical then 8: NewRectangle:= the rectangle ABde 9: else 10: Let L 1 be the line that is perpendicular to L 1 11: Let p be the point at distance 2 from p in L 1 ∩ (L 1 , x ) 12: Let L 1 be the parallel line to L 1 passing through p 13: Let f (resp. j) be the intersection of L Let s (resp. s ) be the orthogonal projection of A onto line L 1 (resp. L 1 ) 21: Let d be the orthogonal projection of d onto line L 1 22: if x 2 = right and L 2 is clockwise between L 1 (included) and (pp ) (excluded) then 25: NewRectangle:= the rectangle f BCt 26: end if 27: if x 2 = right and L 2 is clockwise between (pp ) (included) and (m k ) (excluded) then 28: Execute RectangleScan(φ −1 k (m k km)) 29: NewRectangle:= the rectangle gBCh 30: end if 31: if x 2 ∈ {down, lef t} and L 2 is clockwise between (m k ) (included) and L 1 (excluded) then 32: Execute RectangleScan(φ −1 k (ss d d)) 33: Execute RectangleScan(φ −1 k (m k km)) 34: NewRectangle:= the rectangle pkCh 35: end if 36: if x 2 = lef t and L 2 is clockwise between L 1 (included) and (g h ) (excluded) then 37: Execute NewRectangle:= the rectangle Agpm 40: end if 41: if (x 2 = lef t and L 2 is clockwise between (g h ) (included) and (pp ) (excluded)) or (x 2 = lef t and L 2 is clockwise between (pp ) (included) and (m k ) (excluded)) or (x 2 ∈ {up, right} and L 2 is clockwise between (m k ) (included) and (p k) (excluded)) then 42: Execute We first prove the above properties when (R , (L 1 , x 1 )) is a non-critical configuration. In this case, the variable N ewRectangle is set to the straight rectangle ABde. Note that the points defined in lines 4 to 6 (in particular the points A,B, d and e) exist and ABde is a straight rectangle such that ABde ⊂ R in view of the fact that (R , (L 1 , x 1 )) is a basic configuration. Moreover, since So we have (R \ ABde) ∩ (L 1 , x 1 ) = ∅ and Property P1 is satisfied. Property P2 also holds because (R , (L 1 , x 1 )) is a basic configuration that is not critical. Indeed, in that case we know that the length |Bd| ≤ |BC| − 1, as |dC| ≥ 1. Hence, |Ae| + |Bd| ≤ |AD| + |BC| − 2, and thus P erimeter(R ) − P erimeter(ABde) ≥ 2. It remains to prove Property P3. If we denote by ∆ the difference |BC| − |Bd|, the distance from φ k (p) = p to the center o of rectangle ABde is exactly ∆ 2 . Moreover, the distance from p to φ −1 k (o ) is also ∆ 2 , as φ −1 k is a distance-preserving transformation. As a result, since the only movement of the agent is from p to φ −1 k (o ) and ∆ = P erimeter(R )−P erimeter(ABde) 2 , when the agent executes the last line of Algorithm 3, it has traveled a distance of P erimeter(R )−P erimeter(ABde) 4 during the execution of function ReduceRectangle(R). Thus the lemma holds if (R , (L 1 , x 1 )) is a non-critical configuration.
Let us now consider the more difficult situation when (R , (L 1 , x 1 )) is a critical configuration. In Algorithm 3, this situation is handled by moving the agent to the point φ −1 k (p ) (cf. line 22) where p is the point defined at line 11, in order to get a second hint (L 2 , x 2 ) at φ −1 k (p ). We have six cases to consider depending on the nature of (L 2 , x 2 ). Similarly as for non-critical configurations, we do not study the six cases directly on (L 2 , ). Note that if the list of cases for (L 2 , x 2 ) covers all possible situations, and in each of those cases Properties P1 to P3 are satisfied, then the lemma will be proven.
The six cases correspond to the six conditional statements that are in lines 24 to 45 of Algorithm 3. The fact that these cases cover all possible situations follows from the fact that (R , (L 1 , x 1 )) is a basic configuration, by Proposition 3.2, and from the fact that the objects defined in lines 10 to 21 of Algorithm 3 exist. In turn, the existence of these objects follows from the definition of R and of (L 1 , x 1 ) as well as from the following three claims (note that R has no side with length less than 4, as φ k is a distance-preserving transformation and R has no side with length less than 4). Proof of the claim: Since (R , (L 1 , x 1 )) is basic, we just have to show that it is not a perfect lying configuration of type 1. Suppose by contradiction that it is. So, x 1 = up and line L 1 divides the west vertical side [AD] (resp. the east vertical side [BC]) of rectangle R into two parts of equal length. Since, (R , (L 1 , x 1 )) is critical, each of these parts has length less than 1. As a result, |AD| (resp. |BC|) is smaller than 2. This implies that R has a side with a length smaller than 4, which is a contradiction and concludes the proof of the claim. Proof of the claim: Since p is the center of rectangle R that has no side of length less than 4, every point that is at distance at most 2 from p, and which is not one of the four orthogonal projections of p on the sides of R , necessarily belongs to I(R ). However, by Algorithm 3, point p is at distance 2 from p on a line perpendicular to L 1 and that passes through p. Moreover, by Claim 3.1, (R , (L 1 , x 1 )) is an imperfect vertical configuration of type 1, and thus the slope of L 1 is negative. Hence the claim holds. Proof of the claim: In view of Claim 3.1 and the fact that L 1 is a line parallel to L 1 passing through p that is a point belonging to I(R ) (cf. Claim 3.2), it follows that L 1 divides the east side [BC] of R into two parts of positive length. It also follows that L 1 intersects the northern side [AB] or the west side [AD] of R . So to prove the claim, it is enough to show that L 1 cannot intersect [AD] (i.e., cannot pass through any points of [AD] including the corners A and D). Assume by contradiction that it does. Since L 1 ⊂ (L 1 , x 1 ) and the distance from any point of L 1 to any point of L 1 is at least |pp |, then according to the definition of L 1 and L 1 , we know that the segment [AD] ∩ (L 1 , x 1 ) has a length that is at least |pp | = 2. However, by Claim 3.1 and the fact that (R , (L 1 , x 1 )) is a critical configuration, the segment [AD] ∩ (L 1 , x 1 ) has a length that is smaller than 1, which is a contradiction and proves the claim.
Hence, since we have a list of six cases covering all possible situations, it is enough to show that Properties P1 to P3 are satisfied in each case, in order to conclude the proof of the lemma. Before analyzing them, let us give another claim that will be useful in the sequel. Proof of the claim: As mentioned previously, the distance from any point of L 1 to any point of L 1 is at least |pp | = 2. Hence, |af | ≥ 2 and |jd| ≥ 2. Since d ∈ [jC] and |aA| < 1 (because the configuration is critical) and [af ] is the hypothenuse of the right rectangle Af a, the claim follows.
The fact that each object that is assigned to variable N ewRectangle or given as input parameter to procedure RectangleScan is a rectangle, can be shown using the above claims. Moreover, from the definitions of intersections and projections given in Algorithm 3, it follows that each time procedure RectangleScan is called with an input parameter corresponding to a rectangle X, the agent is in the rectangle X (this is necessary in order to obtain a correct execution of the procedure). In the rest of the proof we will not mention this fact. Similarly, it follows that a rectangle that is assigned to variable NewRectangle is always straight. Now, we consider the six cases and we start with the first one in which x 2 = right and L 2 is clockwise between L 1 (included) and (pp ) (excluded). In this case, variable N ewRectangle is set to the straight rectangle f BCt ⊂ R . Since z ∈ (L 1 , , and in view of the value of x 2 and the position of L 2 , we have
Let us now consider the situation when x 2 = right and L 2 is clockwise between (pp ) (included) and (m k ) (excluded). The variable N ewRectangle is then set to the straight rectangle gBCh ⊂ R . Note that R \ gBCh ⊂ AghD. In view of the value of x 2 and the position of , if the agent has not seen the treasure after having executed RectangleScan(φ −1 k (m k km)), then in view of Proposition 2.1 and the definition of transformation φ k we know that φ k (z) cannot be in the rectangle AghD. Thus, Property P1 is satisfied. Property P2 follows from the facts that |gB| = |AB| 2 (since g is the orthogonal projection of the center p of R on the top side [AB] of R ) and that |AB| ≥ 4 (as R has no side of length less than 4). So, it remains to check the validity of Property P3 in the current case. The move of the agent is composed of three parts: the first part is when it moves from p to φ −1 k (p ), the second part corresponds to the move made when executing procedure RectangleScan(φ −1 k (m k km)), and the third part is when the agent moves to φ −1 k (o ) (where o is the center of the rectangle gBCh). Note that the execution of RectangleScan(φ −1 k (m k km)) starts and finishes at point φ −1 k (p ). This implies that the third part corresponds precisely to a move from point φ −1 k (p ) to point φ −1 k (o ). So, by similar arguments to those used in the previous case, we can show that the distance traveled in the first part plus the distance traveled in the third part gives a total of at most 9∆ 2 where, in the current situation, ∆ is the difference |AB| − |gB|. For the second part, corresponding to the execution of procedure RectangleScan(φ −1 k (m k km)), note that since |pφ −1 k (p )| = 2, we have |kk | ≤ 2 because k (resp. k ) is the orthogonal projection of p (resp. p ) onto [BC]. Moreover, |m k | = |AB|, and in view of the definition of R , we have |AB| ≥ 4. Hence, according to Proposition 2.1, we know that the agent travels a distance of at most 10|AB| during the second part. So the total distance traveled by the agent is at most 9∆ 2 + 10|AB|. As explained for Property P2, we know that |gB| = |AB| 2 . Hence, ∆ = |AB| 2 , P erimeter(R ) − P erimeter(gBCh) = |AB|, and thus the total distance traveled by the agent is at most 49(P erimeter(R )−P erimeter(gBCh))

4
. As a result, Properties P1, P2 and P3 hold in this case.
We continue by analyzing the situation when x 2 ∈ {down, lef t} and L 2 is clockwise between (m k ) included and L 1 (excluded). In this situation, variable N ewRectangle is set to the straight rectangle pkCh ⊂ R . In view of the value of x 2 and the position of L 2 , we have (L 1 , , if the agent has not seen the treasure after having executed RectangleScan(φ −1 k (ss d d)) followed by RectangleScan(φ −1 k (m k km)), then in view of Proposition 2.1 and the definition of transformation φ k we know that φ k (z) cannot be in R \pkCh. Thus, Property P1 is satisfied. We can show that Property P2 also holds by similar arguments to those used to show Property P2 in the previous case. Concerning Property P3, note that the move of the agent can be divided into four parts: the first part is when it moves from p to φ −1 k (p ), the second (resp. third) part corresponds to the move made when executing procedure RectangleScan(φ −1 k (ss d d)) (resp. RectangleScan(φ −1 k (m k km))), and the fourth part is when the agent moves to φ −1 k (o ) (where o is here the center of rectangle pkCh). Note that the execution of RectangleScan(φ −1 k (ss d d)) (resp. RectangleScan(φ −1 k (m k km))) starts and finishes at point φ −1 k (p ). So, the fourth part is actually a move from point φ −1 k (p ) to point φ −1 k (o ). It is worth mentioning that moving from φ −1 k (p ) to point φ −1 k (o ) costs the same or less than first moving from φ −1 k (p ) to p, and then moving from p to φ −1 k (o ). Moreover, moving from p to φ −1 k (o ) costs at most ∆ 1 +∆ 2 2 where ∆ 1 (resp. ∆ 2 ) is the difference |gh| − |pg| (resp. |mk| − |pm|). Hence during the fourth part, the agent travels a distance of at most 2 + ∆ 1 +∆ 2 2 . During the first part, the agent travels a distance 2. What about the second and third parts? To evaluate these costs we need to evaluate the lengths and widths of rectangles ss d d and m k km. In the analysis of the previous case, we have shown that the length and width of rectangle m k km are respectively |AB| and at most 2. Concerning rectangle ss d d, we have the following claim.
Proof of the claim: Note that |ss | is exactly 2 because s (resp. s ) is the orthogonal projection of the corner A onto line L 1 (resp. L 1 ). Also note that |sd| = |sa| + |ad| where [sa] is a side of the right triangle asA whose hypotenuse is [Aa]. However, by Claim 3.1 and the fact that (R , (L 1 , x 1 )) is critical, we know that |Aa| < 1. Moreover, [ad] ⊂ R and |ad| ≥ |AB| ≥ 4. Hence, 2 < |sd| < 1 + |AC|, which concludes the proof of the claim.
So far, we have analyzed the first three cases among the six cases that permit us to cover entirely the situation when (R , (L 1 , x 1 )) is a critical configuration. However, the arguments we need to use in order to analyze the last three cases are similar to those already used to analyze the first three cases. In particular, this is true for the fourth case when x 2 = lef t and L 2 is clockwise between L 1 (included) and (g h ) (excluded): using a similar reasoning to that for the third case we have analyzed just above, we can show that Properties P1, P2 and P3 are also valid here. For the fifth case, which corresponds to the boolean expression of line 41, Properties P2 and P3 can be proven using a similar reasoning to that used above to prove Properties P2 and P3 when x 2 = right and L 2 is clockwise between (pp ) (included) and (m k ) (excluded). Concerning Property P1, note that variable N ewRectangle is set here to the straight rectangle ABkm ⊂ R . In view of the possible values of x 2 and the possible positions of L 2 , we have (L 1 , x 1 ) ∩ (L 2 , x 2 ) ∩ (R \ ABkm) ⊂ gg h h if x 2 = lef t and L 2 is clockwise between (g h ) (included) and (pp ) (excluded). Otherwise, we have , if the agent has not seen the treasure after having executed RectangleScan(φ −1 k (gg h h)), then in view of Proposition 2.1 and the definition of transformation φ k we know that φ k (z) cannot be in R \ ABkm. Thus Property P1 is also true in this case. Finally, the fact that Properties P1, P2 and P3 are true in the last of the six cases i.e., when x 2 = right and L 2 is clockwise between (p k) (included) and L 1 (excluded) can be proven using similar arguments to those used for the first case, i.e., when x 2 = right and L 2 is clockwise between L 1 (included) and (pp ) (excluded). This completes the proof of the lemma. Proof. The execution of Algorithm 2 can be divided into phases 1, 2, 3, . . . where phase j ≥ 1 is the part of the execution in which variable i of Algorithm 2 is equal to j.
In view of the second and third properties of Lemma 3.1 and lines 4 to 7 of Algorithm 2, the number of calls to function ReduceRectangle is bounded by the perimeter of a square with side length 2 j . Hence we have the following claim.
Claim 3.6. For every j ≥ 1, the number of calls to function ReduceRectangle, within phase j, is bounded by 2 j+2 .
In order to conclude the proof of the theorem, it is enough to prove the following two statements: 1. for all j ≥ 1, the following property H j holds: at the beginning of phase j the agent has traveled a distance of at most 2 j+7 .
2. the agent finds the treasure before starting phase log 2 D + 2.
We start by proving the first statement by induction on j. Note that property H 1 is true because at the beginning of phase 1 the agent has traveled a distance 0. So, assume that, for a positive integer λ, property H λ is true. We prove that property H λ+1 is also true. Within phase λ, the move of the agent can be divided into two parts: the first part corresponds to the moves made when executing lines 4 to 7 of Algorithm 2, while the second part corresponds to the moves made when executing lines 8 and 9 of Algorithm 2. By Claim 3.6, we know that the number τ of calls to function ReduceRectangle during phase λ is upper bounded by 2 λ+2 . For all 1 ≤ s ≤ τ , we denote by Q s (resp. Q s ) the rectangle that is the input parameter (resp. the returned value) of the sth call to function ReduceRectangle during phase λ. Note that, for all 2 ≤ s ≤ τ , Q s = Q s−1 . So, by the fourth property of Lemma 3.1, the distance traveled by the agent during the first part of phase λ is upperbounded by 21 s=τ s=1 (P erimeter(Q s ) − P erimeter(Q s )) (1) Concerning the second part of phase λ, it is worth mentioning that when the agent starts executing line 8 of Algorithm 2, variable R i is set to a straight rectangle whose at least one side has length smaller than 4 (according to line 5), and no sides have length larger than 2 λ : indeed, using the first property of Lemma 3.1, it follows by induction on s that the straight rectangle Q s is included in the straight rectangle Q 1 , for all 1 ≤ s ≤ τ . Moreover, the distance between any two points of Q 1 (and thus the cost of line 9 of Algorithm 2) is at most 2 λ+1 . Hence, in view of Proposition 2.1, we know that the distance traveled by the agent during the second part of phase λ is upper bounded by 22 · 2 λ . From this and (4), we know that the total distance traveled during phase λ is at most 2 λ+7 . Moreover, by the inductive hypothesis, H λ is true i.e., at the beginning of phase λ the agent has traveled a distance of at most 2 λ+7 . As a result, when starting phase λ + 1, the agent has traveled a total distance of at most 2 λ+8 . Thus, property H λ+1 is true, which concludes the inductive proof and thus proves the validity of the first statement. Now let us focus on the second statement: the agent finds the treasure before starting phase log 2 D + 2. Suppose by contradiction that this is not the case. By Claim 3.6 and Lemma 3.1, at some point the agent starts executing phase log 2 D + 1. In view of Algorithm 2, when the agent finishes the execution of line 4 in phase log 2 D + 1, the value of variable R i is a square S containing the treasure: indeed this square is centered at the initial position O of the agent and it contains all points at distance at most D from O because its side length is 2 log 2 D +1 ≥ 2D, since D > 1.
Denote by Q f inal the rectangle returned by the last call to function ReduceRectangle in phase log 2 D + 1: since the side length of S is at least 2 log 2 D +1 ≥ 2 2 , this rectangle exists because the agent executes at least once line 6 of Algorithm 2. By Claim 3.6 and Lemma 3.1, at some point the agent executes line 8 of Algorithm 2 and when the agent starts executing this line we know that it is at the center of Q f inal . Moreover, from Lemma 3.1, it follows by induction on the number of calls to function ReduceRectangle within phase log 2 D + 1, that the treasure does not belong to S \ Q f inal , as otherwise the agent would have found the treasure before starting phase log 2 D + 2 which would be a contradiction. However, the treasure belongs to square S. Hence, the treasure belongs to Q f inal , and by applying procedure RectangleScan(Q f inal ) (cf. line 8) from the center of Q f inal , the agent necessarily finds the treasure by the end of the execution of this procedure, and thus by the end of phase log 2 D + 1. This gives a contradiction that proves the second statement.
Hence the agent finds the treasure before starting the execution of phase log 2 D + 2. By the first statement, the total distance travelled by the agent during the first log 2 D + 1 phases is at most 2 ( log 2 D +2)+7 ≤ 2 10 * D. Hence, the theorem holds.

Angles bounded by β < 2π
In this section we consider the case when all hints are angles upper-bounded by some constant β < 2π, unknown to the agent. The main result of this section is Algorithm TreasureHunt2 whose cost is at most O(D 2− ), for some > 0. For a hint (P 1 , P 2 ) we denote by (P 1 , P 2 ) the complement of (P 1 , P 2 ).

High level idea
In Algorithm TreasureHunt2, similarly as in the previous algorithm, the agent acts in phases j = 1, 2, 3, . . ., where in each phase j the agent "supposes" that the treasure is in the straight square centered at its initial position and of side length 2 j . The intended goal is to search each supposed square at relatively low cost, and to ensure the discovery of the treasure by the time the agent finishes the first phase for which the initial supposed square contains the treasure. However, the similarity with the previous solution ends there: indeed, the hints that may now be less precise do not allow us to use the same strategy within a given phase. Hence we adopt a different approach that we outline below and that uses the following notion of tiling. Given a square S with side of length x > 0, T iling(i) of S, for any non-negative integer i, is the partition of square S into 4 i squares with side of length x 2 i . Each of these squares, called tiles, is closed, i.e., contains its border, and hence neighboring tiles overlap in the common border.
Let us consider a simpler situation in which the angle of every hint (P 1 , P 2 ) is always equal to the bound β: the general case, when the angles may vary while being at most β, adds a level of technical complexity that is unnecessary to understand the intuition. In the considered situation, the angle of each excluded zone (P 1 , P 2 ) is always the same as well. The following property holds in this case: there exists an integer i β such that for every square S and every hint (P 1 , P 2 ) given at the center of S, at least one tile of T iling(i β ) of S belongs to the excluded zone (P 1 , P 2 ).
In phase j, the agent performs k steps: we will indicate later how the value of k should be chosen. At the beginning of the phase, the entire square S is white. In the first step, the agent gets a hint (P 1 , P 2 ) at the center of S. By the above property, we know that (P 1 , P 2 ) contains at least one tile of T iling(i β ) of S, and we have the guarantee that such a tile cannot contain the treasure. All points of all tiles included in (P 1 , P 2 ) are painted black in the first step. This operation does not require any move, as painting is performed in the memory of the agent. As a result, at the end of the first step, each tile of T iling(i β ) of S is either black or white, in the following precise sense: a black tile is a tile all of whose points are black, and a white tile is a tile all of whose interior points are white.
In the second step, the agent repeats the painting procedure at a finer level. More precisely, the agent moves to the center of each white tile t of T iling(i β ) of S. When it gets a hint at the center of a white tile t, there is at least one tile of T iling(i β ) of t that can be excluded. As in the first step, all points of these excluded tiles are painted black. Note that a tile of T iling(i β ) of t is actually a tile of T iling(2i β ) of S. Moreover, each tile of T iling(i β ) of S is made of exactly 4 i β tiles of T iling(2i β ) of S. Hence, as depicted in Figure 3, the property we obtain at the end of the second step is as follows: each tile of T iling(2i β ) of S is either black or white.  In the next steps, the agent applies a similar process at increasingly finer levels of tiling. More precisely, in step 2 < s ≤ k, the agent moves to the center of each white tile of T iling((s − 1)i β ) of S and gets a hint that allows it to paint black at least one tile of T iling(s · i β ) of S. At the end of step s, each tile of T iling(s · i β ) of S is either black or white. We can show that at each step s the agent paints black at least 1 4 i β th of the area of S that is white at the beginning of step s. After step k, each tile of T iling(k · i β ) of S is either black or white. These steps permit the agent to exclude some area without having to search it directly, while keeping some regularity of the shape of the black area. The agent paints black a smaller area than excluded by the hints but a more regular one. This regularity enables in turn the next process in the area remaining white. Indeed, the agent subsequently executes a brute-force searching that consists in moving to each white tile of T iling(k · i β ) of S in order to scan it using the procedure RectangleScan. If, after having scanned all the remaining white tiles, it has not found the treasure, the agent repaints white all the square S and enters the next phase. Thus we have the guarantee that the agent finds the treasure by the end of phase log 2 D + 1, i.e., a phase in which the initial supposed square is large enough to contain the treasure. The question is: how much do we have to pay for all of this? In fact, the cost depends on the value that is assigned to k in each phase j. The value of k must be large enough so that the distance travelled by the agent during the brute-force searching is relatively small. At the same time, this value must be small enough so that the the distance travelled during the k steps is not too large. A good trade-off can be reached when k = log 4 i β √ 2 j . Indeed, as highlighted in the proof of correctness, it is due to this carefully chosen value of k that we can beat the cost Θ(D 2 ) necessary without hints, and get a complexity of O(D 2− ), where is a positive real depending on i β , and hence depending on the angle β.

Algorithm and analysis
In this subsection we describe our algorithm in detail, prove its correctness and analyze its complexity. We will use the notion of a slicing of a square. Given a straight square S, the Slicing(i) of S, for any integer i ≥ 3, is the partition of the square S into 2 i triangles with a common vertex at the center q of the square, resulting from partitioning the angle 2π into angles 2π 2 i using lines containing the point q, one of which is horizontal.
Consider any Slicing(i) of a square S. Let Σ be the set of all side lengths of triangles into which Slicing(i) partitions S. We define ρ i to be the maximum of all integers a/b , where a, b ∈ Σ. Note that ρ i depends only on i and not on the side length of S. Moreover, ρ i+1 ≥ ρ i . For every integer i ≥ 3, we define φ(i) = iρ i .
In order to define some objects used by our algorithm, we need the following technical proposition. 1. For every angle 0 < α < 2π with vertex at the center of a square S, the angle α contains some triangle of Slicing(max(3, log 2 ( 2π α ) + 1)) of S.
2. For every integer i ≥ 3 and for every triangle T of Slicing(i) of a square S, at least one tile of T iling(4φ(i)) of S is included in the interior of T .
Proof. We start by proving the first property. Let S be a square and let 0 < α < 2π be an angle with the vertex in the center of S. Let i = max(3; log 2 ( 2π α ) + 1) ≥ 3. The angle at the center of square S in each of the triangles of Slicing(i) of S is at most α 2 . Hence one of the triangles formed by Slicing(i) is included in the angle α. This proves the first property.
In the proof of the second property, all tilings and slicings are for square S: for ease of reading we omit mentioning it. In order to prove the second property, we first prove by induction on i the following statement denoted by H i : For every integer i ≥ 3 and for every triangle T of Slicing(i), there is at least one tile t of T iling(4φ(i) − 2), such that t ⊂ T and one side of t is included in a side of S.
For the base case i = 3, note that each triangle of Slicing(3) contains at least one tile of T iling (2) with one side included in a side of S. Since φ(3) = 3ρ 3 and ρ 3 ≥ 1, we know that 4φ(3) − 2 ≥ 10. Moreover, each side of every tile t of T iling(r) contains at least one side of a tile of T iling(r ), included in t , for all integers r < r . Hence H 3 is true.
Assume that H j is true for some integer j ≥ 3 and let us prove that H j+1 is also true. Suppose by contradiction that H j+1 is false. This means that there exists a triangle T 1 of Slicing(j + 1) that contains no tile of T iling(4φ(j + 1) − 2) with one side included in a side of S. Denote by L the side of S that contains a side of T 1 . There exists a triangle T of Slicing(j) and a triangle T 2 of Slicing(j + 1) such that T 1 ∪ T 2 = T and T 1 ∩ T 2 = l, where l is the common segment of boundaries of T 1 and T 2 . Note that triangle T 2 also has a side included in L.
By the inductive hypothesis, there exists a tile t of T iling(4φ(j) − 2) such that t ⊂ T and one side of t is included in L. For any integers r < r , every tile of T iling(r) contains exactly 4 r −r tiles of T iling(r ) that are organized in 2 r −r rows of 2 r −r squares. So, tile t contains exactly 4 2φ(j+1)−2φ(j) rows that are parallel to L and such that each of them is made of 4 2φ(j+1)−2φ(j) tiles of T iling(4φ(j + 1) − 2). Among these rows consider the one that has a common boundary with L and denote it by R. Note that R contains at least 4 2ρ j+1 tiles of T iling(4φ(j + 1) − 2) because 2φ(j +1)−2φ(j) = 2(j +1)ρ j+1 −2jρ j and ρ j+1 ≥ ρ j . Denote by R the row of T iling(4φ(j +1)−2) that contains R and by R the part of R made of tiles t of T iling(4φ(j + 1) − 2), such that t ⊂ T . Note that R ⊆ R and thus R contains at least 4 2ρ j+1 tiles of T iling(4φ(j + 1) − 2). Moreover, note that the smaller of the two angles formed by l and L cannot be smaller than π 4 or larger than π 2 . As a result, l can intersect at most 2 adjacent tiles s 1 , s 2 of R . We will show that l cannot intersect a tile that is at an end of row R . Let x be the side length of a tile of T iling(4φ(j +1)−2). Suppose that l intersects a tile that is at an end of row R . In view of the fact that R contains all tiles of R that are included in T , a side of T 1 or of T 2 included in L (say the side of T 1 without loss of generality), has length at most 3x, while the side of T 2 included in L has length at least > ρ j+1 , which contradicts the definition of ρ j+1 . Hence l cannot intersect a tile that is at an end of row R . This implies that one of the two tiles at the ends of R belongs to T 1 : by construction this tile belongs to T iling(4φ(j + 1) − 2) with one side belonging to L. Hence we get a contradiction. As a result, H j+1 is true, which ends the proof by induction of H i .
It remains to conclude the proof of the second property of our proposition. In view of property H i , we know that for every integer i ≥ 3 and for every triangle T of Slicing(i), at least one tile of T iling(4φ(i) − 2) is included in T . Moreover, each tile of T iling(4φ(i) − 2) contains 4 rows, each made of 4 tiles belonging to T iling(4φ(i)). Hence, the interior of each tile of T iling(4φ(i) − 2) contains a tile of T iling(4φ(i)). This proves the second property and concludes the proof of the proposition.
1. For every square S and for every hint (P 1 , P 2 ) of size 2π − α obtained at the center of S, there exists a tile of T iling(index(α)) of S included in (P 1 , P 2 ).
Algorithm 4 gives a pseudo-code of the main algorithm of this section. It uses the function Mosaic described in Algorithm 5 that is the key technical tool permitting the agent to reduce its search area. The agent interrupts the execution of Algorithm 4 as soon as it gets at distance 1 from the treasure, at which point it can "see" it and thus treasure hunt stops.
In the following, a square is called black if all its points are black. A square is called white if all points of its interior are white. (In a white square, some points of its border may be black). Proof. Assume by contradiction that there exists a positive integer j ≤ log 4 k √ 2 i such that at the end of the j-th execution of the first loop, there exists at least one tile σ of T iling(jk) of S that is neither black nor white. Without loss of generality, we assume that j is the first integer for which this occurs.
In view of the minimality of j, we know that just before starting the j-th execution of the first loop, each tile of T iling((j − 1)k) is either black or white. Moreover, for every positive integers z ≤ z, every couple of points that belong to the same tile of T iling(z) of S, also belong to the same tile of the coarser tiling T iling(z ) of S. Hence, just before starting the j-th execution of the first loop, each tile of T iling(jk) is either black or white.
During the execution of the first loop, the points that become black remain always black thereafter. Since there exists a tile σ of T iling(jk) of S that becomes neither black nor white during the j-th execution of the first loop, at some point during this execution, the agent does not paint black all points of σ when executing line 16 of Algorithm 5. However, each time the agent executes line 16 of Algorithm 5 within the j-th execution of the first loop, when a point of a tile t of T iling(k) of any tile of T iling((j − 1)k) of S is painted black, then all points inside and on the boundary of tile t are painted black. By definition, t is a tile of T iling(jk) of S. Hence, at the end of the j-th execution of the first loop, each tile of T iling(jk) of S is either black or white. Hence, we get a contradiction with the existence of σ which proves the lemma. Proof. The walk made by the agent executing function Mosaic(i,k) can be divided into two parts: the first part P 1 is the walk made by executing lines 1 to 21 of Algorithm 5, while the second part P 2 is the walk made by executing lines 22 to 31 of Algorithm 5. The distance traveled in P 1 (resp. P 2 ) will be denoted by |P 1 | (resp. |P 2 |). We first focus on the distance traveled in part P 1 , in which the walk made by the agent is as follows: for each j ∈ {1, . . . log 4 k √ 2 i }, starting from the center of S, the agent moves to the center of every white tile of T iling((j − 1)k) of S. By Algorithm 5, the side length of S is 2 i , and thus the distance between any two points of S is upper bounded by 2 i+1 . Moreover, if for every non-negative integer s, we denote by Q s the number of tiles in T iling(s) of S, then we have In view of the definition of a tiling, for all j ∈ {1, . . . log 4 k Hence, in view of (5) and (7), we have In view of the definition of a tiling, we have Hence from (9) and (12), we obtain We now consider the distance traveled in part P 2 . Here, there are two cases: either IndexM ax = k when the agent starts executing line 22 of Algorithm 5, or IndexM ax = k when the agent starts executing line 22 of Algorithm 5. In the first case, P 2 corresponds only to the move made when executing line 30 of Algorithm 5. However, during the entire execution of Algorithm 5, the agent never leaves the straight square S, centered at O, whose sides have length 2 i . Hence in the first case, The second case is trickier to analyze. Indeed, we have to take into account the distance traveled when executing line 30 of Algorithm 5 (that is upper bounded by 2 i+1 in this case as well) but also the distance traveled when executing lines 23 to 28: note that since those lines are executed, we necessarily have the following claim in the second case. It follows from (14) and (16) that the area of the white surface at the end of part P 1 is at most which concludes the proof of the claim. Now, we are ready to compute |P 2 | in the case where the condition IndexM ax = k holds when the agent executes line 22 of Algorithm 5. The value of |P 2 | is the sum of the distance traveled when executing line 30 (upper bounded by 2 i+1 ) and of the distance traveled when executing lines 23 to 28. When executing the latter block of lines, for each white tile t of T iling(k( log 4 k √ 2 i )) of S, the agent performs successively the two following actions: 1. The agent moves to the center of t, at a cost of at most 2 i+1 .
2. Once the center of t is reached, the agent executes procedure RectangleScan(t), at a cost of at most 5l · max(2, l) (cf. Proposition 2.1) with l equal to the side length of tile t.

2
. Thus, from (20) we have the following: So, whether IndexM ax = k or not when the agent starts executing line 22 of Algorithm 5, we have which concludes the proof of the lemma.
Let ψ be the index of 2π − β. The next proposition follows from Proposition 4.2.
We are now ready to prove the final result of this section.
Theorem 4.1. Consider an agent A and a treasure located at distance at most D from the initial position of A. By executing Algorithm TreasureHunt2, agent A finds the treasure after having traveled a distance in O(D 2− ), for some > 0.
Proof. We will use the following two claims. In view of Algorithm 4 and Proposition 4.3, the returned value of Mosaic(i, * ) is a positive integer that is at most ψ. Since v 1 = 1, this implies that ψ ≥ 2. Moreover, for all 2 ≤ j ≤ ψ, we have v j ≥ v j−1 (cf. lines 5-6 of Algorithm 4 and lines 4, 11-12 of Algorithm 5). Hence, there exists an integer k ≤ ψ such that v k = v k−1 . However, according to Algorithm 4, this implies that the number of executions of the repeat loop in the i-th execution of the external loop is at most k ≤ ψ. This is a contradiction which concludes the proof of the claim. (1 − log 4 ψ (4 ψ − 1)). Since ψ is a positive integer, we have 0 < log 4 ψ (4 ψ − 1) < 1 and hence > 0. This ends the proof of the claim.
Assume that the theorem is false. As long as variable i does not reach log 2 D + 2, the agent cannot find the treasure, as this would contradict Claim 4.4. Thus, in view of Claim 4.3, before the time τ when variable i reaches log 2 D + 2 the treasure is not found. By Algorithm 4, this implies that during the last call to function Mosaic before time τ , the function returns a value that is equal to its second input parameter. This implies that during this call, the agent has executed lines 23 to 28 of Algorithm 5: more precisely, there is some integer x such that from each white tile t of T iling(x) of the straight square S that is centered at the initial position of the agent and that has sides of length 2 log 2 D +1 , the agent has executed function RectangleScan(t). Hence, at the end of the execution of lines 23 to 28, the agent has seen all points of each white tile of T iling(x) of S. Moreover, in view of Lemma 4.1, we know that the tiles that are not white, in T iling(x) of S, are necessarily black. Given a black tile σ of T iling(x), each point of σ is black, which, in view of lines 15 to 17 of Algorithm 5, implies that σ cannot contain the treasure. Since square S necessarily contains the treasure, it follows that the agent must find the treasure by the end of the last execution of function Mosaic before time τ . As a consequence, the agent stops the execution of Algorithm 4 before assigning log 2 D + 2 to variable i and thus, we get a contradiction with the definition of time τ , which proves the theorem.

Arbitrary angles
In this section we observe that if hints can be arbitrary angles smaller than 2π then the treasure hunt cost Θ(D 2 ) cannot be improved in the worst case. We prove the following proposition.
Proposition 5.1. If hints can be arbitrary angles smaller than 2π then the optimal cost of treasure hunt for a treasure at distance at most D from the starting point of the agent is Ω(D 2 ).
Proof. Consider the disc D of radius D centered at the initial point of the agent. Consider any position of the agent and suppose that the angle given as hint has size γ > π. Call the complement of the hint the forbidden angle. It has size α = 2π − γ < π. The forbidden angle has the property that the treasure must be outside of it. If the current position of the agent is outside of disc D then the forbidden angle of size α can be chosen in such a way that it is disjoint from D, i.e., that it does not exclude any point of the disc D as a possible location of the treasure. If the current position of the agent is in D, then the intersection of the forbidden angle with D has area at most α 2π π(2D) 2 = α · 2D 2 , as it is at most the area of a sector of the disc with radius 2D and angle α.
Suppose that there exists a treasure hunt algorithm at cost at most D 2 /2. Let the sizes of forbidden angles corresponding to consecutive hints be 1 2 , 1 4 , 1 8 , ... etc., each of size half of the preceding, and such that the forbidden angle is disjoint from the disc D, whenever the current position of the agent is outside of D. When the position is in D, the angle of the respective size can be chosen arbitrarily. The total area of the intersection of D with the forbidden angles is at most ( ∞ i=1 1 2 i ) · 2D 2 = 2D 2 . This leaves out a part of the disc D whose area is at least (π − 2)D 2 . During the walk of length at most D 2 /2 of the agent, the set of points of D from which the agent is at distance at most 1 at some point of the walk has area at most D 2 2 · 2 + π = D 2 + π. For D > 5 we have (π − 2)D 2 > D 2 + π. Hence there exists a point of D not included in any of the forbidden angles, from which the agent has never been at distance at most 1. Placing the treasure in this point refutes the correctness of the treasure hunt algorithm. This implies that the trajectory of the agent must have length larger than D 2 /2, for D > 5, hence the optimal cost of treasure hunt is Ω(D 2 ).

Conclusion
For hints that are angles at most π we gave a treasure hunt algorithm with optimal cost linear in D. For larger angles we showed a separation between the case where angles are bounded away from 2π, when we designed an algorithm with cost strictly subquadratic in D, and the case where angles have arbitrary values smaller than 2π, when we showed a quadratic lower bound on the cost. The optimal cost of treasure hunt with large angles bounded away from 2π remains open. In particular, the following questions seem intriguing. Is the optimal cost linear in D in this case, or is it possible to prove a super-linear lower bound on it? Does the order of magnitude of this optimal cost depend on the bound π < β < 2π on the angles given as hints?