Build Queues for every entity and tile type

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

darklich14
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Sat Feb 24, 2018 3:07 am
Contact:

Build Queues for every entity and tile type

Post by darklich14 »

I know that it would require a bit more overhead, but imagine a round robin whereby the ghosts were serviced X at a time per tick PER entity type. This way, no particular item type starves, and especially beneficial is that power and robot infrastructure can be built in parallel with all the other entities under the construction zone. The limitations of ghosts outside build range are still acceptable and appropriate, but now solar won't jam assembling machines. Landfill won't jam concrete. Again, I acknowledge that there is overhead to this but even in the most complex mods, we're talking about a few hundred lists instead of 2 lists. For the benefit in multiplayer experience, this seems like a worthwhile algorithmic pivot.

Thoughts?
User avatar
NotRexButCaesar
Smart Inserter
Smart Inserter
Posts: 1133
Joined: Sun Feb 16, 2020 12:47 am
Contact:

Re: Build Queues for every entity and tile type

Post by NotRexButCaesar »

This would be very useful and solve a really unintuitive problem. The only question is what goes in each group.
—Crevez, chiens, si vous n'étes pas contents!
darklich14
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Sat Feb 24, 2018 3:07 am
Contact:

Re: Build Queues for every entity and tile type

Post by darklich14 »

AmericanPatriot wrote: Wed Aug 05, 2020 2:26 pm This would be very useful and solve a really unintuitive problem. The only question is what goes in each group.
Put each new construction request at the beginning of each queue to give it a preemption opportunity. Literally a separate list for every entity type in the game no matter whether it's a mod or base game. Additional entity gets additional queue. Then the rest of the game dynamics apply from there on out.
mrvn
Smart Inserter
Smart Inserter
Posts: 5853
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Build Queues for every entity and tile type

Post by mrvn »

Not a few hundred lists. Make a hashtable of lists. Each item goes into their own list. If no such list exists yet it gets added to the hashtable. When it becomes empty it gets removed.

The hashtable would allow finding the list for each item in O(1) and also allow iterating through the used entries in O(1) [assuming the table grows/shrinks dynamically]. That way you don't have to worry about the number of lists or about items with no ghosts. The order of the lists might change as lists are added or removed to the hashtable but all that would mean is that sometimes you might get 2 chemical plants build in a row or so.
darklich14
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Sat Feb 24, 2018 3:07 am
Contact:

Re: Build Queues for every entity and tile type

Post by darklich14 »

mrvn wrote: Wed Aug 05, 2020 3:06 pm Not a few hundred lists. Make a hashtable of lists. Each item goes into their own list. If no such list exists yet it gets added to the hashtable. When it becomes empty it gets removed.

The hashtable would allow finding the list for each item in O(1) and also allow iterating through the used entries in O(1) [assuming the table grows/shrinks dynamically]. That way you don't have to worry about the number of lists or about items with no ghosts. The order of the lists might change as lists are added or removed to the hashtable but all that would mean is that sometimes you might get 2 chemical plants build in a row or so.
That's fine. The underlying data structure can be optimized. Round robin doesn't care about O(1) performance though. The list for an entity could be removed if there are no construction requests. These are all marginal implementation details compared to the overarching goal of preventing starvation of any particular type of entity.
Post Reply

Return to “Ideas and Suggestions”