I Coded an ANT COLONY in Python… You Won’t Believe How They Behave!

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ธ.ค. 2024

ความคิดเห็น • 101

  • @okolenmi7511
    @okolenmi7511 หลายเดือนก่อน +37

    You can make ants more realistic. They should go back home and stay there some time when they have low energy. Also add more types of pheromones, enemies or fights with other colonies.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +6

      Thank you for your feedback! I'm actually planning on developing it further and try to use AI

    • @kas_tv-fg1xk
      @kas_tv-fg1xk หลายเดือนก่อน +1

      regarding realism, I can say that in many similar implementations, ants do not know the way to the anthill, just as they do not know the way to food and remember it through pheromones, this allows ants to move not quite in a straight line to the anthill, but also to avoid potential obstacles

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I'm gonna try to do that in the next video, implement more types of pheromones and add obstacles on the plane.

    • @nedames3328
      @nedames3328 หลายเดือนก่อน

      Warfare is the primary mechanism for ant population control. Add warfare.

  • @LangSphere
    @LangSphere หลายเดือนก่อน +7

    0:02 ant colonies when humans aren't looking:

  • @Resursator
    @Resursator หลายเดือนก่อน +11

    I like how the first bug you met was a pheromone loop of death. It's kinda realistic.

  • @oli111222
    @oli111222 หลายเดือนก่อน +3

    I love your way of presenting, and also that you show not just the success, but also the strugle you had with all the different problems and steps! Thats what programming is mostly about. Also very clean code, readable, necessities documented and well organized. Good work! Like every feedback, there is a "but"... The computation time and the fps... I'd highly recommend, especially when it comes down to visualising, using different python libraries which are already solving for that, such as numba, taichi, etc... There are a lot of different libraries out there optimized for not just matrix, but also tensor optimizations. If you wanna know more, I once made a good "speedcomparison" of all libraries and different implementations, demonstrated on the mandelbrot set (not released yet). Let me know, and I will share the sourcecode with you. Long story short: Keep up the good work :)
    mandelbrot demo: th-cam.com/video/XV2CVJAfVJk/w-d-xo.html

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thank you for the tips! Your visualization looks amazing, I'll make sure to try out the libraries you mentioned!

  • @74Gee
    @74Gee หลายเดือนก่อน +10

    There's another fairly easy metric to implement. That's food levels in the any nest - ant pheromones change from building to scavenging when the food gets low. Also builders could allow more ants to live in the colony.
    Hope you open source this, I'd love to have a play, I love ants, they're truly fascinating.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +2

      Thanks for the idea!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +3

      I created a repository if you'd still like to play with it :) Link is in the description.

    • @74Gee
      @74Gee หลายเดือนก่อน +1

      @@CodeCr4fter Thanks!! Stared and forked :)

    • @Bee-eautiful
      @Bee-eautiful หลายเดือนก่อน +1

      ants truly are fascinating indeed

    • @Bee-eautiful
      @Bee-eautiful หลายเดือนก่อน +1

      @@CodeCr4fterthanks a lot, i'll be sure to check this out later when i have time, this was awesome!

  • @8bit_pineapple
    @8bit_pineapple หลายเดือนก่อน +1

    I hate it when my ant simulation is full of bugs.

  • @eventHorizonROstock
    @eventHorizonROstock หลายเดือนก่อน

    I love the project. It is very fundamental intelligence research / engagement with its concepts.
    The only nitpick I have with the video was the jump in volumes. Your voice was very quiet and then the bass hit :D
    But anyway, keep up the good work!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks! Sorry about the bass

  • @minatimanil
    @minatimanil หลายเดือนก่อน +1

    This is cool man. Keep it up, I enjoyed the video. Honestly shocked you aren't a bigger channel.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I'm glad you liked it!

    • @Bee-eautiful
      @Bee-eautiful หลายเดือนก่อน

      how does such quality content has only 172 subscribers?
      let me fix that, i'll bring in both of my alts

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thank you so much bro!

  • @michaeldeloatch7461
    @michaeldeloatch7461 หลายเดือนก่อน

    Fascinating but I think you had an ant colony living in your microphone...

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Sorry about that, the sound quality will be better in the next video

  • @Bee-eautiful
    @Bee-eautiful หลายเดือนก่อน

    that was a great video, ants are great, and so is coding
    i'm currently learning python actually, and i already know a bit, so i'll look into this to learn more about how to make great things like it

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I'm glad you liked it!

  • @unknown1689-e9e
    @unknown1689-e9e หลายเดือนก่อน +3

    Nice work bro!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thanks a lot!

  • @mushrafaltaf
    @mushrafaltaf หลายเดือนก่อน

    I enjoyed this! Keep it up!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you!

  • @charlesloeffler333
    @charlesloeffler333 หลายเดือนก่อน

    Recommend making the cells larger relative to the ant detection radius. Say 9 squares covering the circle

  • @rechtfrage6003
    @rechtfrage6003 หลายเดือนก่อน

    Already spent hours providing enough food to the ants using my mouse-buttons and mouse-wheels, a pleassure to watch ;-)
    Interesting that in your first iterations the ants seem to leave a (blue) trail, appearing as lines - where in the later iterations (and when using your code on Guthub) they leave blue dots, have you noticed it as well?

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      That's because in the first version ants leave pheromones every single frame, so they appear as a blue line because they blend together. Later I reduced it to every 7 (I believe) steps.

  • @yosef_ii
    @yosef_ii หลายเดือนก่อน +2

    Amazing work!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I'm glad you liked it ❤️

  • @amosky5105
    @amosky5105 หลายเดือนก่อน +1

    Nice work and editing !

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks a lot!

  • @anon_y_mousse
    @anon_y_mousse หลายเดือนก่อน

    Neat. I never gave it much thought before, but can Python do a multiway tree? If so, I'd add a time component and sort by that along one tree. Add the lifespan to the starting timestamp to get the ending timestamp and sort by that, removing from both trees at the end of a particle's lifespan.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thanks for your feedback! There are implementations of multiway trees in python libraries, somebody has even suggested trying it out instead of the grid. I'll look into that!

  • @rumble_bird
    @rumble_bird หลายเดือนก่อน

    You can rewrite ant logic to compute shader, which can potentially increase the performance to handle millions of them, also, i don't know whether kd tree or octtree can increase performance in comparison to grid, but it worth trying. In regard to ant simulation, maybe adding rival ants or other creatures can create interesting patterns.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks for the feedback! I'll make sure to look into the things you mentioned

  • @dfunited1
    @dfunited1 หลายเดือนก่อน +1

    Thank you so much for a well made and thought provoking video. I've mostly been thinking about the fewest numbers of phermones and fewest number of "rules" over the ants' behavior. One question, how do ants know where the nest is? I'm not sure they have individual awareness, other than "that direction smells like exploration, that direction smells like food, that direction smells like combat".
    Just food for thought. Again, thanks.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thanks for the comment! I've read they actually do have spatial awareness and can use landmarks for navigation, some even build them (some desert species). They also use a thing called 'path integration' which basically means that they remember turns and count steps to get back to the anthill.

  • @kas_tv-fg1xk
    @kas_tv-fg1xk หลายเดือนก่อน

    I've done similar experiments, and I've also tried to do it in python.tell me, have you done any optimizations, or is it just a fairly long rendering?

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      The things that I tried are mentioned in the video, I haven't done anything else yet. Rendering certainly slows the simulation down, it should be done on a separate thread

    • @kas_tv-fg1xk
      @kas_tv-fg1xk หลายเดือนก่อน

      @@CodeCr4fter Yes, like you, I had optimization problems related to the number of pheromones being tested.I've been experimenting with this for a long time, but I can say that dividing space is really a great idea that I saw when I was working on another project.Dividing space into equal parts is a good idea when the objects being checked are the same size, but within the same project I ran into the problem that some objects were larger than others, so much so that if you leave the space as finely divided, then collisions with the object could not be properly processed, and if you increase the area of the cells, it turned out that the optimization suffered much worse

  • @maximeduchalet4662
    @maximeduchalet4662 หลายเดือนก่อน

    very nice, maybe try multiple types of pheromones? i dunno you did something pretty cool

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks for the idea! I'll see what i can do

  • @marcelbricman
    @marcelbricman หลายเดือนก่อน

    it needs terrain and obstacles!
    ants could also drop food
    and of course there will need to be epic battles against other colonies ;)

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thanks for the feedback!

  • @peligros13
    @peligros13 หลายเดือนก่อน

    Biggest issue I see with this is not using numpy operations for arrays. Your code is full of for loops that are 100s or 1000s of times slower than vectorized code. I know using classes and objects looks cool but it hurts performance by a lot.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks for the feedback! I'll try to improve next time

  • @fte6
    @fte6 หลายเดือนก่อน

    Good work!

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you, I appreciate it!

  • @johnnypgames
    @johnnypgames หลายเดือนก่อน +1

    open source? seems fun to play with

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I created a repository if you'd still like to play with it :) Link is in the description.

  • @cybermanne
    @cybermanne หลายเดือนก่อน

    Nice project!
    If you want any kind of feedback (or constructive criticism) on the video itself I think you should try to modulate your narrating a bit more. As in put some emphasis on some words here and there instead of just sounding so flat. I expect you're reading from a script, and that's the reason your voice never changes much.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thank you! I will make sure to pay attention to modulation next time.

    • @cybermanne
      @cybermanne หลายเดือนก่อน

      @@CodeCr4fter It's just one of those things that could potentially make the videos more appealling to people in general. It's one of those things that gets mentioned alot for public speaking. If your voice sounds the same all the time people tend to have difficulties keeping engaged. I don't think it's that much of a problem for an audience that is already very interested in the subject though.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      @@cybermanne You're absolutely right. Even if the audience is engaged on its own, improving my speaking skills certainly won't hurt.

  • @thomasveal7697
    @thomasveal7697 หลายเดือนก่อน

    underrated chanel

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you!

  • @Kaviranghari
    @Kaviranghari หลายเดือนก่อน

    7:40 i can bro
    I can and i do
    Its like a ton is lifted off your forehead and chest and you can breathe normally and your brain chills out

  • @requestfx5585
    @requestfx5585 หลายเดือนก่อน +1

    Choosing the right algorithms and optimizations is always important but I wouldnt use python. If you want to go for speed and in this case simulating hundreds or thousand of ants you probably should go with zig. The only way python could be remotely close is by using numpy I think it was which uses C code behind making it fast.
    Using zig with sfml for rendering would be a good way and probably a huge improvement, could be also interesting of comparing the speed to python but watch out for the rendering since that can make a difference aswell. I would write the logic code separate from the rendering code so running the simulation without any rendering can be a good way of measuring the performance.
    Alternatively using c++ will give you similar performance but in my opinion it's easier than zig but memory safety is not enforced 👉👈

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you for the feedback! You're absolutely right, python is not made for this kind of task. Separating rendering from logic is a very good idea as well, I'll try to implement that. I've never heard of zig but I'll look into that. Thanks again!

    • @requestfx5585
      @requestfx5585 หลายเดือนก่อน

      @CodeCr4fter yeah no problem, zig is a relatively new language that "replaces" the c language, which is does pretty good and gains a lot of popularity. It implements safety features like rust and decent memory safety (no garbage collector).
      Its already a usable language which basically has all features implemented that are needed (v 0.13.0), it's usage is not that complicated but the hard part is that the documentation is weak and very not beginner friendly.
      Features that are awesome is you can use any c library in zig, c++ as well I heard? But I didn't test that yet, you can cross compile easily to a different system / architecture arm, x32, even compile to webassembly if you like, has testing support directly built into it which I never heard of in any other language.

  • @Kaviranghari
    @Kaviranghari หลายเดือนก่อน +1

    I literally thought i was watching some successful channel
    For 10 minutes
    Then i saw the view count and then the sub count and i was blown away

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thanks bro, it means a lot!

  • @playing_dark2553
    @playing_dark2553 หลายเดือนก่อน

    heyy, i am student and stuck on basic can you help how do i improve

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Hi! Best advice I can give you is don't stop creating. Create and design things you're interested in and solve problems one by one looking for solutions online. Now that we have LLMs it's easier than ever, but if you're using them avoid mindlessly copying code and try to understand why it works. Don't hesitate to ask for clarifications if you're not sure. Good luck!

  • @ohimdabiggestbird
    @ohimdabiggestbird หลายเดือนก่อน

    u already know that u gotta throw some ai magic into that, u better

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      I'll try to do that in the next video for sure!

  • @GamePlay-pl2nv
    @GamePlay-pl2nv หลายเดือนก่อน

    great video but please focus on the code part more

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      I'm glad you liked it! Do you mean that I should explain the code in more detail?

    • @GamePlay-pl2nv
      @GamePlay-pl2nv หลายเดือนก่อน

      @@CodeCr4fter yes, this video was a lot better than other videos on your channel,create something new and tell us how you did it step by step, tanks

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      I'm happy to hear that because it took quite some time to create it :) Thank you for your feedback!

    • @GamePlay-pl2nv
      @GamePlay-pl2nv หลายเดือนก่อน

      @@CodeCr4fter you could try to apply them to 2d or even 3d characters

  • @SetTheCurve
    @SetTheCurve หลายเดือนก่อน

    My intuition tells me that your method of optimization isn’t ideal. Optimizing slow code is a bandaid. Switching to a method that isn’t slow, and optimizing that, is a superior path to performance. The code that was partitioned is still slow code.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks for the feedback! You're right, I'll try to fix that in the next video

  • @fantasticalthoughts
    @fantasticalthoughts หลายเดือนก่อน

    good vid

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you!

  • @HoSza1
    @HoSza1 หลายเดือนก่อน

    You wrote it in Turtle. 😂

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      That's a good one 😂

  • @dennisdecoene
    @dennisdecoene หลายเดือนก่อน

    Wtf is going on with the speech audio.

  • @NoenD_io
    @NoenD_io หลายเดือนก่อน

    Can you make a tutorial

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Hi! Maybe someday, but probably not in the near future. If you need the code, link to my github repository is in the description :)

  • @NopeNopeNope9124
    @NopeNopeNope9124 หลายเดือนก่อน

    Believed everything

  • @RS_Chrono610
    @RS_Chrono610 หลายเดือนก่อน

    can we get the code great work btw

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      Thank you! I'll consider creating a repository

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน +1

      I created a repository if you'd still like to play with it :) Link is in the description.

    • @RS_Chrono610
      @RS_Chrono610 หลายเดือนก่อน

      thanks world needs more like you

  • @okolenmi7511
    @okolenmi7511 หลายเดือนก่อน +1

    You need a better mic. It's the only bad thing in the video.

    • @axospyeyes281
      @axospyeyes281 หลายเดือนก่อน +3

      eh, it's fine

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thanks! I know, I was trying to improve it during editing but I could only do so much

  • @peskarr
    @peskarr หลายเดือนก่อน

    Cool stuff, great story, but cheap MIDI music really hurts sometimes.

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      Thank you! I didn't really spend a long time picking music but if it's that bad I'll definitely try to put more effort into that in the next video

    • @Omena0
      @Omena0 หลายเดือนก่อน

      ​@@CodeCr4fterI don't think its bad at all

    • @sirynka
      @sirynka หลายเดือนก่อน

      It's just extremely loud compared to your narration

    • @CodeCr4fter
      @CodeCr4fter  หลายเดือนก่อน

      @@sirynka You mean the parts when I'm not talking right?

    • @sirynka
      @sirynka หลายเดือนก่อน

      @@CodeCr4fter yeah