>On Wednesday, June 26, 2002, at 07:12 AM, Robert Covington wrote: > >>> rc: >>> >>>> I think your algorithm is simply a little whacked, and drawing >>>> conclusions >>>> from it is a bit of a stretch. They just clump up and sort >>>> of v-out on >>>> the way to the edge. I will not be awarding you the Nobel >>>> Beaks Prize by >>>> any means. >>> >>> Whacked??? Well... programs do tend to reflect their writers. I >>> could/should put more flash in it to make it look better, but the >>> idea is still there. >>> >>> As for the "bit of a stretch" maybe I see a bit further than you. >> >> Mebbe you'n don't. I have quality mental optics. Somewhere. >> > >I think tedd is referring to something in the same realm as the >study of insects...their "brains" are basically a set of >mathematical responses to stimuli and can be predicted and >mimicked in computer systems accurately....imagine extending the >mathematical response results to a flock of birds. > >That's how I took it anyway. Hard to say if anyone has bothered >to waste grant money studying birds in such a fashion and what >useful data could be gleaned from such a thing. > >-D D, Greetings. The problem with Tedd's observation in my opinion is that for the most part, geese seem to be the main ones using it. Others just clump along. Or ovoid. He may be right. If he is, I will send him an old Playboy. When I said whacked, I meant something in the algorithm adjustment doesn't look quite thrilling, that is, properly functioning. I have seen similar behaviors in some of my experiments, and I just don't think drawing a conclusion from a simulation, if that is what occurred, is necessarily valid. Tedd wrote: >It just goes to demonstrate that when birds are flying somewhere >specific, all they have to do is to figure out where the center of the flock is, fly towards it, while keeping a certain distance from the others. AND they will naturally form a V.<< I disagree completely with the assumption of -natural- V formation, particularly drawing this conclusion from a simulation. I can make my own boids version fly toward a place using an algorithm in the pseudocode to direct the center of mass towards a point, and they will -not- form a V. So you can't infer anything at all about natural behavior from a simulation in this case. That is my point. "Whacked" was not a statement of opinion regarding Tedd, though I think that about some pronouncments he makes on occasion that are too global in nature. Not planetary, but as in overbroad. Like some comments about PG users, and those who don't. I'll go back to my cave now. Still no Nobel Beaks Prize for the Teddster. ;) rc /* Boids v0.1.1, FB 3 Program By Robert Covington ©2002 Based on PseudoCode by Conrad Parker <conrad@...> describing and enhancing Reynold's Boid Algorithm Addition of Tend To Place by Space Bar, 6/27/02 Adjust to enable/disable Target bird in check for tend flag to note slightly different behavior from adjustment of whole flock. */ Begin Globals DIM as int gKeyState(7) _SpaceBarModKey = 64 _TargetBird = 24 _TotalBoids = 80 // adjust to suit _wndW = 700 _wndH = 500 begin record Vector DIM x as Double DIM y as Double end Record Begin Record Boid DIM position as Vector DIM velocity as Vector End Record DIM bd(_TotalBoids) as Boid DIM pc as vector// for passing , rule 1 DIM cc as vector// for passing , rule 2 DIM pv as vector// for passing , rule 3 DIM pz as vector // for passing , Zookeeping DIM tc as vector // for passing , Place Tending End Globals '~'1 LOCAL DIM Key Local FN SpaceMe Key = 0 CALL GETKEYS(gKeyState(0))'Read the keyboard IF gKeyState(3) AND 512 THEN Key = Key + 64:'Space key End FN = Key AND _SpaceBarModKey '~'1 '~'1 /* Rule 1: Boids try to fly towards the centre of mass of neighbouring boids.*/ Local LOCAL FN Rule_1(sumBoid) DIM j as int pc.x = 0 pc.y = 0 // Total Center of Mass //c = (b1.position + b2.position + ... + bN.position) / N For j = 0 to _totalBoids Long IF sumBoid <> j pc.x = pc.x + bd.position.x(j) pc.y = pc.y + bd.position.y(j) END IF Next j pc.x = pc.x / (_TotalBoids - 1) pc.y = pc.y / (_TotalBoids - 1) pc.x = (pc.x - bd.position.x(sumboid)) / 200 pc.y = (pc.y - bd.position.y(sumboid)) / 200 END FN /* Rule 2: Boids try to keep a small distance away from other objects (including other boids).*/ Local DIM tx as Double DIM ty as double Local FN BoidDistance#(b1,b2) tx = (bd.position.x(b1)-bd.position.x(b2))^2 ty = (bd.position.y(b1)-bd.position.y(b2))^2 End FN = SQR(tx+ty) Local DIM dist as double LOCAL FN Rule_2(sumBoid) DIM j as int cc.x = 0 cc.y = 0 FOR j = 0 to _TotalBoids LONG IF j <> sumBoid dist = FN BoidDistance#(sumboid,j) Long IF dist < 4// Adjust to spread flock cc.x = cc.x - (bd.position.x(sumboid) - bd.position.x(j)) cc.y = cc.y - (bd.position.y(sumboid) - bd.position.y(j)) END IF End if Next j END FN /* Rule 3: Boids try to match velocity with near boids. */ LOCAL FN Rule_3(sumboid) DIM j as int FOR j = 0 to _TotalBoids Long IF j <> sumboid pv.x = pv.x + bd.velocity.x(j) pv.y = pv.y + bd.velocity.y(j) END IF Next j pv.x = pv.x / (_TotalBoids - 1) pv.y = pv.y / (_TotalBoids - 1) pv.x = (pv.x - bd.velocity.x(sumboid)) / 8 pv.y = (pv.y - bd.velocity.y(sumboid)) / 8 END FN Local FN ZooZoo(sumboid) pz.x = 0 pz.y = 0 LONG IF bd.position.x(sumBoid) < 0 pz.x = 10 XELSE LONG IF bd.position.x(sumBoid) > _wndW pz.x = -10 END IF END IF LONG IF bd.position.y(sumBoid) < 0 pz.y = 10 XELSE Long If bd.position.y(sumBoid) > _wndH pz.y = -10 End IF END IF End FN '~'1 Local FN Tend_To_Place(sumboid) DIM place as vector place.x = 20 // Send to upper right corner place.y = 20 '~'1 tc.x = (place.x - bd.position.x(sumBoid)) / 500 // or 1000 tc.y = (place.y - bd.position.y(sumBoid)) / 500 // or 1000 '~'1 END FN '~'1 LOCAL FN Move_All_Boids_To_New_Positions DIM j as int DIM sx as int DIM sy as int DIM vLimit as int vLimit = 3 tc.x = 0 // init place tc.y = 0// init place FOR j = 0 to _TotalBoids sx = bd.position.x(j) sy = bd.position.y(j) FN Rule_1(j) // Returns pc FN Rule_2(j) // Returns cc FN Rule_3(j) // Returns pv FN ZooZoo(j) '~'1 Long if FN SpaceMe //and j = _TargetBird FN Tend_To_Place(j) End if '~'1 bd.velocity.x(j) = bd.velocity.x(j) + pc.x + cc.x + pv.x + pz.x + tc.x bd.velocity.y(j) = bd.velocity.y(j) + pc.y + cc.y + pv.y + pz.y + tc.y // Calc Boid new position and velocity sums bd.position.x(j) = bd.position.x(j) + bd.velocity.x(j) bd.position.y(j) = bd.position.y(j) + bd.velocity.y(j) Next j END FN LOCAL FN Init_Boid_Positions DIM j // 'Maybe' helps smooth first dive to lower right for j = 0 to _TotalBoids bd.position.x(j) = RND(_wndW) bd.position.y(j) = RND(_wndH) bd.velocity.x(j) = RND(_wndW)\_wndW*Maybe bd.velocity.y(j) = RND(_wndH)\_wndH*Maybe Next j End FN Local FN Draw_All_Boids DIM j,track //track = _ZTrue // Don't Track,otherwise, boid number. Cls // Erase to background. For j = 0 to _TotalBoids //if j = track Then Long color 0,0,65535,1 ¬ //else Long color 65535,65535,0,1 Plot bd.position.x(j),bd.position.y(j) Next j End FN // MAIN FN Init_Boid_Positions // Fire It Up DIM ticks as long Window 1,"Boids",(0,0)-(_wndW,_wndH),_DocNoGrow long color 0,0,0,0 // Erase To Black Long color 65535,65535,0,1 // Boid Color FN Draw_All_Boids // Init Draw ticks = FN TickCount Do Long if FN TickCount-Ticks >= 2 // or 3. FN Draw_All_Boids FN Move_All_Boids_To_New_Positions ticks = FN tickCount end if // End Frame Speed Limiter Until FN Button