Jump to content

Abusing Butterfly AI


Recommended Posts

So when playing around with the pathfinding of the AI, I saw that bees do really nice when running through mazes.

Then butterflies just flew right on over the wall without a care.

 

This disappointed me, and I delved into the AI a bit of the butterfly to see why they can fly over things when bees cannot.

 

I found that the butterfly will optionally ignore walls in its pathfinding if it finds the path too obscure and out of its way to escape from and just glides from A to B as if the walls don't exist.

The butterfly prefab doesn't even collide with walls, so the AI is just following the walls to make it look like it has to when it doesn't.

 

I checked the brain of the butterfly and it's pretty simple:

While it's haunted or on fire, panic.

If there's something with tag "scarytoprey" then run away from it.

If it's night or full of pollen from touching flowers then go to its spawn flower.

Otherwise find a flower to go to, and if no flower found then just wander around mindlessly.

 

Seems pretty innocent.

However, there's a combination of a bunch of small factors that allows one to create a butterfly trap.

1) Butterflies are scared of things.

2) Pigs/bunnymen are scary.

3) Butterflies obey wall pathfinding conditionally.

4) Walls and pigs/bunnymen are just the right size to force the pigs/bunnymen to be on an axis-aligned position.

5) Walls may be placed very closely to other objects while the objects cannot be placed close to walls.

6) Bunnymen sleep in the day and butterflies only spawn in the day.

7) Butterflies don't disappear by magic- they need to go home to their flower spawner.

 

So I give to you a very simple butterfly trap:

goLpT6a.png

_#__######_
#S#_F_____#
_#__######_

The gap is needed to force the butterflies to use its conditional pathfinding to follow the path towards the Scary entity if it's trying to wander.

But wait, there's a Scary entity in the way!

So the butterfly runs back away into the trap.

The Flower is close enough to the Scary entity that the butterfly cannot make it without being scared back.

So these four butterflies will not despawn unless every player moves ~77 units (19.25 turfs) away from them to make the entity sleep which triggers a despawn.

 

Easiest way to build this is to start with the Scary entity in the walls, then using a geometric placement mod put the Flower as close to the wall of the Scary entity as possible, and then build the other walls around the Flower.

 

 

But surely there could be more to do for quicker spawnings of butterflies?

No, butterflies spawn every 10-20 seconds if possible and only up to a maximum of 4 (Default settings, can get more/less depending on butterfly settings).

So this design does nothing beneficial in the speeding up of more butterflies but demonstrates that the butterflies can be caught on diagonals as well:

Spoiler

O8ATqyd.png

_________#_________
__##____#_#____##__
_#__#___#_#___#__#_
_#___#__#_#__#___#_
__#___#_#_#_#___#__
___#____#_#____#___
____#___#F#___#____
_______F___F_______
_######__#__######_
#_____F_#S#_F_____#
_######__#__######_
_______F___F_______
____#___#F#___#____
___#____#_#____#___
__#___#_#_#_#___#__
_#___#__#_#__#___#_
_#__#___#_#___#__#_
__##____#_#____##__
_________#_________

For these two designs pigmen can work for the Scary entity, since precision is not needed.

I will be stating more on the precision mechanic of this tomorrow, as well as abusing the butterflies' AI even more to generate infinite butterflies over time instead of the default 4 max.  (Relates to #6.)

Spoiler

 

@jamesl Please don't stop the magic that will be revealed tomorrow.  It's beautiful.

 

 

 

Infinite butterfly trap has been added.

 

So the infinite butterfly trap.

EnICbYv.png

This abuses the key #6 as a requirement.

Precision is a must since small deviations will cause the butterfly to fly out of the perfectly aligned trap, and you'll see why.

 

But first I want to state why there's a limit of 4 butterflies.

It all has to deal with the butterflyspawner component.

When a player joins it is polled every 10-20 seconds, randomly, for each additional butterfly.

This is also where checks happen to limit the number of butterflies in a given radius.

 

The first check is done is by checking for any butterfly within 64 units (16 turfs) away, which is very huge.

If there are already max butterflies then no more will have a chance to spawn.

Otherwise, it will check for flowers that are at least 6 units (1.5 turfs) and no more than 25 units (6.25 turfs) away and then spawn a butterfly on a randomly chosen flower.

 

64 units is the exact same radius as the entity pop-in radius for clients in Don't Starve Together.

