Hello,
at the moment we’re going to speak about some flying robotic habits enhancements. Some of the issues we mounted have been reported numerous instances, so I hope that some folks will admire it :).
Quality of life versus flashy featureskovarex
I do know that you’re primarily trying ahead to the brand new content material, and that simply
high quality of life enhancements aren’t the form of issues that make folks purchase the sport and get excited for.
But I strongly consider, that if you wish to add content material, mechanics, and programs to a recreation, which already is not easy, there’s at all times a danger of simply it being an excessive amount of. By doing QOL enhancements, we scale back the small hassles and annoyances, which successfully creates an additional psychological area to take pleasure in extra within the recreation. Its like cleansing your room earlier than getting a brand new toy.
So to make issues clear, the explanation that we make and current these form of modifications will not be as a result of we do not need to make new flashy options, we simply need the brand new stuff to be gratifying with out a burden of getting an excessive amount of to cope with.
But don’t be concerned, we’ll present one thing new subsequent week!
Smarter robotic tasksOxyd
Logistic and development robots have been within the recreation for some time, and at their
core they’re pretty easy entities. A logistic robotic, for instance, could also be instructed
to go decide up an merchandise from a chest, and ship it to a different chest. So far so
good, however in Factorio there normally is multiple merchandise to be transferred —
so what does the sport do when tasked with transferring, say, 500 objects from one
field to a different?
The Old Way
In Factorio 1.1, the sport retains an inventory of all idle robots, together with these
hiding away in roboports, and when a activity must be taken care of, it
selects the closest idle robotic from that checklist. So, to switch 500 objects from
a supplier chest to requester, the sport would discover the primary idle robotic
closest to the supplier chest and activity it with the switch. This robotic now
has a activity, so it’s faraway from the checklist of idle robots.
But we nonetheless have 499 different objects to switch (ignoring robotic capability bonus
for simplicity). The logistic community merely repeats the earlier steps for
all the opposite objects — discover the subsequent closest idle robotic, activity it with
transferring the subsequent merchandise and so forth till there’s a robotic for every of the
500 objects within the field.
The drawback with this technique is that whereas the primary few robots could also be
positioned in roboports fairly near the supplier chest, by the point we
get to the final objects the community could have to succeed in for robots on the different
finish of the manufacturing facility as a result of there isn’t a nearer idle robotic for the duty. The
finish result’s that the primary batch of robots will arrive on the chest, take
the merchandise and ship it to the vacation spot, after which recharge and go have a
nap in a roboport — transferring a single merchandise was all these robots have been
tasked with and the remaining objects have already been assigned to different
robots. After that, a sluggish trickle of robots from distant elements of the
manufacturing facility will are available in and switch the remaining objects.
The state of affairs is comparable for development robots, and this may be particularly
obvious when utilizing one’s transportable roboport. Say the participant needs to take away a
bunch of bushes of their manufacturing facility. A single private roboport can have up
to 25 development robots, in order that’s as much as 25 bushes that can be
deconstructed utilizing the participant’s private robots. All remaining bushes will
be assigned to robots from the primary logistic community, and the participant will
have to attend for them to reach for the bushes to be gone — though the
participant’s private robots are proper there with nothing higher to do!
The New Way
Choosing a robotic for a activity solely from the checklist of idle robots clearly is not
one of the best technique. Assigning a activity to a robotic that’s at present busy however
close by could also be a more sensible choice, even when the brand new activity could have to attend till
the robotic finishes its different duties. This required two fundamental modifications to the
logistic community code.
The first change was to permit robots to have a number of duties assigned to
them. Much of the code has been written with the belief {that a} robotic
has precisely one job, however after some code refactor, robots now have a queue of duties.
Second, we’d like a method to choose a robotic for a activity. Each activity has a beginning place,
for instance a deconstruction order begins on the entity to be deconstructed. Until now, the choice course of
was easy — simply choose the idle robotic closest to that time.
But now, after we can even choose a robotic with a number of queued duties, the method
turns into a bit extra complicated.
The new metric for robotic choice is the arrival time. For an idle robotic,
its arrival time is solely the space to the beginning place divided by its velocity.
For a busy robotic, we will look via its queue of duties, work out the place and when the robotic is
going to finish up when its completed, after which add the flight time from there to the beginning place of the brand new job.
When choosing a robotic for a activity, we choose the one that’s going to reach first, even when it has to take care
of different issues earlier than that.
It is value stating that the arrival time calculation is just an estimate.
For instance, we simplify the results of the recharging instances.
A keen-eyed participant will little doubt discover conditions the place selecting a distinct
robotic might have been somewhat bit extra environment friendly.
But within the massive image, it would not appear to be very noticeable.
Let’s see how the brand new system handles our earlier two examples. The preliminary batch of robots is tasked with
transferring all of the objects which leads to them shuffling backwards and forwards
between the requester and the supplier.
For deconstructing bushes, every of the participant’s private robots does greater than
only a single tree. Robots from the primary community nonetheless come to assist out, however
this time it is as a result of they will help get the entire job completed quicker.
Performance
Having a easy checklist of all busy robots and going via it every time a brand new
activity is available in may go positive for small factories, however with a number of thousand
robots flying all over the place it may rapidly develop into a UPS drain. To alleviate
that, we applied a distinct illustration.
Whenever a robotic’s queue of duties is up to date, it calculates its closing
place estimate — that’s, its closing place and the time at which it
will end. Each map chunk now shops an inventory of all busy robots which can be
estimated to complete on that chunk. So when a robotic updates its closing place
estimate, it registers itself in that chunk’s checklist of robots. When looking out
for a robotic for a selected activity, the sport now begins its search on the
chunk the place the job’s beginning place is positioned, and continues its search in
an outward spiral.
Storing busy robots on chunks and looking out in a spiral improved the
efficiency by so much, and even factories with 1000’s of busy robots run properly.
Smarter robotic different thingsKlonan
While enjoying and growing the enlargement for the final 2 years, we now have additionally accrued a number of extra options and modifications to make the robots really feel smarter and work higher.
Roboport robotic requests
There are some conditions when it’s essential ensure that some roboports at all times have robots to service duties. For instance when you have somewhat resupply level with buffer chests, you need logistic robots round to rapidly empty your trash and refill your provides. It is kind of annoying when all of the supplies are proper there, however you’re caught ready round, as a result of resulting from pure robotic migratory patterns, the roboports within the space are fairly empty.
It may very well be solved with requester chests, inserters, circuit community, and such… however we determined a smoother strategy. You can now set logistic requests for robots straight contained in the roboport GUI. Robots can be dispatched from different roboports to satisfy the request (necessary to notice, robots is not going to be taken from storage or supplier chests).
With this new function, we will set all of the roboports close to our resupply level to at all times have 100 logistic robots accessible. Once we arrive, our wants are serviced in report time, and afterwards you’ll be able to see robots arriving to get the roboport again as much as 100.
Another good use of that is that we will use the roboport requests to take away sure robots from the community. Perchance we had some mod with increased high quality employee robots, we will request the low high quality ones and take away them with a filter inserter, over time eradicating the more severe robots from circulation.
Better robotic charging heuristic
When a employee robots runs low on vitality, they should discover a close by roboport to cost at, however they have to be somewhat bit good about it. For occasion in the event that they at all times selected the closest roboport, then you definately would get queues and site visitors jams at some roboports whereas others are fully empty.
For these ‘smarts’ we use a fairly easy heuristic, factoring in not simply how shut the roboport is, but in addition what number of different robots are at present charging there. Typically this labored ‘properly sufficient’ however every now and then you possibly can encounter somewhat inconvenient state of affairs the place they’re nonetheless bunching up on some roboports whereas ignoring others which can be just a bit bit additional.
In some excessive circumstances this will really be fairly an issue, because the robots ready to cost nonetheless use vitality for hovering, so lose extra vitality, in a optimistic suggestions loop the place all robots who be a part of the queue will fall to 0 vitality whereas they’re ready their flip. Generally although the primary drawback right here is that the participant appears on the robots and thinks “These robots are so dumb…”. Not the top of the world, however we will do higher…
Surprisingly on this case the problem could be helped so much by only a small enchancment within the heuristic logic. When deciding which roboport to cost at, the robots crucially didn’t take into account the present robots on the way in which to that roboport, solely these already within the queue, and didn’t think about what number of free charging spots the roboport has open. By including these two additional parameters into the equations, the distribution of the robots improves fairly properly.
Mitigation for robotic pathing over lakes
It has been an issue for a very long time, the robots are fairly dumb on the subject of pathfinding, and attempt to fly over areas that don’t have any logistic community protection. This is as a result of for efficiency causes, we do not do any pathfinding in any respect. The robots simply fly in a straight line to the job place.
One main drawback of that is the potential of the robots to get caught in an infinite loop. This is as a result of they fly out over uncovered territory, run out of battery, and return again to recharge and take a look at once more. Obviously they are going to by no means make it.
This difficulty was notable sufficient and annoying sufficient for us that we actually did need to give you a repair. The resolution we got here to was a wise trick within the roboport choice after they run out of vitality. Usually the robotic simply chooses one of many nearest roboports, which is okay for regular circumstances, however on this case results in the robotic turning fully round in failure.
So we modified the choice logic, in order that the robotic tries to at all times cost at a roboport that’s nearer to the vacation spot than the robotic is. This signifies that even when the robotic will probably fly with low vitality for longer, it’s going to at all times have the ability to make some progress in the direction of the goal, and ultimately full their mission.
It will not be an ideal resolution, however ought to hopefully assist stop probably the most egregious difficulty of this technical constraint.
As at all times, tell us what you assume on the standard locations.
…. to be continued
Read the Original Article
Copyright for syndicated content material belongs to the linked Source : Hacker News – https://factorio.com/blog/post/fff-374