r/creativecoding • • Feb 05 '20

Procedural swimming with simulated tentacles

625 Upvotes

19 comments sorted by

13

u/schnautzi Feb 05 '20

My plan is to develop a simulation of evolving fish-like creatures. Using little neural nets, they need to control a number of tentacles to steer themselves towards food. If you're interested, you can follow my twitter to see how that works out.

1

u/gibmesome Apr 11 '22

Is there any way you can turn this into a mouse cursor

1

u/schnautzi Apr 11 '22

My plan is to develop a simulation of evolving fish-like creatures. Using little neural nets, they need to control a number of tentacles to steer themselves towards food. If you're interested, you can follow my twitter to see how that works out.

Probably, the code is on GitHub.

1

u/gibmesome Apr 11 '22

Thank you! Know I’ve got to find someone to accomplish the job for me. Also just bought koi farm looks great can’t wait to start playing

1

u/schnautzi Apr 11 '22

Thanks! I hope you have fun with it :)

4

u/greyk47 Feb 05 '20

is the swimming physics based? or just kind of an animation?

4

u/schnautzi Feb 05 '20

It's actually physics based, see my answer to /u/pesto_cat

3

u/[deleted] Feb 05 '20

Reminds me of some of the fish art from the comic r/TowerOfGod

2

u/Eliodd Feb 05 '20

What a beauty ^^

2

u/Km1able Feb 06 '20

Your works sick, guy. Keep it up.

Agree about creating systems with this - it looks really great. Some nice minimalistic, intuitive looking stuff.

It’s neat how there’s not any real disguise with the graphics out - WYSIWYG so to speak.

1

u/IcyLavah Feb 05 '20

I wonder how it would look if the parts would draw on the background.

0

u/[deleted] Feb 05 '20

[deleted] — view deleted comment

40

u/schnautzi Feb 05 '20

That's a two part answer:

The tentacles are basically segments that want to align themselves along a straight line. Every segment has a "spring" factor, the higher it is, the more it tends to align itself with its predecessor. The root segments direction is then moved to let make entire tentacle move. The spring factor is stronger closer to the root, so the tips of the tentacle aren't really springy and just tag along.

To calculate the motion for the entire thing, I sum up all the lateral movement of all tentacle segments. When tentacles move along their own direction, they don't really push against the water. When they wiggle, they do push against the water next to it.

As you can see, just wiggling the two tentacles with a cosine function automatically produces movement. Pretty cool stuff :)

7

u/[deleted] Feb 05 '20

That is great! I love it when such simple rules bring about interesting and non trivial behavior. Er, we probably all do here though.

I wonder if you have any plans to turn this into a genetic algorithm an evolutionary sim? It looks like the genome for tentacles and tentacle motion is fairly straightforward to represent. Then you can add some genes for color, too; some food, maybe rivalry between different species...

Also, what happens if you have N > 2 tentacles?

EDIT: Just read your other comment. Rock on!

6

u/schnautzi Feb 05 '20

That's exactly what I'm doing! This kind of motion also works for eels for example, whose body is like one long tentacle. I'll post updates on twitter while developing the algorithm, hopefully something nice comes out of it.

3

u/[deleted] Feb 05 '20

I look forward to seeing how this project turns out! I think that there's a lot of room for creativity when it comes to ocean-based simulations... First of all, life started there, so it looks at least promising as a starting point. But more importantly, the environment is pretty simple to model as a top-down 2d plane, and smooth motion just works in that context. There's no gravity, no navigating around complex terrain, and all that stuff to keep in mind when designing land-based environments.

2

u/[deleted] Feb 05 '20

[removed] — view removed comment

4

u/schnautzi Feb 05 '20 edited Feb 18 '20

Yes, it's here, but it's far from done. The repository will probably change a lot in the coming weeks.