without clearing the previous frames
https://www.youtube.com/watch?v=hohnjFj_zqI
Boids
- NobodysSon
- Prole
- Posts: 33
- Joined: Tue Oct 30, 2012 10:37 pm
Re: Boids
This was posted some time ago but I wanted to say how cool I thought your program was! It is very soothing to watch - reminds me of schools of fish.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: Boids
I haven't taken the time to download the love file or check out the code, but what's so wrong with the first piece of code? Assuming that there isn't another handle to that table somewhere, it should just get garbage collected eventually, right? Are you just suggesting this for the sake of minimizing the work that has to be done come garbage day? :pivan wrote:Cool demo.
I have a couple of suggestions about the code:The line above creates a lot of intermediate tables, you can just use 2 variables or do:Code: Select all
closest = {x=boid.x,y=boid.y}
Code: Select all
closest.x, closest.y = boid.x, boid.y
Re: Boids
I believe the code was creating intermediate tables in a loop.
(I'm probably nitpicking, but then you have to access the table via "." which is slower than using locals)
In my experience, poor GC leads to occasional frame drops.
Yes, primarily because of the GC and it's just not a good use of intermediate tablesSir_Silver wrote:but what's so wrong with the first piece of code? Assuming that there isn't another handle to that table somewhere, it should just get garbage collected eventually, right? Are you just suggesting this for the sake of minimizing the work that has to be done come garbage day? :p
(I'm probably nitpicking, but then you have to access the table via "." which is slower than using locals)
In my experience, poor GC leads to occasional frame drops.
Re: Boids
Haven't been able to code properly for sometime, finally got access to my own laptop.
Here's a new one.
Here's a new one.
- Attachments
-
- boids.love
- (4.41 KiB) Downloaded 151 times
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Boids
Can this be used as a pathfinding alternative for grid based games?
Re: Boids
Well this technically isn't pathfinding: https://en.wikipedia.org/wiki/BoidsKayleMaster wrote: ↑Fri Dec 29, 2017 12:08 pm Can this be used as a pathfinding alternative for grid based games?
The grid here exists so only entities within a certain range will be iterated.
But you could get creative and use this combined with other algorithms.
Who is online
Users browsing this forum: Google [Bot] and 203 guests