Fractal Softworks Forum

Starsector => General Discussion => Blog Posts => Topic started by: Alex on March 20, 2018, 03:38:42 PM

Title: Orbital Fleet Behavior
Post by: Alex on March 20, 2018, 03:38:42 PM
Blog post here (http://fractalsoftworks.com/2018/03/20/orbital-fleet-behavior/). Just a short look at something I was working on, this time around.
Title: Re: Orbital Fleet Behavior
Post by: c plus one on March 20, 2018, 03:41:56 PM
An imminent dev blog-post! The suspense.

All fighters, report in. Red One standing by.....  :D
Title: Re: Orbital Fleet Behavior
Post by: PCCL on March 20, 2018, 03:45:38 PM
does the player fleet factor into this? I imagine the AI wouldn't make us move our fleet, but would other fleets move out of our way?
Title: Re: Orbital Fleet Behavior
Post by: Alex on March 20, 2018, 03:52:31 PM
does the player fleet factor into this? I imagine the AI wouldn't make us move our fleet, but would other fleets move out of our way?

It actually doesn't factor in at all because it uses slightly different mechanics to orbit a planet.
Title: Re: Orbital Fleet Behavior
Post by: Clockwork Owl on March 20, 2018, 04:03:28 PM
Woah, woah, woah... Another blogpost this fast? Are you working overtime or something?
Title: Re: Orbital Fleet Behavior
Post by: Techhead on March 20, 2018, 04:06:01 PM
When I saw the second screenshot, I actually thought the ships looked too spread out, but after seeing the gif, I have to admit it looks great in motion.

The mini-blogposts when you have small things to talk about is nice, I think. I wouldn't mind reading more in the future.
Title: Re: Orbital Fleet Behavior
Post by: Wyvern on March 20, 2018, 04:09:35 PM
The mini-blogposts when you have small things to talk about is nice, I think. I wouldn't mind reading more in the future.
Agreed.

Not a lot to say about this one beyond 'neat effect' and 'tinkering with collective behavior is fun' - but worth saying both of those.
Title: Re: Orbital Fleet Behavior
Post by: Alex on March 20, 2018, 04:40:03 PM
Woah, woah, woah... Another blogpost this fast? Are you working overtime or something?

Hah, usually. Trying to be better about it, though; not great to overdo it in the long run. (Case in point: when I've got more energy, it's easier to do public-facing things like blog posts!)

When I saw the second screenshot, I actually thought the ships looked too spread out, but after seeing the gif, I have to admit it looks great in motion.

Funny, had a similar thought on looking at the screenshot. It really does need the circular motion to get a feel for it.

The mini-blogposts when you have small things to talk about is nice, I think. I wouldn't mind reading more in the future.

Thank you for the feedback! Was wondering about that myself.


Not a lot to say about this one beyond 'neat effect' and 'tinkering with collective behavior is fun' - but worth saying both of those.

Hah! Thank you for saying it :)
Title: Re: Orbital Fleet Behavior
Post by: hawkeye on March 20, 2018, 05:50:58 PM
Sounds like N^2 time complexity to me... that will get slow in a busy system.


I recommend a different approach:

Imagine radial lines going out from the station making many pie slices.
Now, slice those pies with circle cuts at various radius's from the station.

Fleets ask the station for a pie slice that fits their fleet size. (larger fleets being farther out around the station)

Given each ring of slices, the station gives them out in a pseudo random order.
The station doesn't need to know if a slot is still being occupied or not, it simply knows it's unlikely since it would've had to cycle through all the other slots in that ring before repeating the pseudo random selection.
If there are still issues, there are two extra measures you can take. One, favor rings that haven't been used as heavily if the ship is "close enough" to fit that orbit radius. Two, each time a ring completes a pseudo random cycle, offset the whole thing a half slice. This way, even if you filled it up again, the ships would only overlap 50%.

The result is trading O(n^2) processing for O(1) processing and O(1) memory.

Title: Re: Orbital Fleet Behavior
Post by: Alex on March 20, 2018, 06:44:26 PM
Hey - thank you for your suggestion!

Basically, it's getting a potential performance improvement in exchange for reduced behavior quality.

