vgstation-coders / vgstation13

Butts
GNU General Public License v3.0
260 stars 540 forks source link

Bee-yond byond's limits. #17905

Closed nuklearcellphoneg closed 6 years ago

nuklearcellphoneg commented 6 years ago

bee1 bees2

Okay, so for a little background I decided to make a bee factory going for relative efficiency. Two things about the structure.

The apiaries are formed into a central core:

X X X X X X X X X

These apiaries are surrounded by a square of flowers to max out their nectar gain. You get in the center there, you start off with about 200 bucks as botany, so you can order at least ten bee crates, which is thirty queen bees. You can just keep stuffing these queens into the central apiary. Whenever it's too full, they'll colonize a new apiary around. Now the fun part.

They'll generate lots of new bees and have plenty of food constantly with very little delay for their reproduction. In this way(there are aux apiaries around it but you get the gist for the core) you can simply continue harvesting that central apiary, put it back down, all the surrounding apiaries which are overstuffed will immediately fill the new apiary. Repeat until the surrounding apiaries no longer feed into it. Wait a minute. Boom, continue on.

So it's fairly simple to mass produce these bees. Now, I will point out some of the major issues that arise due to this:

  1. There is not a large enough swarm. As you can see in my list, there needs to be ever larger swarms for these bees to feed into, within the expected amount a botanist could produce them(the bees themselves lag people, and if you move say south east of it, each swarm will follow tick by tick. However let's say you move south two steps before this 'train' or 'slinky' of bees get to that previous spot, at this amount they will finish moving there first, then the first to have moved will begin to move towards you.

  2. Bees seem to form into factions? So in my above scenario, the bees I am producing are homeless(which means they also won't seek out a hive when calm... and won't ever die from starvation either. They can be killed). These bees are angry at different people than other bees. So if you calm this swarm, and the nectar collecting bees are also made, it's possible they won't collectively calm down.

  3. As evidenced by the fire that killed these bees, as the swarm dies, it produces one bee at a time. There were... from what I can see... maybe 1,500 dead bees? When ZAS kicked in there, byond died in loading for about fifteen second I'd like to say. There are no ways to remove these dead bees either, as far as I can tell.

To summarize: There needs to be a few more larger swarms created by the swarms you see in my right click list. If five, ten, whatever of those swarms combine to make an x swarm, that would probably help the lag they naturally create.

Factions? I think that can be covered by the above, I think it's just a side effect of too many bees.

I think if dead bee piles naturally stacked themselves into piles of dead bees, and you could do something to them to get rid of them, that would bee that.

ihadtoregisterforthis commented 6 years ago

Dead bees are decals, scrub them out with cleaning products

DeityLink commented 6 years ago

Thanks a lot for the research nuke. I'm going to do some balance and other QoL to remedy to all of that. Here's how I consider fixing the major issues you listed:

  1. "swarms" of hundreds of bees can currently happen one of two ways: a apiary containing this many bees was deconstructed/angered, or a net containing this many bees was emptied out. IRL, hives can have up to 80.000 worker bees, but for the sake of Gameplay x Performance, queens stop producing new workers once there are 20 workers in it (the actual number is slightly higher due to workers turning into queens if no queens are home, and some workers simply being outside the hive). However, the bug net can currently hold an infinite number of bees, and empty ALL of them inside an apiary (which immediately cause them to die from overpopulation since they need way more nutrients than they can harvest, not counting those who followed a queen to another apiary). Therefore, my planned fix for that issue is to limit the amount of bees a player can empty from a net inside an apiary to a limit (let's say 30-40 bees max per apiary, that's 2 full swarms) and the remainder will remain inside the net. Likewise, a net will have a limit of probably 100 bees (that's 5 full swarms). And will be unable to catch any bee until some of them have been emptied out. I might let the player decide how many bees to empty inside an apiary from a net, and an equal proportion of queen and workers will be moved. (the default value will be all of them, so you can still do quick emptying by hitting enter). Also bug nets currently release bees in stacks of 5 bees for some reason... I'll up that to 20.
  2. I'll allow queen bees to recruit homeless workers if their hive has enough room, while homeless queen bees will add other homeless workers to their swarm, and actively look for nearby empty apiaries. That should solve the problem. Remember that bees from different hives CANNOT stack together, unless picked up with a net (which makes them homeless), so that's why nectar collecting bees would not calm down while a stack of homeless was calmed down. Also it's completely stupid but extinguishers only work if you land the spray right on top of the bees.
  3. As @ihadtoregisterforthis said some space cleaner or anything that cleans will get you rid of those dead bees, however I agree that their current model is thoroughly unoptimized. I think i'll have only one dead bee object per turf, which will collect the appearance of any subsequently dying bees. Oh and also I'll anchor them.

I'd rather not raise the amount of bees per swarm because it can VERY quickly allow them to instacrit players, and because I like watching multiple swarms moving independently. I might allow bee swarms to change targets if they're unable to reach their current one for a few seconds.

Either way I'll do it this week end.

nuklearcellphoneg commented 6 years ago

Please excuse my autism.

On the net, let's say I'm trying to be a benevolent but extreme beekeeper as above, when someone rushes in and releases some of my bees for the sake of lol bees- I just opt to kill the bees at that point, or lure them in by following me, because the net is just going to result in me angering them as I try to catch them, and then spraying, and catching, but angering, etc, making it very hard to be a nice beekeeper.

As a comment on the offensive uses of bees, the above pics are from an antag round and I was planning on using them. Some problems are the above 'lag' with them homing in on people, once the swarm is sufficiently huge. In a previous round, the splitting off of the bees was by far the most useful bit. I walked into medbay, some security was there, it was interesting because they would split off and that added to the difficulty of folks simply shooting me dead.

So the splitting off is very useful for its chaos, however, last night I played before the round which is pictured above. Xenos happened, and I happened to have been producing a massive swarm then too as a nonantag, testing out a first version of the above hive layout. I produced a comparably huge swarm but since it was xenos, no antag set a fire. Now, the splitting off applied here too, but the bee swarm totally wrecked the xenos, because they kept angering the bees which doubled as protecting me from their disarms.

The bees of course wrecked any larva that was tossed near me, and killed two or three of the xenos, and that was without me doing much of anything but walking alongside the swarm.

I understand not wanting to buff the swarm amount, but a single lucky disarm, or spending a moment too close to that thing, will result in your instacrit, if not unrevivable death.

This is compounded by the amount of lag it can produce, and that may vary in the sense that walking into view of the thing I think causes byond to skip a beat(especially of course when things like ZAS happen).

I am unsure as to how to suggest to fix that without having them be the ultimate antag power. I was thinking something like where the attacking swarms at max size as we know it seek out and chase people like they do, but have them, when there are X number on a tile, form into a larger swarm(Call this X swarm) which, when it attacks on its own, has the same damage as one angry swarm, but if attacked redisperses into the X number of swarms and attack in unison.

When enough X swarms form on a tile, they would form a larger still swarm(Y Swarm) which still does as much damage as a regular angry swarm of bees, however again, when it attacks, it disperses into a number of X Swarms.

So 5 angry swarms forms one X swarm, 5 X swarms forms one Y swarm, and 5 Y swarms would form a Z swarm. And no matter how big the swarm, they do the same damage as a single angry swarm. This would mean that they were still dangerous, dangerous to fight, and most importantly of all, very very tedious to kill, which is pretty much how dealing with a huge swarm of bees would be. Fire, of course, would be very effective but attacking by hand or laser, no.

ghost commented 6 years ago

Also like to chip in, soap's in the biogen so you can clean it out reliably.

DeityLink commented 6 years ago

Ok let me clarify a few things: when I say a "bee swarm" I usually refer to a single "mob" that contains one ore more "bees". A bee swarm will lag the same no matter how many bees are in it. Furthermore, the larger a swarm is, the more likely are bees to split off from it into their own swarm, so if you release a single mob that contains 20 bees, they're going to split off naturally. My planned changes to the bug net only mean that those "split offs" will happen more progressively and result in less "mobs" being created right as you empty your net (which aims to reduce the immediate lag, but after a few seconds it should appear similar overall, especially since angry bees tend to quickly stack up together, which means that they'd stack anyway right after getting dropped from the net, which is far from optimized). Also on one hand I'm overjoyed that a swarm can be so efficient at wrecking xenos, but on the other I think it suits them well to be more of a "defensive-territorial" mob that sucks at chasing but great at denying an area. If I was to raise the limit on bees per swarm, that'd mean less bee mobs, and less "chasing after different targets" which would be sad.

I was thinking something like where the attacking swarms at max size as we know it seek out and chase people like they do, but have them, when there are X number on a tile, form into a larger swarm(Call this X swarm) which, when it attacks on its own, has the same damage as one angry swarm, but if attacked redisperses into the X number of swarms and attack in unison.

Well that's a bit counter-intuitive. You'd expect such a swarm to do more damage, not less. Anyway it all conflicts with a swarm's natural organic behaviour of randomy splitting/merging with nearby bees. I'd rather fix the issue by doing tweaks and QoL rather than adding entire new mechanics.

nuklearcellphoneg commented 6 years ago

My planned changes to the bug net only mean that those "split offs" will happen more progressively

I'd like to again clarify, I've never used the net because it's impossible to get them in without angering them, so if I'm doing it to clean them out of say the hallway, I just kill all the bees. If I'm doing it to move the bees... well I don't, I just try to get the mobs to follow me or I put them in a locker.

Furthermore, the larger a swarm is, the more likely are bees to split off from it into their own swarm

In the picture above, when you get to having as many bees like that, their... pathing or homing or target finding, not sure how to put it, really starts to break and they become useless outside of absorbing hits.

DeityLink commented 6 years ago

it's impossible to get them in without angering them, so if I'm doing it to clean them out of say the hallway, I just kill all the bees.

Wat, you know that you can use the extinguisher BEFORE angering them so you're guarranted to catch them right? Also swarms with very little bees (for instance, just one) are likely to get caught even without getting calmed first. I often see bees wandering outside of botany when I observe, while it would take a beekeeper a minute to pick up his net, an extinguisher, and round them up.

when you get to having as many bees like that, their... pathing or homing or target finding, not sure how to put it, really starts to break

I'll test if I can fix that by forbidding swarms from merging/splitting up if there are too many different swarms on their tile. Ideally I'd look at their vars to see what's going on through their minds.

Reviire commented 6 years ago

What if you capped their damage. They're bees, being instantly killed by a swarm of bees is just silly. No matter how large the swarm gets, billions of bees even.

DeityLink commented 6 years ago

A fix would be to replace their toxic damage by actually adding toxin to their target.

nuklearcellphoneg commented 6 years ago

Wat, you know that you can use the extinguisher BEFORE angering

Do you mean Calm>Calm again>Net? Netting them is not guaranteed from my experience and most of the time it takes several Calm>Net>Angered>Calm>Net>Angered before I can get them in. I think you might want to test this personally, though it may have something to do with how I raise bees.

Again, first two or three rounds I tried using the net, but it seemed useless to me.

Ideally I'd look at their vars to see what's going on through their minds.

Yeah, without me actually capturing video of them doing it, the best way I can describe it is like a train of bees that go somewhere, but the first bees to move can't move without the last bees getting to where the first got.

I don't know, I've never been stung by 100 bees at one time but according to the internet

If you're not allergic to bee stings, the average person can tolerate 10 stings per one pound of body weight. Most adults can tolerate more than 1,000 stings. 500 stings may be fatal for children.

nuklearcellphoneg commented 6 years ago

Also, and if I've overlooked this feature I'm sorry, stinging people doesn't seem to kill the bees which is kind of their hallmark.

In the above thing I mentioned

So 5 angry swarms forms one X swarm, 5 X swarms forms one Y swarm, and 5 Y swarms would form a Z swarm.

What if they was those bigger swarms had the added benefit of, when it was on top of someone, increasing their body temperature to damaging levels? So if you added in stinging killing bees, getting the swarm big enough to also stack this heat damage would also begin to kill off bees, so the population would regulate itself

I think queens converting homeless bees or however you put it would be a start, but you could always just leave the bees in their angry state to continue to replicate them.

DeityLink commented 6 years ago

from my experience and most of the time it takes several Calm>Net>Angered>Calm>Net>Angered before I can get them in.

Bees calm down on their next Life() update if they stand inside a spray. If the bees split after calmed (which may happen right afterwards often), the split bees COULD not be calmed. I'm adding that to the list of things to check for. (along with possibly making it easier for extinguishers to calm bees by having simply the spray move through them)

Most adults can tolerate more than 1,000 stings.

That's one case of Gameplay > Realism. Bees having some danger is part of their charm.

stinging people doesn't seem to kill the bees which is kind of their hallmark.

not necessarily

Although it is widely believed that a worker honey bee can sting only once, this is a partial misconception: although the stinger is in fact barbed so that it lodges in the victim's skin, tearing loose from the bee's abdomen and leading to its death in minutes, this only happens if the skin of the victim is sufficiently thick, such as a mammal's.[3] Honey bees are the only hymenoptera with a strongly barbed sting, though yellow jackets and some other wasps have small barbs. Bees with barbed stingers can often sting other insects without harming themselves. Queen honeybees and bees of many other species, including bumblebees and many solitary bees, have smoother stingers with smaller barbs, and can sting mammals repeatedly.[3]

once again G > R. Also at this point I consider that our bees are genetically enhanced spess bees. How would they produce this much honey so quickly, reproduce so quickly, and be visible from this far away otherwise. They're the size of an hand, which makes them hurting people much more believable.

Wild bees from infestation events might get replaced with actual wasps later.

nuklearcellphoneg commented 6 years ago

I mostly only suggest these because they would help to sort themselves out in terms of numbers. If they sting, but it has a chance to kill the bee, they work themselves out, and if reaching a greater number bumps up the temp, and that can also kill them, it also helps work them out.

If you can mostly maintain their current functionality simply with QoL that's great, but I'll let you know more about that once you merge something 'cause I'll see if I can't break them. :^)

nuklearcellphoneg commented 6 years ago

image

I went a bit farther today. When I went on the offensive, some things happened but basically.

1) No one could die, get healed, or recover from stuns

