\ Food addition, mixing and consumption and bacteria connectivity determination \. During the food-mixing phase, food is introduced at the boundary, and diffuses through the system. At the same time, we compute which bacteria are connected through an unbroken chain of other bacteria to the substrate. Connected bacteria may eat food. At the end of the mixing phase, we delete unconnected bacteria (they "blow away") and we display the system. .\ \* Before diffusing the food, we fill all empty spaces with food at the feed density. We will run this rule twice, once with food+ allowed to change, and again (after a shift) with food- allowed to change. *\ : food-fill-rule bacteria 0= boundary 0= and if feed -> food+ feed -> food- then update ; create-lut food-fill-lut ?rule>table food-fill-rule food-fill-lut \* The first time this rule is run in a sequence of food-mixing steps, we expect the conn+ and conn- bits to be set to zero. *\ : food-rule \ communicate connectivity to additional bacteria conn 0<> bacteria 0<> and if 1 -> connected then update \ set conn+ and conn- to reflect connectivity so far connected 0<> boundary substrate = or -> conn+ connected 0<> boundary substrate = or -> conn- update \ only connected bacteria eat food connected 0<> eat 0<> and if 0 -> food+ then update \ don't mix inside of boundary mix 0<> boundary 0= and if food+ <-> food- then update \ add food at food source (+ dir is always okay for flat source) boundary food-source = if feed -> food+ then update \ at the top, food must be going down (eventually) boundary food-source = food- 0<> and if 0 -> food- 1 -> food+ then update \ at the bottom, food must be going up (eventually) boundary substrate = food+ 0<> and if food- <-> food+ then update ; create-lut food-lut ?rule>table food-rule food-lut : detach-rule connected 0= if 0 -> bacteria then update bacteria 0<> -> visibility update ; create-lut detach-lut ?rule>table detach-rule detach-lut define-step food-fill-step lut-data food-fill-lut switch-luts lut-src site site-src lut food- field site kick feed field random x random y random z run site-src lut food+ field site kick feed field random x random y random z run end-step : food-kick (s axis dir -- ) is dir is axis kick conn+ field 1 axis xn conn- field -1 axis xn food+ field dir axis xn food- field -dir axis xn eat field random x random y random z mix field random x random y random z feed field random x random y random z ; define-step food-init-step lut-data food-lut switch-luts site-src site conn field 0 fix kick run site-src lut lut-src site end-step \* For horizontal steps, we alternate kicking diffusing + and - particles right/left, and left/right. This is done to avoid a bias, since particles that penetrate the boundary become - particles, so that on the next vertical step they will come out. We want these - particles to have an equal chance to going right or left within the boundary. *\ define-step food-step food-diffuse-period 0 do 0 1 food-kick run 1 1 food-kick run 2 1 food-kick run 0 -1 food-kick run 1 1 food-kick run 2 -1 food-kick run loop end-step define-step detach-step lut-data detach-lut switch-luts lut-src site site-src lut kick run end-step