Effective definition of set boundaries

I am writing an AI for playing RTS using the API that the game offers. One thing I want to do is define a set of line segments that limit the enemy nation. However, the game offers only a function that tells me the team identifier from one two-dimensional point of the territory.

Requests for the AI ​​game are incredibly expensive to complete, so I need the number of requests to be an absolute minimum, even if it means that sometimes a slightly worse quality response is obtained. It is also better to overestimate the territory of an enemy territory than to underestimate it.

How can I effectively determine the set of bounding lines around a non-convex region of space using the minimum number of queries?

Nb: Bonus points for the answer written in Lua, but also pseudo-code.

+3
source share
3 answers

I assume that you can find a point in the space that is in the territory. Call it Z. (Since you have several cities, you can choose the average location of the city as a kind of central place.)

Given the starting point Z, I would think about creating a set of rays from this point, with each ray having a lower and upper bound in size, and a set growing in quantity to get the details. I sketched the diagram below. Nothing about this has been verified; Feel free to suggest improvements.

Theta Z. : Inside Outside, . Inside 0, , , , ( "Horizon" ); , , , , (log2 N ). , , . , , "" .

(theta = North (0), Inside = 0, Outside = Horizon). R. , R , r R, (r) , (r) R . , , . .

"" .

R = empty
add_to_R(0,0,Horizon)
repeat until done
    done = true
     for each ray r in R
      guess = average(Inside(r),Outside(r))
      if guess>threshold
         then done = false
      if interritory(Z+(Theta(r),guess))
        then Inside(r)=guess
        else Outside(r)=guess
     for each ray r in R
       if (distance(Inside(r),Inside(next(r)))> spacing
          then add_to_R(average(Theta(r),Theta(next(r)),
                        min(Inside(r),Inside(next(r)),
                        max(Outside(r),Outside(next(r))
end

log 2 , , .

; , . , . , , , , , , , .

+2

, . http://en.wikipedia.org/wiki/Convex_hull

O (n log n) - . . http://en.wikipedia.org/wiki/Graham_scan

: , , , . ( , , , ), .

: , , . "", - () "".

+3

-

http://en.wikipedia.org/wiki/Monte_Carlo_method

, "" , ( ).

, . , , , .... .

EDIT:

, , /... , , .

, , , . , ( , ), , ... , .

. , /.

+2

Source: https://habr.com/ru/post/1789827/


All Articles