2) This went on for several minutes: When I got put in cryo for a second, all the damage came onto me all at one time(and every across the server started back up albeit slowly).

Probe1 commented 6 years ago

That would indicate the master controller crashed and was unable to restart. Or it was able to restart and promptly crashed again.

nuklearcellphoneg commented 6 years ago

Hello.

I maintain that there are some more things that need to be done to bees to mitigate their effect on the server itself, freezing the controller or whatever it is it does.

From what different folks have said, there's some behind the scenes clean up that could fix this, but as I also mentioned, making an ever larger bee swarm should be able to mitigate this. Another small fix could possibly bee that when the bees are searching for nectar, they do so in their entire bee swarm- for example, you have little sets of individual bees moving from plant to plant, then when you ax all those bees' home apiary, one swarm will come out when you begin axing, and actually opening it will release a new swarm, in addition to the bees that are moving in a chain from plant to plant.

pls fix bees without nerfing them I beg of you

Exxion commented 6 years ago

It probably lagged the mob controller, not the master controller. That said, on my machine at least, it required over one thousand zombies to get the mob controller's tick usage (or whatever the var is) over 100%, so I suspect there's some major inefficiency somewhere in beecode

EDIT: And you said it was several minutes per mob tick, and with close to six thousand zombies it didn't get that bad