The entity pop-in radius is when entities are networked to a client, and is smaller than the entity pop-out radius ~77 units (19.25 turfs) where entities leave the client and go into sleep/limbo mode.

This is also another crucial key part to making this work solo, but would work fine with two players if need be.

 

 

So the goal is to make butterflies move in a set pattern 64 units away from the player without the player in the way of the path of the butterflies.

This was my final design after going through different designs.

My other designs tried not using a wall in the middle since the walls around the bunnies were messing with the pathfinding and causing them to fly off.

However, having a solid wall line like this causes the pathfinding to enter its special case of ignoring walls, making this the ideal one.

tGnSLsG.png

(more bunny chain segments)

luE1qcp.png

Spoiler

_#__#_____#________#________#________#________#________#________#________#__#######_
#B#_F#####B########B########B########B########B########B########B########B#________#
_#__#_____#________#________#________#________#________#________#________#__#######_
_________________
_________________
_________________
_______#####_____
______#_____#____
______#______#___
______#______#___
______#______#___
______#______#___
_______#_____#___
_______#_____#___
_______#______#__
_______#______#__
_______#______#__
_______#______#__
________#_____#__
________#______#_
________#______#_
________#______#_
_________#______#
_________#_____#_
_________#____#__
__________#_##___
___________#_____

Any spot in the 'wing' is valid to stand in to generate more butterflies and not cause despawns.

 

Bunnies are required since they sleep in the day and thus have their location exactly where the flower line is at, making no deviations occur.

If we were to use pigs, then the small deviations from pigs when they walk into walls is just enough to cause butterfly leaks when going from node to node making them undesirable.

 

The top wall of the wing is parallel with the bunny chain wall since butterfly scare radius is 5 units, so this keeps the player from going in the radius and potentially being the scare target.

 

Showing radii used:

Spoiler

zXdqL9q.png

 

Downsides:

 

Someone _must_ be within the butterfly radius and keep them active/not in limbo or they will despawn.

64 units (16 turfs) is a fairly huge radius to play in, so someone will become the dedicated butterfly watcher/base builder if you want them to stick around permanently.

It doesn't matter who, but so long as someone is within the radius then the butterflies stick around.

 

No meat!

Meat wakes the bunnies up, so stay away meat-lovers.

 

Takes up a large portion of space.

Needs 9 bunnies.

99 walls for the trap, 45 for the wing if you want easy guidance.

Link to comment
Share on other sites

At least you won't have to worry about werepigs tearing the walls down.  Could be useful if yo want to mass-produce gossamer saddles.

I wonder what the best way to kill all those butterflies would be.  Abigail would be good, but only if she doesn't scare them away.  Fill the trap with broken-down hay walls and burn them?

Link to comment
Share on other sites

1 hour ago, TemporaryMan said:

At least you won't have to worry about werepigs tearing the walls down.  Could be useful if yo want to mass-produce gossamer saddles.

I wonder what the best way to kill all those butterflies would be.  Abigail would be good, but only if she doesn't scare them away.  Fill the trap with broken-down hay walls and burn them?

burning them means butterfly wings will become ash, I believe.

Link to comment
Share on other sites

1 hour ago, AnonymousKoala said:

burning them means butterfly wings will become ash, I believe.

that is only if the mob itself is set on fire it doesnt count if the mob dies to nearby fire damage which is why you sometimes see butterfly wings and morsels after a forest fire

 

Link to comment
Share on other sites

gW0kkPZ.png

They know now.

Hopefully the infinite mechanic won't be nerfed/changed too drastically, since the setup required for it could be compared to making a megabase filled with berries and other food based goodies in terms of time and resources.

Also Winter making them unable to spawn more, and the great size needing more flings than normal bases to keep the bunnymen from burning.

Link to comment
Share on other sites

Just tested fire.  It doesn't work, but not for any reason suggested.  No, they just panic, which as you'll recall from the original post overrides all other behaviour... and they fly over the walls and escape.  Well, some of them escape.  I still got some butterfly wings.

Attacking them with a weapon requires ctrl + f... which would hit the walls.  So I hope you have a lot of silk, because it looks like nets are the way to go here.  Or you can just point & click with a mouse.  It's kind of fussy and won't work for folks who use controllers, but it works.

Looks like we still have a bit of work to do to take this thing from a proof-of-concept to a practical tool.

Link to comment
Share on other sites

