Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computation as an Expressive Medium Lab 10½: Looking through the Braitenberg Vehicle code Jason Alderman.

Similar presentations


Presentation on theme: "Computation as an Expressive Medium Lab 10½: Looking through the Braitenberg Vehicle code Jason Alderman."— Presentation transcript:

1 Computation as an Expressive Medium Lab 10½: Looking through the Braitenberg Vehicle code Jason Alderman

2 Braitenberg! (It's so fun to say. Try it!) Look through the sections of the code Look through the sections of the code How-to tips to How-to tips to change the behavior of vehicle change the behavior of vehicle add another set of sources add another set of sources put sources on vehicles put sources on vehicles do nifty drawing effects do nifty drawing effects

3 The Methods and Classes setup() draw() keyPressed() updateGround() VehicleSensor Wheel mousePressed() mouseReleased() nonlinear() Source drawMe() doSenseLogic() moveMe() checkBounds() checkCollision() setASpeed() setBSpeed() changeASpeed() changeBSpeed() drawMe() setSpeed() setSpeedChange() drawMe() setLocation() getSense() getInverseSense() getNonlinearSense() drawMe() setLocation() getLocation() checkCollision() getReading() SensoryField get() addSource() deleteSource() getSource() update() Wheel() Sensor()Source() SensoryField() Vehicle()

4 The Vehicle VehicleSensor Wheel drawMe() doSenseLogic() moveMe() checkBounds() checkCollision() setASpeed() setBSpeed() changeASpeed() changeBSpeed() drawMe() setSpeed() setSpeedChange() drawMe() setLocation() getSense() getInverseSense() getNonlinearSense() Wheel() Sensor()Vehicle() 2x

5 The SensoryField Source drawMe() setLocation() getLocation() checkCollision() getReading() SensoryField get() addSource() deleteSource() getSource() update() Source() SensoryField() ArrayList sources float[][] field field is a 2D array of float values from 0 to 255 (…we translate these values to a color to draw the ground)

6 Change the vehicle behavior? Make a subclass of vehicle and cut-and- paste the version of doSenseLogic() that you want… Make a subclass of vehicle and cut-and- paste the version of doSenseLogic() that you want… Consult Lecture 11 slides for overview of these behaviors Consult Lecture 11 slides for overview of these behaviors // Sensor output goes directly to wheel on same side void doSenseLogic() { setASpeed(sA.getSense()); setBSpeed(sB.getSense()); } // Sensor output crossed to wheel on opposite side /* void doSenseLogic() { setASpeed(sB.getSense()); setBSpeed(sA.getSense()); }*/ // Each sensor goes to wheel on same side with an inhibitory connection /* void doSenseLogic() { setASpeed(sA.getInverseSense()); setBSpeed(sB.getInverseSense()); } */ // Each sensor goes to wheel on opposite side with an inhibitory connection /* void doSenseLogic() { setASpeed(sB.getInverseSense()); setBSpeed(sA.getInverseSense()); } */ // Sensors are hooked up to opposite motors, with threshhold sensing. /* void doSenseLogic() { setASpeed(sB.getNonlinearSense()); setBSpeed(sA.getNonlinearSense()); } */

7 Add another type of source? doSenseLogic() will probably need to be changed, so that the wheels get a combination of inputs defining the pixels of PImage ground will need to somehow show sources differently Create a new SensoryField class Create a new SensoryField class Things to watch for: Things to watch for: almost all the methods reference ONLY lightsGround… almost all the methods reference ONLY lightsGround… You'll have to change the Vehicle's Sensors' getSense methods (or add more sensors on the Vehicle) You'll have to change the Vehicle's Sensors' getSense methods (or add more sensors on the Vehicle)

8 Put a source on a vehicle You need the Sources to be in a SensoryField of their own …so you'll want a pointer field in Vehicle (perhaps just an id# that references the Vehicle's particular Source in the SensoryField ArrayList) You need the Sources to be in a SensoryField of their own …so you'll want a pointer field in Vehicle (perhaps just an id# that references the Vehicle's particular Source in the SensoryField ArrayList) And don't forget to change the source location when the Vehicle moves (instead of when the mouse drags) And don't forget to change the source location when the Vehicle moves (instead of when the mouse drags) Things to watch for: Things to watch for: If a Vehicle has a Source and can sense that same type of Source on other Vehicles, then you need to make sure that it subtracts the value of its own Source when sensing (the getReading under the x, y of the Sensor) Sources are currently added or subtracted from the SensoryField when user presses number keys… make this different for your new SensoryField, since Sources are tied to Vehicles instead of free-floating.

9 Do nifty drawing effects Now that you have a 2D array, you don't have to draw to a PImage ground Now that you have a 2D array, you don't have to draw to a PImage ground You could draw rect()s or ellipse()s …or use some other kind of icon to represent each "pixel" in the ground of your source You could draw rect()s or ellipse()s …or use some other kind of icon to represent each "pixel" in the ground of your source Image from carnivore.webcam.sniffing …using Safari.html icons for each pixel.


Download ppt "Computation as an Expressive Medium Lab 10½: Looking through the Braitenberg Vehicle code Jason Alderman."

Similar presentations


Ads by Google