Boids/Java: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
(3 intermediate revisions by one other user not shown)
Line 1:
This code supports flocking behavior, but not collision avoidance.
 
Loosely based on natureofcode.com's Chapter 6. Autonomous Agents' sample code.
{{works with|Java|8}}
[[File:boids_java.png|300px|thumb|right]]
<langsyntaxhighlight lang="java">import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.geom.*;
Line 350 ⟶ 353:
return acos(v.dot(v2) / (v.mag() * v2.mag()));
}
}</langsyntaxhighlight>
9,476

edits