@TemporaryMan The design principles don't seem to preclude the idea of bulging the walls out a little. Instead of just doing a corridor, keep the entrance the same and then open into a larger chamber. Standing in the middle, ctrl+f should always target a butterfly, as should controllers.

Edit: Yup, this works very nicely.

20160608002545_1.jpg

Link to comment
Share on other sites

4 minutes ago, rezecib said:

@TemporaryMan The design principles don't seem to preclude the idea of bulging the walls out a little. Instead of just doing a corridor, keep the entrance the same and then open into a larger chamber. Standing in the middle, ctrl+f should always target a butterfly, as should controllers.

Yeah, I went with minimalist as possible.

So long as the nearest path from to the butterfly exit is the same it shouldn't matter the chamber size.

Chamber shown is as tight as possible and still maintain them.

Link to comment
Share on other sites

Well, sure enough, I expanded it to a diamond-shaped room and it worked fine.  For a whie.

The bad news: Krampus likes to kill bunnymen.  So my instinctive wish for a passive, no naughtiness method for killing the butterflies was justified.  Too bad fire doesn't work.  (I tried with a flingo, it doesn't respond fast enough to freeze them all.  And star caller's staff won't roast them.)

The good news: you can build an alchemy engine or shadow manipulator just outside where the wing will be built and still use it from across the walls.  Oh, and you can in fact carry meat and even cook it on crock pots as long as you stay in the middle or lower portion of the wing.  They'll only wake up if you stand in the top three rows.

I'd post screenshots but photobucket's down for maintenance.

Link to comment
Share on other sites

17 hours ago, ImDaMisterL said:

If you don't get a member title related to butterflies, I swear...

I'd like to believe those are reserved for peoples' mistakes rather than accomplishments.

13 hours ago, TemporaryMan said:

The good news: you can build an alchemy engine or shadow manipulator just outside where the wing will be built and still use it from across the walls.  Oh, and you can in fact carry meat and even cook it on crock pots as long as you stay in the middle or lower portion of the wing.  They'll only wake up if you stand in the top three rows.

I'd post screenshots but photobucket's down for maintenance.

The wing isn't needed to be created, but it's there for guidance to keep the user in the know of where they may stand and have the infinite trap function without a hitch.

Having the outer wall is nice so you know where you may not pass, and the inner is there to keep more butterflies spawning.

You may as well only use the outer since keeping the mass is more important than adding more to it.

Also imgur is a pretty good hoster, though they will make the image into a jpeg despite the png file extension at the end.

14 hours ago, TemporaryMan said:

Attacking them with a weapon requires ctrl + f... which would hit the walls.

Could also make a client-sided mod to not do this:

Spoiler



AddClassPostConstruct("components/combat_replica",
    function(self)
        local IsAlly_old = self.IsAlly
        self.IsAlly = function(self, guy)
            if(self.inst:HasTag("player"))
            then
                if(guy:HasTag("wall"))
                then
                    return true
                end
            end
            local returnValue = false
            if(IsAlly_old~=nil)
            then
                returnValue = IsAlly_old(self, guy)
            end
            return returnValue
        end
    end
)


 

 

Link to comment
Share on other sites

  • Developer
4 hours ago, CarlZalph said:

I'd like to believe those are reserved for peoples' mistakes rather than accomplishments.

But then there wouldn't be puzzle member titles given to the guys cracking Klei's puzzles :p

Sorry for beinf off-topic, I'll stop now.

Link to comment
Share on other sites

By day 14 using just the simple trap got 73 wings in storage after eating a lot since I didn't get bushes.

This might be a tad bit too good.

 

Tried making the infinite trap and boy the resources required for it, it's a challenge getting the rabbits and walls needed before Winter hits to make it even worth it.

But for the following seasons it destroys the need of a food supply.

1 hour ago, The Letter W said:

this is the most over the top thing i have ever read and i am greatly amused 

thank you for sharing your ways O Butterfly Whisperer 

Spoiler

the_monarch_by_supajoe.jpg

Src

8 minutes ago, ImDaMisterL said:

But then there wouldn't be puzzle member titles given to the guys cracking Klei's puzzles :p

Sorry for beinf off-topic, I'll stop now.

Yeah true, thoufh I'd still like to believe it beinf true.

Link to comment
Share on other sites

This is really helpful, I might just make one of these on my server, seeing how none of my friends seems to know how awesome it is to kill buttflies (Tons of health, Butter and krampus)

Also, fear the Mighty Minotaur

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...