Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
buzz_examples [2016/09/02 13:34] – [Square Pattern Formation] ilpincy | buzz_examples [2018/03/18 22:58] – root | ||
---|---|---|---|
Line 77: | Line 77: | ||
var accum = neighbors.map(lj_vector).reduce(lj_sum, | var accum = neighbors.map(lj_vector).reduce(lj_sum, | ||
if(neighbors.count() > 0) | if(neighbors.count() > 0) | ||
- | math.vec2.scale(accum, | + | math.vec2.scale(accum, |
# Move according to vector | # Move according to vector | ||
goto(accum.x, | goto(accum.x, | ||
Line 98: | Line 98: | ||
==== Square Pattern Formation ==== | ==== Square Pattern Formation ==== | ||
- | To form square lattice, we can build upon the previous example. The insight is to notice that, in a square lattice, we can color the nodes forming the lattice with two shades, e.g., red and blue, and then mimic the [[http:// | + | To form square lattice, we can build upon the previous example. The insight is to notice that, in a square lattice, we can color the nodes forming the lattice with two shades, e.g., red and blue, and then mimic the [[http:// |
- | With this idea in mind, the following script | + | With this idea in mind, the following script |
- | <code buzz hexagon.bzz> | + | <code buzz square.bzz> |
# We need this for 2D vectors | # We need this for 2D vectors | ||
# Make sure you pass the correct include path to "bzzc -I < | # Make sure you pass the correct include path to "bzzc -I < | ||
Line 139: | Line 139: | ||
accum = neighbors.nonkin().map(lj_vector_nonkin).reduce(lj_sum, | accum = neighbors.nonkin().map(lj_vector_nonkin).reduce(lj_sum, | ||
if(neighbors.count() > 0) | if(neighbors.count() > 0) | ||
- | math.vec2.scale(accum, | + | math.vec2.scale(accum, |
# Move according to vector | # Move according to vector | ||
goto(accum.x, | goto(accum.x, | ||
Line 162: | Line 162: | ||
} | } | ||
</ | </ | ||
- | |||
- | ===== Wheeled-robot Specific ===== | ||
- | |||
- | TODO | ||
- | |||
- | ===== Flying-robot Specific ===== | ||
- | |||
- | TODO |