Made an algorithm for a simple flock simulation on my pandora


Bosbeetle

Terminally lost
Joined
Sep 7, 2008
Messages
4,275
Age
42
Location
The Netherlands
Website
Visit site
Ive made a simple flocking algorithm on my pandora, very much childsplay since I cannot code. But I thought it would be nice to share it. Here are two youtube clips, the final algorithm was not run on the pandora but on a desktop, 800 dots was a bit much to emulate on the pandora (like I said I cannot code)...


I thought it would be nice to dedicate the rest of this thread to other nice simulations on the youtubes...

like the following


Or of course share your own simulations
 
Your second video reminds me of a massive school of fish, just not quite as tight with the swarming or whatever you call it, and the dots seem slow for fish. Really cool, I like it.
 
Your second video reminds me of a massive school of fish, just not quite as tight with the swarming or whatever you call it, and the dots seem slow for fish. Really cool, I like it.

I made one with twenty birds of prey


Actually the one with no birds of prey seem quite like an actual flock of birds... I wanted to apply this to a 3d flock but I have to apply euler axis theory for that and I have other stuff to do.
 
my favorite is the one where they start throwing boxes at the big guy.

also, gonna have to try that new skip-like gait at the end of that video.

what are you programming your flocks in?
 
my favorite is the one where they start throwing boxes at the big guy.

also, gonna have to try that new skip-like gait at the end of that video.

what are you programming your flocks in?
IKR... Watching I was giggling a little "He's skipping! Look at him go!" :D
 
my favorite is the one where they start throwing boxes at the big guy.

also, gonna have to try that new skip-like gait at the end of that video.

what are you programming your flocks in?

This was done in the imagej macro language works really well on the pandora :) (I also made a realtime java version but that became slow with more than 300 birds)
 
I made one with twenty birds of prey
That one is really fun to watch. See how some of the groups stay tight? If they would all stay together and close like that you could have another one for fish. I enjoy watching video of huge schools of fish evade and confuse predators, in case you are wondering why I keep bringing them up.
 
Simulations are fun, i could watch them the whole day.

Here is a something i made a few years ago, pretty shitty tho:
PHP:
#!/usr/bin/python

sizex=640
sizey=400
from threading import Thread
from threading import activeCount
from time import sleep
import random
import pygtk
pygtk.require('2.0')
import gtk
import gobject
gobject.threads_init()
#tocall
def init():
main()
gtk.main()
#createwindow+box
def main():
global window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event",close_application)
window.show()
# map, mask = gtk.gdk.pixmap_create_from_xpm_d(window.window,None,Pic.wow)
global image
image = gtk.Image()
# image.set_from_pixmap(map, mask)
# image.show
window.add(image)
image.show()

#actual picture viewer
def inputdummy(data):
   gobject.idle_add(input, data )
def input(data):
  map, mask = gtk.gdk.pixmap_create_from_xpm_d(window.window,None,data)
  image.set_from_pixmap(map, mask)
  image.show
 
#close
 
def close_application(widget, event, data=None):
        gtk.main_quit()
        return False

#starte gui
class gui(Thread):
def __init__(bla):
  Thread.__init__(bla)
def run(bla):
  init()
gui().start()
class w:
teiler=40
futter=1
tod=-1

def generate():
global bild
global bildz
bildz=[]
bild=[
  str(sizex) + " " + str(sizey) + " 13 1",
"0    c #b8b730",
"1    c #e9e817",
"2    c #c8e917",
"3    c #ade917",
"4    c #72E917",
"5    c #4fe917",
"6    c #25e917",
"7    c #1de917",
"8    c #16e910",
"9    c #07ff00",
"k    c #000000",
"u    c #6F6F6F",
"h    c #FFFFFF",]
x=sizey/4
y=sizex/4
while x > 0:
  line= ""
  while y > 0:
   line += str(9)
   y -= 1
  bildz.append(line)
  y=sizex/4
  x -=1
global grass
grass=[]
for i in bildz:
  line=[]
  for ii in i:
   line.append(int(ii))
  grass.append(line)
global kuh
kuh=[[random.randrange(0,sizex/4),random.randrange(0,sizex/4),14],]
inputdummy(bild+bildz)