That might well be worthwhile if O(n^2) performance here was a real concern, but it's quite far from it. An extremely busy system might have 30, 40 fleets, and this should easily perform well enough with several hundred. In addition, if O(n^2) performance in the number of fleets was an issue, this would likely not be the main bottleneck; at that point I'd probably add a bin-lattice (such as the combat layer uses) to make "give me everything within a given radius" queries O(n^2) relative to the radius (divided by a constant) instead of to the number of fleets - and then use that across the board.
Title: Re: Orbital Fleet Behavior
Post by: shoi on March 20, 2018, 09:58:11 PM
I don't know if this is weird but  I really appreciate the detail you went into on explaining the logic behind your algo. Cheers  ;D
Title: Re: Orbital Fleet Behavior
Post by: Thaago on March 20, 2018, 10:17:00 PM
This was neat! Its always nice to read about the process, even in small cases.

Quote
... Like cars going down the right side of the road without having to talk about it. ...

What magical fantasy land do you live in? :P
Title: Re: Orbital Fleet Behavior
Post by: CrashToDesktop on March 20, 2018, 10:59:05 PM
I quite like these mini blog posts.  Keep it up!
Title: Re: Orbital Fleet Behavior
Post by: AxleMC131 on March 21, 2018, 01:04:06 AM
Short and sweet makes a good blog post on an otherwise busy day.  ;D

Also that gif of the fleets moving around in real time is simply beautiful.
Title: Re: Orbital Fleet Behavior
Post by: Draba on March 21, 2018, 01:40:54 AM
To me small mechanical tidbits like this are actually more interesting than the sweeping teasers.
One of those times when the logic is really simple but the resulting behavior could be mistaken for intelligence.
Title: Re: Orbital Fleet Behavior
Post by: SCC on March 21, 2018, 06:18:03 AM
does the player fleet factor into this? I imagine the AI wouldn't make us move our fleet, but would other fleets move out of our way?
Player fleet kinda is allowed to overlap, because it's transparent for selection purposes, so it doesn't really need not to overlap.
Title: Re: Orbital Fleet Behavior
Post by: Alex on March 21, 2018, 10:45:49 AM
I don't know if this is weird but  I really appreciate the detail you went into on explaining the logic behind your algo. Cheers  ;D
I quite like these mini blog posts.  Keep it up!
To me small mechanical tidbits like this are actually more interesting than the sweeping teasers.
One of those times when the logic is really simple but the resulting behavior could be mistaken for intelligence.

Glad you're finding it interesting, thank you!

Quote
... Like cars going down the right side of the road without having to talk about it. ...

What magical fantasy land do you live in? :P

... fair point.
Title: Re: Orbital Fleet Behavior
Post by: mav on March 21, 2018, 11:38:07 AM
Thank you for the blog post, found it quite interesting learning a bit about what's going on behind the scenes regarding such a seemingly small detail.

The small things do matter. :)
Title: Re: Orbital Fleet Behavior
Post by: Gothars on March 21, 2018, 12:10:56 PM
You could play a bit with this by having low stability influence orbiting behavior negatively. Then if a player spots fleets orbiting a planet in a messy way, shoving and jockeying, he'd immediately know something's up.

Title: Re: Orbital Fleet Behavior
Post by: Alex on March 21, 2018, 03:42:31 PM
Thank you for the blog post, found it quite interesting learning a bit about what's going on behind the scenes regarding such a seemingly small detail.

Cool!

You could play a bit with this by having low stability influence orbiting behavior negatively. Then if a player spots fleets orbiting a planet in a messy way, shoving and jockeying, he'd immediately know something's up.

Huh, that's a very neat idea! Not quite sure how to implement it, though - I guess could allow more overlap at lower stability? Hmm. Don't know if that'd really convey that properly; it wouldn't exactly be "more jostling". Tough to do something half-way here without it potentially looking like a bug.

(Speaking of things like that - just took out the name "Random" from the list of star names. It's a Chronicles of Amber reference, but it just looks wrong when you see it pop up, so, sadly, it had to go. Erm, point being that sometimes things that are right look wrong...)
Title: Re: Orbital Fleet Behavior
Post by: SCC on March 21, 2018, 03:57:02 PM
Danger could be conveyed via ships staying further away from one another or moving out of the way briefly.
Title: Re: Orbital Fleet Behavior
Post by: Kanil on March 21, 2018, 04:29:18 PM
I'm not sure stations are regularly crowded enough to justify orbits conveying information to the player. Not that it would be a negative to add, but it seems like something you'd never notice.

Like others, I enjoyed the mini blog.
Title: Re: Orbital Fleet Behavior
Post by: icepick37 on March 23, 2018, 09:07:10 AM
Huh. Neat!

I appreciate your ability and sense in crafting these simple but elegant solutions to interesting problems like this.

I would definitely be interested any time you post these mini-blogs. They are fun.