Snidely <Snidely.too@[EMAIL PROTECTED]
> wrote:
> On May 13, 10:40 pm, huey.calli...@[EMAIL PROTECTED]
wrote:
> > 3) it makes the code ****table, because then anybody can start the
> > object in any space, and it'll find its own borders. If he
> > hardcodes the space it's allowed to go in, it only works in his
> > space.
> I wasn't hardcoding the space. I was discovering the space. I just
> wasn't modelling 1 single bird in flight.
Well, if you wanted to speed it up, you could make it a silent bird
with a telescope that was capable of hyperspace-jumps from point to
point, and rewrite my algorithm as follows
If (distance) is more than one unit away,
look (distance) in (direction). Do you own that?
If so, go there and iterate.
If not, iterate looking distance/2.
If not, you've found an edge. Iterate with (distance=as far as you can
go) and (direction = direction + 90deg)
Call that initially with distance="as far as you can look" and a random
direction, and it finds the same rectangles I found with the last one --
which aren't the edges, just some rectangle bounded by the edges,
depending on the shape you're in and where you start in that shape.
Following the edge exactly is harder. Once you've found the edge in the
above one, instead of iterating again, you'd need to go:
Have you been here before? If not,
Look around
in case (you own:)
squares to your left and front: /* you're following the right-hand wall
take a step forward and iterate
squares to your left and right, but not in front of you: /* looking at
wall
turn left, take a step forward, and iterate
squares to your left: /* you've found a corner
turn left, take a step forward, and iterate
none of those three squares: /* you're at the end of a blind alley
turn around, take a step forward, and iterate
sqares to your right (regardless of owner****p of the other two)
/* meaning that you've lost the wall
turn right, take a step forward, and iterate
If so, we're done.
The first piece of code, you don't need to store anything, because all
it's doing is finding one random spot on the wall. The second one will
actually find your fenceline, so if you need the exact boundaries of
everything, you'd need to store all of that. But an invisible massless
hummingbird still ought to be able to do it pretty fast.
Next question: Your invisible massless hummingbird tells you:
(8,6)
(8,7)
(8,8)
(8,9)
(8,10)
(7,10)
(7,9)
(6,9)
(5,9)
(5,8)
(4,8)
(3,8)
(3,7)
(2,7)
(2,6)
(1,6)
(1,5)
(0,5)
(0,4)
(1,4)
(1,3)
(1,2)
(2,2)
(2,3)
(2,4)
(3,4)
(3,3)
(3,2)
(3,1)
(4,1)
(4,2)
(5,2)
(5,1)
(5,0)
(6,0)
(6,1)
(6,2)
(6,3)
(6,4)
(7,4)
(8,4)
(8,5)
(8,6)
....now, that's an ugly-ass figure. How do you code other objects to
efficiently stay within the bounds of that?
I think the moral of this story is "Well, don't do that then".
Only own rectangular parcels.
--
Huey


|