Playground

Define kinds of boids and their rules, then run the scene. The server starts one process for each boid of your definition.

Connecting

A scene

KeyValue
box[WIDTH, HEIGHT], each from 40 to 400
groundgrass, water, sand, floor, night or none
wraptrue: each side continues at the opposite side
rocksA list of [X, Y, RADIUS]. The rule avoid moves a boid around them.
kindsThe kinds of boids: 6 kinds at most. The server has a limit of the boids of a scene, and tells it.

A kind

KeyValue
nameThe group of its boids
countThe number of its boids
speed[MINIMUM, MAXIMUM]
perceptionThe distance that a boid sees (default 10)
rulesA list of [NAME, WEIGHT] or [NAME, WEIGHT, OPTIONS]
whenA list of {"sees": GROUP, "rules": RULES}: the rules of a boid while it sees a boid of that group
follows"chain": each boid has the relation follows to the boid before it. The target "leader" of a rule is that boid.
combine"priority": the first rules use the force first
shapeAn animal: bird, sheep, dog, wolf, fish, shark, deer, fox, bee, beetle, ant, duck, duckling, firefly, person or child; or leaf, spark, dart, dot, hex, rock
color, sizeink, warm, cool, rock, wool, fur, gold, leaf or plum; a number

The rules

RuleOptions
separation, alignment, cohesionradius, groups ("all", "same" or a list of names)
seek, flee, arrivetarget; radius for flee
pursue, evadetarget, radius, max_time
leadertarget, distance
wanderjitter, distance, radius
cruisespeed
avoidlookahead, clearance
dodgeradius, horizon
containmargin
followpath (a list of points), loop
flowfield (a vector [X, Y])

A target is a point [X, Y], the name of a group (the nearest boid of that group), or "leader".

A definition is data, and not code. For a boid with code of your own, write a module with the behavior gen_boid: see the game.