<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Sprühfarbe war ein schlechter Versuch, sich zu flocken.Ich glaube, der Teil, der mir gefehlt hat, war die Ausrichtung http://gamedevelopment.tutsplus.com/tutorials/the-drei-simple-rules-of-flocking-behaviors-alignment-cohesion-and-separa… hat mich dorthin gelenkt.Hier ist ein neues Video.
ChanceOfDragons – YouTube

Und hier ist die JSL zum Erstellen der Bitmaps (nochmals keine Entschuldigung ... Sie müssen die Nachbarschafts- und Nnear-Berechnung aus der Iterate-Funktion entfernen, wenn Sie mit den Schiebereglern spielen möchten.Dies ist die letzte JSL, die mehrere Stunden lang lief, um alle Bitmaps zu erstellen, und nicht die frühe JSL, als ich versuchte, einige Parameterwerte zu finden, die interessante Ergebnisse liefern würden.)
// Ideen entlehnt von
// http://gamedevelopment.tutsplus.com/tutorials/the- three-simple-rules-of-flocking-behaviors-alignment-cohesion-and-separation--gamedev-3444
Nachbarschaft = 2; // Radius der nahegelegenen Nachbarschaft
nnear=20; // Anzahl der in der Nachbarschaft zu findenden Nachbarn
a=.04;b=0.08;c=0.2;
w=.8;//1-w ist zur Mitte ziehen
speed=8;//kleiner ist schneller
x = 1;
y = 2;
dx = 3;
dy = 4;
Farbe=5;
nvar = 5;
nflock = 1700;
flock = J( nflock, nvar, . );
// Anfangspositionen von 10 bis 90 und Anfangsgeschwindigkeiten unter 1 festlegen
Parallele Zuweisung(
{x = x, y = y, dx = dx, dy = dy, nflock = nflock,color=color},
flock[i, v] = If( v < dx,
100*(i+100)/(nflock+200),//Zufällige Ganzzahl( 10, 90 ),
if(v
)
);
Rahmen = 0;
iterieren = Funktion( {},
{temp = flock, iflock, irow, kdt = KDTable( flock[0, 1 :: 2] ), dxsum, dysum, xsum, ysum, myx, myy, xdif, ydif, neighbour, nneighbors, len},
nnear = 10*(1,1+sin(frame/2000)); // ein bis zwanzig nächste Nachbarn
Nachbarschaft = 1*(1+cos(frame/3000)); // null bis zwei Nachbarschaft
{rows, dist} = kdt << KNearestRows( {nnear, neighborhood} );
Rahmen++;
For( iflock = 1, iflock <= nflock, iflock++,
myx = temp[iflock, x];
myy = temp[iflock, y];
dxsum = 0;
dysum = 0; // Summe der Nachbargeschwindigkeiten
xsumme = 0;
ysum = 0; // Summe der Nachbarpositionen
xdif = 0;
ydif = 0; // Summe der Nachbarabstände
Nachbarn = 0;
For( irow = 1, irow <= nnear & (neighbor = rows[iflock, irow]) != 0, irow++,
Nachbarn++;
dxsum += temp[neighbor, dx];
dysum += temp[neighbor, dy];
if(1,
xsum += temp[neighbor, x];
ysum += temp[neighbor, y];
if(1,
xdif += (myx - temp[neighbor, x]); // Vektor weg vom Nachbarn
ydif += (myy - temp[neighbor, y]);
))
);
len = Sqrt( dxsum * dxsum + dysum * dysum );
If( len != 0,
dxsum /= len; // dadurch wird die Geschwindigkeit 1, in Richtung der Gruppe
dysum /= len;
,
dxsum = 0;
dysum = 0;
);
Wenn( Nachbarn,
xc = 50+40*sin((choose(1+mod(iflock,3),3,5,7)*frame)/2207);
yc = 50+40*cos((choose(1+mod(iflock,3),11,13,17)*frame)/3067);
xsum = ((1-w)*xc+(w*(xsum) / (nneighbors))) - myx; // Dieser Vektor gibt die Richtung zum Gruppenzentrum vor
ysum = ((1-w)*yc+(w*(ysum) / (nneighbors))) - myy;
len = Sqrt( xsum * xsum + ysum * ysum );
if(len!=0,xsum/=len;ysum/=len,xsum=0;ysum=0);// normalisiert auf 1
len = Sqrt( xdif * xdif + ydif * ydif );
if(len!=0,xdif/=len;ydif/=len,xdif=0;ydif=0); // normalisiert auf 1
,
xsumme = 0;
ysum = 0;
xdif = 0;
ydif = 0;
);
flock[iflock, dx] += a*dxsum + b*xsum + c*xdif;
if( abs(flock[iflock, dx])>1, flock[iflock, dx]*=.9);
Herde[iflock, x] += Herde[iflock, dx]/Geschwindigkeit;
if((flock[iflock, x] < -5 & flock[iflock, dx] < 0)|(flock[iflock, x] >105 & flock[iflock, dx] > 0), flock[iflock, dx] = - flock[iflock, dx]);
flock[iflock, dy] += a*dysum + b*ysum + c*ydif;
if( abs(flock[iflock, dy])>1, flock[iflock, dy]*=.9);
flock[iflock, y] += flock[iflock, dy]/speed;
if((flock[iflock, y] < -5 & flock[iflock, dy] < 0)|(flock[iflock, y] >105 & flock[iflock, dy] > 0), flock[iflock, dy] = - flock[iflock, dy]);
flock[iflock,color]=heatcolor((nneighbors)/(nnear),"spectral");//heatcolor((nneighbors-1)/(nnear+10),"jet");//3+nneighbors;/ /hlscolor(.4-.6*(nneighbors)/(nnear),.5,1);//
);
);
iterieren();
Neues Fenster( „Flock“,
V-Listenfeld(
gb = Diagrammbox(
Unterdrückungsäxte,
Rahmengröße( 1922, 1082 ),
<
Stiftgröße (3);
For( i = 1, i <= nflock, i++,
Stiftfarbe( flock[i, color] );
Line( {flock[i, x] - flock[i, dx], flock[i, y] - flock[i, dy]}, {flock[i, x], flock[i, y]} );
);
),
H-Listenfeld(
Textfeld( „Ausrichtung“),
Schieberegler (0, .16, a),
Textfeld( „Kohäsion“),
Schieberegler (0, .2, b),
Textfeld( „Trennung“),
Schieberegler (0, .4, c),
Textfeld( „Nachbarschaft“),
Slider Box( 0, 30, Nachbarschaft),
,
Textfeld( „NNear“),
Slider Box( 1, 30, nnear ),
Textfeld( „Geschwindigkeit“),
Slider-Box (.5, 30, Geschwindigkeit)
)
)
);
While( Frame<=27000,
gb << ungültig;
gb << updatewindow;
Warten( 0 );
temp=gb[framebox(1)]<
pixel=temp<
Pixel=Pixel[3::1082,3::1922];
temp<
temp<
iterieren();
);