def days():
bildn = list(list(i) for i in grass)
###getier
global kuh
muh=[]
for k in kuh:
  nuh=[]
  k[random.choice([0,1])] += random.choice([-1,1])
  nuh.append(k[0])
  nuh.append(k[1])
  k[2] -= w.futter
  if nuh[0] in [sizex/4,sizex/4+1,sizex/-4,sizex/-4-1] :
   nuh[0] = 0
  if nuh[1] in [sizey/4,sizey/4+1,sizey/-4,sizey/-4-1] :
   nuh[1] = 0
  k[2] +=grass[nuh[1]][nuh[0]]
  grass[nuh[1]][nuh[0]] = 0
  if k[2] > w.teiler:
   nuh.append(k[2]/2)
   muh.append(nuh)
  else:
   nuh.append(k[2])
  grass[nuh[1]][nuh[0]] = 0
  if nuh[2] > 10:   
   bildn[nuh[1]][nuh[0]]="k"
   muh.append(nuh)
  elif nuh[2] > w.tod:
   bildn[nuh[1]][nuh[0]]="u"
   muh.append(nuh)
  else:
   bildn[nuh[1]][nuh[0]]="h"
   
#  print kuh
kuh=muh
###into string
bildz=[]
for i in bildn:
  line=""
  for ii in i:
    line += 4 * (str(ii))
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
 
inputdummy(bild+bildz)
def day():
bildn = []
global grass   
for i in grass:
  line=[]
  for ii in i:
   if ii <9:
    line.append(ii+1)
   else:
    line.append(ii)
  bildn.append(line)
grass = list(list(i) for i in bildn)
###getier
global kuh
muh=[]
for k in kuh:
  nuh=[]
  k[random.choice([0,1])] += random.choice([-1,1])
  nuh.append(k[0])
  nuh.append(k[1])
  k[2] -= w.futter
  if nuh[0] in  [sizex/4,sizex/4+1,sizex/-4,sizex/-4-1] :
   nuh[0] = 0
  if nuh[1] in  [sizey/4,sizey/4+1,sizey/-4,sizey/-4-1] :
   nuh[1] = 0
  k[2] +=grass[nuh[1]][nuh[0]]
  grass[nuh[1]][nuh[0]] = 0
  if k[2] > w.teiler:
   nuh.append(k[2]/2)
   muh.append(nuh)
  else:
   nuh.append(k[2])
  grass[nuh[1]][nuh[0]] = 0
  if nuh[2] > 10:   
   bildn[nuh[1]][nuh[0]]="k"
   muh.append(nuh)
  elif nuh[2] > w.tod:
   bildn[nuh[1]][nuh[0]]="u"
   muh.append(nuh)
  else:
   bildn[nuh[1]][nuh[0]]="h"
   
#  print kuh
kuh=muh
print len(kuh)
###into string
bildz=[]
for i in bildn:
  line=""
  for ii in i:
    line += 4 * (str(ii))
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
 
inputdummy(bild+bildz)
generate()
while activeCount() == 2 :
  sleep(0.09)
  day()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
 

Attachments

  • panvers.py.tar
    6.5 KB · Views: 112
Simulations are fun, i could watch them the whole day.

Here is a something i made a few years ago, pretty shitty tho:
PHP:
#!/usr/bin/python

sizex=640
sizey=400
from threading import Thread
from threading import activeCount
from time import sleep
import random
import pygtk
pygtk.require('2.0')
import gtk
import gobject
gobject.threads_init()
#tocall
def init():
main()
gtk.main()
#createwindow+box
def main():
global window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event",close_application)
window.show()
# map, mask = gtk.gdk.pixmap_create_from_xpm_d(window.window,None,Pic.wow)
global image
image = gtk.Image()
# image.set_from_pixmap(map, mask)
# image.show
window.add(image)
image.show()

#actual picture viewer
def inputdummy(data):
   gobject.idle_add(input, data )
def input(data):
  map, mask = gtk.gdk.pixmap_create_from_xpm_d(window.window,None,data)
  image.set_from_pixmap(map, mask)
  image.show

#close

def close_application(widget, event, data=None):
        gtk.main_quit()
        return False

#starte gui
class gui(Thread):
def __init__(bla):
  Thread.__init__(bla)
