{
   "author" : "henklass",
   "name" : "The Beasties",
   "ancestor_list" : [],
   "description" : "A life simulator. Beasties are running across the screen, eating, finding a mate and eventually dying. Every event has its own sound.",
   "labels" : [
      "science",
      "life simulator"
   ],
   "code" : "/*\r\nThe Beasties\r\n\r\nDedicated to the lovely Clarien van Harten\r\n\r\nA beastie is an array of values: age, sex, energy, horizontal en vertical position (+ possibly other experimental properties). \r\nAll beasties are in a List. Add with list.add(beastie), remove with list.removeAt(index). Edit with list.put(index, beastie).\r\n\r\nFood is in a 2D-aray. \r\n\r\n==========================================================================\r\nMake two beasties, a boy and a girl. They have an amount of energy and search for food, until their energy surpasses a certain amount. Then they look for a playmate. At a certain age they come of age. If a grownup man plays with a grownup woman, a new beastie comes to life. Both parent give the same amount of energy. If one of the parents hasn't enough energy, the other compensates, if possible. In that way, death of a child is prevented as much as possible.\r\n\r\n===========================================================================\r\nThe cycle:\r\n1. is there food where you stand?? If yes, take e byte! Energy increases.\r\n2. Age is increased by 1.\r\n3. Determine ypur direction\r\n\tAre you hungry? Find food.\r\n\tNot hungry? Find someone to play with\r\n4. take the step. Energy decreases by 1.\r\n5. as 1.\r\n6. Is there another beastie where you stand now? Meeting.\r\n7. Is there a meeting between a grownup man and a grownup woman? \r\n\tIf yes, birth.\r\n============================================================================\r\nBirth\r\n1. New beastie in the list\r\n\tage=0\r\n\tsex=random\r\n\tposition:shoot away\r\n\tenergy: if possible standard initial energy.\r\n2. energy of parents decreases.\r\n3. When shooting away: parents jump aside, child is shot away.\r\n============================================================================\r\nDeath\r\nIf energy == 0 and at the position where you are, there is no food.\r\nRemove from list.\r\n============================================================================\r\n\r\n*/\r\n\r\ns.boot;\r\n(\r\n//Synthdefs for sounds\r\n//strewing food\r\nSynthDef (\\strewSound, {\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tBBandPass.ar (\r\n\t\t\t\tWhiteNoise.ar(0.25)\t,\t\t//input\r\n\t\t\t\t2000,\t\t\t\t\t\t//center frequency\r\n\t\t\t\t1,\t\t\t\t\t\t\t//bandwith in octaves\r\n\t\t\t\tEnvGen.kr(Env.perc(1, 2, 1, -4), doneAction: 2),\t\t\t\t\t\t\t\t\t\t//mul\r\n\t\t\t\t0,\t\t\t\t\t\t\t//add\r\n\t\t\t),\r\n\t\t\tLFNoise1.ar(0.125, 2, -1)\r\n\t\t)\r\n\r\n\t)\r\n}).add;\r\n\r\n\r\n//birth\r\nSynthDef(\\birth, { arg posX, posY;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tSinOsc.ar(Line.kr(500, 1000, 0.25, doneAction: 2), 0, 0.25),\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t0.5\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t//pos\r\n\t\t),\r\n\t)\r\n}).add;\r\n\r\n//death\r\nSynthDef(\\death, { arg posX, posY;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tSinOsc.ar(100+(SinOsc.ar(Line.kr(70, 64, 1, doneAction: 2), 0, 1000, 0)),\r\n\t\t\t\t\t\tmul: EnvGen.kr(Env.perc(0.01, 1, 0.5, -4), doneAction: 2)\t\t\t\t),\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t0.5\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t//pos\r\n\t\t)\r\n\t)\r\n}).add;\r\n\r\n\r\n//death of a child\r\nSynthDef(\\childDeath, { arg posX, posY;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tSinOsc.ar(1600+(SinOsc.ar(Line.kr(1200, 1000, 1, doneAction: 2), 0, 1000, 0)),\r\n\t\t\t\t\t\tmul: EnvGen.kr(Env.perc(0.01, 1, 0.5, -4), doneAction: 2)\t\t\t\t),\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t0.5\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t//pos\r\n\t\t)\r\n\t)\r\n}).add;\r\n\r\n//byte\r\nSynthDef(\\hap, {arg freq, posX, posY;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tRLPF.ar(\r\n\t\t\t\t\tSaw.ar(freq, EnvGen.kr(Env.perc(0.03, 0.01, 0.25, 4), levelScale: 0.5, doneAction: 2)),\r\n\t\t\t\t\t3*freq*EnvGen.kr(Env.asr(0.001, 1, 0.0001, 4), doneAction: 2), //cutoff=3*toonhoogte\r\n\t\t\t\t\t0.05\r\n\t\t\t\t\t\r\n\t\t\t\t),\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t0.5\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t//pos\r\n\t\t)\r\n\t)\r\n}).add;\r\n\r\n\r\n//coming of age\r\nSynthDef(\\coa, { arg posX, posY, num;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tBlip.ar(1000, num, EnvGen.kr(Env.perc(0.01, 1, 1, -4), doneAction: 2)),\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t0.5\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t//pos\r\n\t\t)\r\n\t)\r\n}).add;\r\n//meetings\r\nSynthDef(\\meeting, {arg freq1, freq2, posX, posY;\r\n\tOut.ar(0,\r\n\t\tPan2.ar(\r\n\t\t\tFreeVerb.ar(\r\n\t\t\t\tPulse.ar(freq1, 0.5, EnvGen.kr(Env.perc(0.01, 0.1, 1, 4), levelScale: 0.25)) + \r\n\t\t\t\tPulse.ar(freq2, 0.5, EnvGen.kr(Env.perc(0.2, 0.01, 1, 4), levelScale: 0.25, \t\t\t\t\tdoneAction: 2)),\t\r\n\t\t\t\tposY,\t\t//mix\r\n\t\t\t\t1\t\t\t//room\r\n\t\t\t),\r\n\t\t\tposX\t\t\t\t//pos\r\n\t\t)\r\n\t)\r\n}).add;\r\n\r\n)\r\n(\r\n//variabels\r\nvar maxX=100, maxY=100, aoc=15,\r\n//names of synths\r\nstrewsynth, birthsynth, deathsynth, childdeathsynth, bytesynth, coasynth, meetingsynth,\r\n//names of functions and routines\r\nstrew, findFood, findPartner, eat, determinePartner, doIt,\r\n//named indices \r\nage=0, sex=1, xPos=2, yPos=3, energy=4, dying=5, cngoa=6;\r\n\r\n~beasties = List.new(2);\r\n~thisBeastie=Array.new(7);\r\n~thatBeastie=Array.new(7);\r\n~newBeastie=Array.new(7);\r\n~food=Array2D.new(maxX, maxY);\r\nt=0.03; //default time to wait\r\n\r\n\r\n//fill ~food with zeroes\r\n{for(0, maxX-1, {arg h;\r\n\tfor(0, maxY-1, {arg v;\r\n\t\t~food[h,v]=0\r\n\t});\r\n});\r\n}.value;\r\n\r\n//show window\r\nz=7;\r\nw=Window(\"beasties\", Rect(400, 150, z*maxX, z*maxY));\r\nw.view.background_(Color.white);\r\nw.front;\r\n\r\n\r\n//strewing food, 10 bytes per cycle\r\nstrew={\r\n\tvar x, y;\r\n for(1, 10, {\r\n\t x=maxX.rand;\r\n\t y=maxY.rand;\r\n\t ~food[x,y]=~food[x,y]+1;\r\n\t });\r\n\t strewsynth=Synth(\"strewSound\");\r\n\t};\r\n\r\n\r\n//draw\r\nw.drawFunc={\r\n\t//draw ~food \r\n\tfor(0, maxX-1, {arg v;\r\n\t\tfor(0, maxY-1, {arg h;\r\n\t\t\tPen.color=Color.new(1-(~food[h,v]/10), 1,1-(~food[h,v]/10)); //more food on one place -> darker green\r\n\t\t\tPen.addRect(Rect(h*z, v*z, z, z));\r\n\t\t\tPen.fill;\r\n\t\t})\r\n\t});\r\n\t\t\r\n\t//draw ~beasties \r\n\tfor(0, ~beasties.size-1, {arg i;\r\n\t\te=~beasties[i];\r\n\t\tif(e[dying]==true,{\r\n\t\t\tPen.color=Color.black;\r\n\t\t\tPen.addRect(Rect(((e[xPos]-0.5)*z), ((e[yPos]-0.5)*z), 2*z, 2*z));\t\t\tPen.fill;\r\n\t\t});\r\n\t\tif (e[cngoa]==true,{\r\n\t\t\tPen.color=Color.yellow;\r\n\t\t\tPen.addRect(Rect(((e[xPos]-0.5)*z), ((e[yPos]-0.5)*z), 2*z, 2*z));\t\t\tPen.fill;\r\n\t\t});\r\n\r\n\t\tif (e[sex]==0, {\r\n\t\t\tif (e[age]<aoc, {\r\n\t\t\t\tr=1;\r\n\t\t\t\tg=0.45 - (e[age] * 0.45/aoc);\r\n\t\t\t\tb=0.9 - (e[age] * 0.9/aoc);\r\n\t\t\t},{\r\n\t\t\t\tr=1;\r\n\t\t\t\tg=1-pow(0.995, e[age]-aoc);\t//beasties get grey when they age\r\n\t\t\t\tb=1-pow(0.995, e[age]-aoc);\r\n\t\t\t})\r\n\t\t},{\r\n\t\t\tif (e[age]<aoc, {\r\n\t\t\t\tr=0;\r\n\t\t\t\tg=0.9 - (e[age] * 0.9/aoc);\r\n\t\t\t\tb=1;\r\n\t\t\t},{\r\n\t\t\t\tr=1-pow(0.995, e[age]-aoc);\r\n\t\t\t\tg=1-pow(0.995, e[age]-aoc);\r\n\t\t\t\tb=1;\r\n\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\t\t);\r\n\t\tif (e[energy]<100, {\t\t//beasties get darker when hungry\r\n\t\t\tr=e[energy]/100*r;\r\n\t\t\tg=e[energy]/100*g;\r\n\t\t\tb=e[energy]/100*b;\r\n\t\t});\r\n\t\tPen.color=Color(r, g, b);\r\n\t\tPen.addRect(Rect((e[xPos]*z), (e[yPos]*z), z, z));\t\tPen.fill;\t\t\r\n\t});\r\n\t\r\n};\r\n\r\nfindFood={\r\n\tvar minX, minY, distance;\r\n\tminX=maxX;\t//x-coördinate of food-particle, closest to the beastie\r\n\tminY=maxY;\t//y-coördinate of food-particle, closest to the beastie\r\n\tdistance=max(maxX, maxY);\r\n\tfor(0, maxY-1, {arg v;\r\n\t\tfor(0, maxX-1, {arg h;\r\n\t\t\tif (~food[h,v]>0, {\r\n\t\t\t\td=max((h-~thisBeastie[xPos]).abs, (v-~thisBeastie[yPos]).abs);\r\n\t\t\t\tif(d<distance, {\r\n\t\t\t\t\tminX=h;\r\n\t\t\t\t\tminY=v;\r\n\t\t\t\t\tdistance=d;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t});\r\n\tif(minX<~thisBeastie[xPos], {~thisBeastie[xPos]=~thisBeastie[xPos]-1});\r\n\tif(minX>~thisBeastie[xPos], {~thisBeastie[xPos]=~thisBeastie[xPos]+1});\r\n\tif(minY<~thisBeastie[yPos], {~thisBeastie[yPos]=~thisBeastie[yPos]-1});\r\n\tif(minY>~thisBeastie[yPos], {~thisBeastie[yPos]=~thisBeastie[yPos]+1});\r\n};\r\n\r\neat={if (~food[~thisBeastie[xPos], ~thisBeastie[yPos]]>0, {\r\n\tf=240-(210*~thisBeastie[sex])+((1760+(210*~thisBeastie[sex]))*pow(0.99, ~thisBeastie[age]));\r\n\t//\"Men\" and \"women\" have different voices. Voices get lower with age\r\n\tbytesynth=Synth(\"hap\", [freq: f, posX: -1+ (2*~thisBeastie[xPos]/maxX), posY: ~thisBeastie[yPos]/maxY]);\r\n\t~food[~thisBeastie[xPos], ~thisBeastie[yPos]]= ~food[~thisBeastie[xPos], ~thisBeastie[yPos]]-1;\t~thisBeastie[energy]=~thisBeastie[energy]+10; //1 byte = 10 steps\r\n\t\t\t});\r\n};\r\n\r\n\r\nfindPartner={\r\n\tvar minX, minY, distance;\r\n\tminX=maxX;\t//x-coördinate of partner, closest to the beastie\r\n\tminY=maxY;\t//y-coördinate of partner, closest to the beastie\r\n\tdistance=max(maxX, maxY);\r\n\tfor(0, ~beasties.size-1, {arg k;\r\n\t\tif (k!= ~thisIndex,{\r\n\t\t\td=max((~beasties[k][xPos]-~thisBeastie[xPos]).abs, (~beasties[k][yPos]-~thisBeastie[yPos]).abs);\r\n\t\t\tif(d<distance, {\r\n\t\t\t\tminX=~beasties[k][xPos];\r\n\t\t\t\tminY=~beasties[k][yPos];\r\n\t\t\t\tdistance=d;\r\n\t\t\t});\r\n\t\t});\r\n\t});\r\n\tif(minX<~thisBeastie[xPos], {~thisBeastie[xPos]=~thisBeastie[xPos]-1});\r\n\tif(minX>~thisBeastie[xPos], {~thisBeastie[xPos]=~thisBeastie[xPos]+1});\r\n\tif(minY<~thisBeastie[yPos], {~thisBeastie[yPos]=~thisBeastie[yPos]-1});\r\n\tif(minY>~thisBeastie[yPos], {~thisBeastie[yPos]=~thisBeastie[yPos]+1});\r\n};\r\n\r\ndeterminePartner={arg l;\r\n\t~partnerFound=false;\r\n\tfor(0, ~beasties.size-1, {arg j;\r\n\t\tif(((l!=j)&&(~beasties[j][xPos]==~thisBeastie[xPos])&&\r\n\t\t\t(~beasties[j][yPos]==~thisBeastie[yPos])), {\r\n\t\t\t\t~thatBeastie=~beasties[j];\r\n\t\t\t\t~thatIndex=j;\r\n\t\t\t\t~partnerFound=true}\r\n\t\t\t);\r\n\t});\r\n};\r\n\r\ndoIt=Routine({\r\n\tvar f1, f2;\r\n\t~beasties.add([0, 1, maxX.rand, maxY.rand, 100, false, false]);\r\n\t~beasties.add([0, 0, maxX.rand, maxY.rand, 100, false, false]);\r\n\tstrew.value;\r\n\t////~beasties.postln;\r\n\t{w.refresh}.defer;\r\n\t\r\n\t{\r\n\t\ti=0;\r\n\t\twhile ({i<= (~beasties.size-1)}, {\r\n\t\t\t~thisIndex=i;\r\n\t\t\t~thisBeastie=~beasties[i];\r\n\t\t\t~thisBeastie[age]=~thisBeastie[age]+1;\r\n\t\t\tif(~thisBeastie[age]==aoc, {\r\n\t\t\t\tif (~thisBeastie[energy]<100, {\r\n\t\t\t\t\tn=~thisBeastie[energy]\r\n\t\t\t\t},{\r\n\t\t\t\t\tn=100\r\n\t\t\t\t});\r\n\t\t\t\tcoasynth=Synth(\"coa\", [\\posX, -1+ (2*~thisBeastie[xPos]/maxX), \\posY, ~thisBeastie[yPos]/maxY, \\num, n]);\r\n\t\t\t\t~thisBeastie[cngoa]=true;\r\n\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t0.5.wait;\r\n\t\t\t\t~thisBeastie[cngoa]=false;\t\r\n\t\t\t});\r\n\t\t\t~thisBeastie[energy]=~thisBeastie[energy]-1;\r\n\t\t\teat.value;\r\n\t\t\tif ((~thisBeastie[energy]<=0), {\r\n\t\t\t\tif(~thisBeastie[age] < aoc, {\r\n\t\t\t\t\tchilddeathsynth=Synth(\"childDeath\", [posX: -1+ (2*~thisBeastie[xPos]/maxX), posY: ~thisBeastie[yPos]/maxY]);\r\n\t\t\t\t\t},{\t\r\n\t\t\t\t\tdeathsynth=Synth(\"death\", [posX: -1+ (2*~thisBeastie[xPos]/maxX), posY: ~thisBeastie[yPos]/maxY]);\r\n\t\t\t\t});\r\n\t\t\t\t~thisBeastie[dying]=true;\r\n\t\t\t\t~beasties.put(~thisIndex, ~thisBeastie);\r\n\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t1.wait;\r\n\t\t\t\t~beasties.removeAt(i);\r\n\t\t\t\t{w.refresh}.defer;\t\t\t\t\t\t\t~beasties.size.postln;\r\n\t\t\t\t},{\r\n\t\t\t\tif (~thisBeastie[energy]<500, //hungry?\r\n\t\t\t\t\t{findFood}.value,\r\n\t\t\t\t\t{findPartner}.value\r\n\t\t\t\t);\r\n\t\t\tdeterminePartner.value(i);\r\n\t\t\t//meeting\r\n\t\t\tif (~partnerFound, {\r\n\t\t\t\t//play meeting\r\n\t\t\t\tvar p1, p2;\r\n\t\t\t\tf1=240-(210*~thisBeastie[sex])+((1760+(210*~thisBeastie[sex]))*pow(0.99, ~thisBeastie[age]));\r\n\t\t\t\tf2=240-(210*~thatBeastie[sex])+((1760+(210*~thatBeastie[sex]))*pow(0.99, ~thatBeastie[age]));\r\n\t\t\t\tp1 = -1+(~thisBeastie[xPos]/maxX*2);\r\n\t\t\t\tp2=~thisBeastie[yPos]/maxY;\r\n\t\t\t\tmeetingsynth=Synth(\\meeting, [freq1: f1, freq2: f2, posX: p, posY: p2]);\r\n\r\n\t\t\t\tif(( (~thisBeastie[sex]!=~thatBeastie[sex])&&(~thisBeastie[age]>aoc)&&\r\n\t\t\t\t(~thatBeastie[age]>aoc)), {\r\n\t\t\t\t\t//birth\r\n\t\t\t\t\tbirthsynth=Synth(\"birth\", [posX: -1+ (2*~thisBeastie[xPos]/maxX), posY: ~thisBeastie[yPos]/maxY]);\r\n\t\t\t\t\t\r\n\t\t\t\t\t~thisBeastie[energy]=~thisBeastie[energy]-50;\r\n\t\t\t\t\t~thatBeastie[energy]=~thatBeastie[energy]-50;\r\n\t\t\t\t\t~newBeastie=[0, 2.rand, ~thisBeastie[xPos], ~thisBeastie[yPos], 100, false, false];\r\n\t\t\t\t\tif((~thisBeastie[energy]<0),{\r\n\t\t\t\t\t\t ~thatBeastie[energy]=~thatBeastie[energy]+~thisBeastie[energy];\r\n\t\t\t\t\t\t ~thisBeastie[energy]=0\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\tif((~thatBeastie[energy]<0),{\r\n\t\t\t\t\t\t ~newBeastie[energy]=~newBeastie[energy]+~thatBeastie[energy];\r\n\t\t\t\t\t\t ~thatBeastie[energy]=0\r\n\t\t\t\t\t});\t\r\n\t\t\t\t\t~beasties.add(~newBeastie);\r\n\t\t\t\t\t~beasties.size.postln;\r\n\t\t\t\t\tg=2.rand;\r\n\t\t\t\t\tif(g==0, {\t\t//shoot horizontally\r\n\t\t\t\t\t\t~thisBeastie[yPos]=~thisBeastie[yPos]+1;\r\n\t\t\t\t\t\tif(~thisBeastie[yPos] > (maxY-1), {~thisBeastie[yPos]=maxY-1});\r\n\t\t\t\t\t\t~thatBeastie[yPos]=~thatBeastie[yPos]-1;\r\n\t\t\t\t\t\tif(~thatBeastie[yPos] < 0, {~thatBeastie[yPos]=0});\r\n\t\t\t\t\t\t~beasties.put(~thisIndex, ~thisBeastie);\r\n\t\t\t\t\t\t~beasties.put(~thatIndex, ~thatBeastie);\r\n\t\t\t\t\t\tx=~newBeastie[xPos];\r\n\t\t\t\t\t\tif((x<(maxX/2)), {\r\n\t\t\t\t\t\t\tfor(0, 10, {\r\n\t\t\t\t\t\t\t\t~newBeastie[xPos]=~newBeastie[xPos]+2;\r\n\t\t\t\t\t\t\t\t~beasties.put(~beasties.size-1, ~newBeastie);\r\n\t\t\t\t\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t\t\t\t\tt.wait;\r\n\t\t\t\t\t\t\t})\r\n\t\t\t\t\t\t},{\r\n\t\t\t\t\t\t\tfor(0, 10, {\r\n\t\t\t\t\t\t\t\t~newBeastie[xPos]=~newBeastie[xPos]-2;\r\n\t\t\t\t\t\t\t\t~beasties.put(~beasties.size-1, ~newBeastie);\r\n\t\t\t\t\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t\t\t\t\tt.wait;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t})},\t\t\t\t\t\r\n\t\t\t\t\t\t{\t\t\t//shoot vertically\r\n\t\t\t\t\t\t~thisBeastie[xPos]=~thisBeastie[xPos]+1;\r\n\t\t\t\t\t\tif(~thisBeastie[xPos] > (maxX-1), {~thisBeastie[xPos]=maxX-1});\r\n\t\t\t\t\t\t~thatBeastie[xPos]=~thatBeastie[xPos]-1;\r\n\t\t\t\t\t\tif(~thatBeastie[xPos] < 0, {~thatBeastie[xPos]=0});\r\n\t\t\t\t\t\t~beasties.put(~thisIndex, ~thisBeastie);\r\n\t\t\t\t\t\t~beasties.put(~thatIndex, ~thatBeastie);\r\n\t\t\t\t\t\ty=~newBeastie[yPos];\r\n\t\t\t\t\t\tif((y<(maxY/2)), {\r\n\t\t\t\t\t\t\tfor(0, 10, {\r\n\t\t\t\t\t\t\t\t~newBeastie[yPos]=~newBeastie[yPos]+2;\r\n\t\t\t\t\t\t\t\t~beasties.put(~beasties.size-1, ~newBeastie);\r\n\t\t\t\t\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t\t\t\t\tt.wait;\r\n\t\t\t\t\t\t\t})\r\n\t\t\t\t\t\t},{\r\n\t\t\t\t\t\t\tfor(0, 10, {\r\n\t\t\t\t\t\t\t\t~newBeastie[yPos]=~newBeastie[yPos]-2;\r\n\t\t\t\t\t\t\t\t~beasties.put(~beasties.size-1, ~newBeastie);\r\n\t\t\t\t\t\t\t\t{w.refresh}.defer;\r\n\t\t\t\t\t\t\t\tt.wait;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t\t~partnerFound=false;\r\n\t\t\t});\r\n\t\t\teat.value;\r\n\t\t\t~beasties.put(i,~thisBeastie);\r\n\t\t\t});\r\n\t\t\tt.wait;\r\n\t\t\t{w.refresh}.defer;\r\n\t\t\ti=i+1;\r\n\t\t});\r\n\t\tstrew.value;\r\n\t}.loop;\r\n\r\n\t\r\n//~beasties.postln;\r\n});\r\n\r\ndoIt.play;\r\n)",
   "is_private" : null,
   "id" : "1-4Xa"
}