nuklearcellphoneg commented 6 years ago

@Exxion Probably so, I've heard similar things from other coders about how 'this could fix' but I don't speak the jargon so I don't recollect. If you want, I'd gladly grow a bunch of bees on the test server if that would be helpful.

I'm not exactly sure what the deficiency is.

Describing it verbatim from memory though, atypically the bees in their regular state don't cause things to shut down. It takes... gosh, probably 25-35 apiaries to get to that point and I've only done it once, I can't remember how many apiaries I'd laid down but @Hoshi-chan saw it when I'd done the most bees I'd ever done one morning during low pop. In regular pollen-foraging mode, these caused blue space chugging while you were near them.

The true lag really doesn't start until you harvest the apiaries though. Harvesting, of course, fucked the entirety of the server for everyone(I had done that once before, on accident, but it wasn't nearly as many bees).

To describe exactly what happened, I started harvesting, and all the bees themselves are basically frozen. If someone gets stunned, it's permanent. You can be damaged well byond death, but you can't actually die. The bees will never die or move. I suspect that while the bees move into collective swarms, it might track each and every bee despite this. Swarms can and do split off on their own if they're not collectively targeting, I'd say on average I do about 9-12 apiaries, and I now do not harvest them all at once for fear of two things, one they are nearly impossible to net back up with that many bees and so it's almost impossible to make the area safe for people not properly equipped(at that point though, the bees lag severely and they're not much of a threat unless you're dumb, and two I'm of course worried about killing the server.