def run(bla):
  init()
gui().start()
class w:
teiler=40
futter=1
tod=-1

def generate():
global bild
global bildz
bildz=[]
bild=[
  str(sizex) + " " + str(sizey) + " 13 1",
"0    c #b8b730",
"1    c #e9e817",
"2    c #c8e917",
"3    c #ade917",
"4    c #72E917",
"5    c #4fe917",
"6    c #25e917",
"7    c #1de917",
"8    c #16e910",
"9    c #07ff00",
"k    c #000000",
"u    c #6F6F6F",
"h    c #FFFFFF",]
x=sizey/4
y=sizex/4
while x > 0:
  line= ""
  while y > 0:
   line += str(9)
   y -= 1
  bildz.append(line)
  y=sizex/4
  x -=1
global grass
grass=[]
for i in bildz:
  line=[]
  for ii in i:
   line.append(int(ii))
  grass.append(line)
global kuh
kuh=[[random.randrange(0,sizex/4),random.randrange(0,sizex/4),14],]
inputdummy(bild+bildz)

def days():
bildn = list(list(i) for i in grass)
###getier
global kuh
muh=[]
for k in kuh:
  nuh=[]
  k[random.choice([0,1])] += random.choice([-1,1])
  nuh.append(k[0])
  nuh.append(k[1])
  k[2] -= w.futter
  if nuh[0] in [sizex/4,sizex/4+1,sizex/-4,sizex/-4-1] :
   nuh[0] = 0
  if nuh[1] in [sizey/4,sizey/4+1,sizey/-4,sizey/-4-1] :
   nuh[1] = 0
  k[2] +=grass[nuh[1]][nuh[0]]
  grass[nuh[1]][nuh[0]] = 0
  if k[2] > w.teiler:
   nuh.append(k[2]/2)
   muh.append(nuh)
  else:
   nuh.append(k[2])
  grass[nuh[1]][nuh[0]] = 0
  if nuh[2] > 10:  
   bildn[nuh[1]][nuh[0]]="k"
   muh.append(nuh)
  elif nuh[2] > w.tod:
   bildn[nuh[1]][nuh[0]]="u"
   muh.append(nuh)
  else:
   bildn[nuh[1]][nuh[0]]="h"
  
#  print kuh
kuh=muh
###into string
bildz=[]
for i in bildn:
  line=""
  for ii in i:
    line += 4 * (str(ii))
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)

inputdummy(bild+bildz)
def day():
bildn = []
global grass  
for i in grass:
  line=[]
  for ii in i:
   if ii <9:
    line.append(ii+1)
   else:
    line.append(ii)
  bildn.append(line)
grass = list(list(i) for i in bildn)
###getier
global kuh
muh=[]
for k in kuh:
  nuh=[]
  k[random.choice([0,1])] += random.choice([-1,1])
  nuh.append(k[0])
  nuh.append(k[1])
  k[2] -= w.futter
  if nuh[0] in  [sizex/4,sizex/4+1,sizex/-4,sizex/-4-1] :
   nuh[0] = 0
  if nuh[1] in  [sizey/4,sizey/4+1,sizey/-4,sizey/-4-1] :
   nuh[1] = 0
  k[2] +=grass[nuh[1]][nuh[0]]
  grass[nuh[1]][nuh[0]] = 0
  if k[2] > w.teiler:
   nuh.append(k[2]/2)
   muh.append(nuh)
  else:
   nuh.append(k[2])
  grass[nuh[1]][nuh[0]] = 0
  if nuh[2] > 10:  
   bildn[nuh[1]][nuh[0]]="k"
   muh.append(nuh)
  elif nuh[2] > w.tod:
   bildn[nuh[1]][nuh[0]]="u"
   muh.append(nuh)
  else:
   bildn[nuh[1]][nuh[0]]="h"
  
#  print kuh
kuh=muh
print len(kuh)
###into string
bildz=[]
for i in bildn:
  line=""
  for ii in i:
    line += 4 * (str(ii))
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)
  bildz.append(line)

inputdummy(bild+bildz)
generate()
while activeCount() == 2 :
  sleep(0.09)
  day()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)
  days()
  sleep(0.09)


Ah what is it, will look at it later.
 
Back
Top