[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] AI Module (was: Perlin Noise Function)



On Wed, Jul 30, 2008 at 6:20 PM, Knapp <magick.crow@xxxxxxxxx> wrote:
>
> That works unless you game is about space and which star out of 30,000 is
> close. Then the idea of finding the distance to everything gets a bit slow.
> To solve this you can take the position and divide by some distance that you
> think of as close in the X,Y,Z.  and take the integer quotient. If it is 0
> then the object is is your close box.
>
> 1,1,1
> 5,5,5
> 20,20,20
>
> close is a cube 10,10,10 so you get
> 0,0,0
> 0,0,0
> 2,2,2
>
> the first 2 are close.
>
> You can do this for are large bunch of objects and keep the result so that
> you only need to check small subsets of the whole and it is pre-calculated.
> If only a few are moving it is a quick check to see if they moved to a new
> cell.

Nice, but this algorithm doesn't take object sizes in consideration,
only position. Also, it only determines wether something is close to
the origin, so you'll have to calculate relative positions if your
object is not at (0, 0, 0). This then becomes not very different from
finding distances, perhaps even slightly less efficient because of the
expensive modulo operation. Or am I misunderstanding something here?

Not my point, however. Closeness is a generalization of collision
detection, and pygame only handles simple cases of this. What you
describe seems like a form of binary space partitioning, which is not
a simple case.