Exxion commented 6 years ago

Yes, doing it on the test server would be very helpful. I need some profiler info.

Exxion commented 6 years ago

Alright. Findings: The "normal" bee lag is due to a shit ton of reagent transfers, and lags the mob and machinery subsystems. The apocalyptic bee lag when you harvest all the apiaries seems to be due to some mob[s] (probably the bees) simply attempting to move approximately 1000 times per second, for some reason that I haven't figured out. It seems to completely freeze every single controller except the failsafe controller. The failsafe controller utterly fails to actually fix anything, though. I have no idea what the fuck is causing them to try to move so many times, but it's probably something BYOND-internal, since no procs have a higher total CPU than /mob/living/Move(), meaning whatever is calling that does not show up on the profiler.

EDIT: It appears to occur specifically when the bees have no target. They certainly lag when they do have a target, too, but they don't completely freeze everything.

EDIT: I think I've found it, but I'm not sure I'll do some testing later and open a PR if I'm right

nuklearcellphoneg commented 6 years ago

Well, some clarification I've noticed in observing the bees(aka not from a code standpoint).

When a target has left their sight angry bees disperse a bit instead of staying condensed and move a bit randomly in the meantime.

When it came to the final controller-killing crash, I have a theory. Normally when angry bees are aggro'd, they follow the most direct path to you. So if I have one huge swarm and step one tile ahead, they all go there. So they've executed their pathing. They are super slow as you noticed, presumably because so many are processing movement every second. When the bees are docile, it did lag, but all those processes were self contained, as in, there are plants here, we go from hive to plant back to hive rinse and repeat. As they had targeted me, and it depends largely on what I do and where I go, I hadn't moved all that much at first.

However, when you asked how to get them to attack you and I let them attack me(they only managed 5 stings before they stopped, but continued moving) I then moved southwest so they would attack you. So my theory is one of two, maybe three things.

  1. The pathing became so complex that the series of movements I took, instead of a one-tile over path, there were like 10,000 new orders to move to four new tiles.

  2. When I moved far enough away, they swapped to target you, and this massive swap froze everything.

  3. When I moved far enough away, the bees split priorities

One of those, or(more likely) a combination of those probably causes it.

Exxion commented 6 years ago

The exact time everything exploded was when they had no targets, and when they had a target again, the controllers magically unfroze I'm pretty sure the issue is that Deity apparently never heard of any of the step procs and instead called walk_to() for a target one tile away, and then something went nuclear and caused the bees to fail to actually walk, and since walk_to() has no delay by default, they all try to step constantly And they only become bored while they have no targets if they also have a home, which, if I'm not mistaken, is not the case for bees who exit the apiary due to it being harvested So this continues forever

DeityLink commented 6 years ago

that walk_to() and bee pathing in general was one of the only aspects of old bee-code that I didn't touch. Can't remember quite why.

Exxion commented 6 years ago

Ah. Sorry, that sounded like your kind of bug

Exxion commented 6 years ago

While bees certainly still cause lag, the server-eviscerating ur-lag seems to have been fixed by #18470