MCB419 logo  




Homework

MCB 419 Homework 4 (Spring 2009)


Braitenberg Vehicles

In this assignment, you'll simulate four four different classes of Braitenberg vehicles:

Description       Wiring
-----------       -------------
Aggressive        Crossed excitatory
Coward            Uncrossed excitatory
Love              Uncrossed inhibitory
Explorer          Crossed inhibitory

This week you will NOT have a template program. Instead, you should combine programming elements that you have used previously in assignments 1-3.

Because this is your first complete NetLogo simulation, be sure to give yourself plenty of time to develop and debug your simulation.

Answer the questions found on the 'Assignment' tab and email your responses along with a copy of your simulation file to mcb419@gmail.com with 'hw04' in the Subject line.

This assignment is due by 11:59PM (midnight) on Tue, Feb 17.

Specific Design Requirements/Guidelines

user interface

  • patches: max-pxcor = max-pycor = 50; patch-size = 4
  • update: 'on ticks'
  • add 3 buttons labeled setup, step, and go
  • add 1 slider labeled gain to control the strength of the connections betwen the sensors and the motors (min = 1, max = 100, default = 50)
  • add 1 switch to control whether or not the bots leave trails
  • add 1 button to clear the bot trails

light source

  • one light source positioned at 0 0
  • light intensity = 1 / r ^ 2 (and intensity at the origin is 1.0)
  • patches should be shaded yellow to show light intensity
    you may want to let the color scale saturate near the source:
    e.g. set pcolor scale-color yellow inten 0 0.09

bots

  • 10 bots; shape 'default', size 6, color random
  • initial bot positions are randomized
  • two sensors (left and right), shape 'circle', color red, size 1
  • sensor response = light intensity of the underlying patch

bot motion

  • if mtrL is the speed of the left motor (typically -1 to 1)
    and mtrR is the speed of the right motor (typically -1 to 1) then:
    the bot forward speed (per tick) is : (mtrL + mtrR) / 2
    and turn angle (to the right) is: 57.3 * (mtrL - mtrR) / size
  • these movements should be constrained so that the distance
    and turn angle don't change too much on a single tick:
    -1 ≤ speed ≤ 1
    -45 ≤ turn-angle ≤ +45
  • Here's a function called squashed that you can use
    to constrain a variable x between xmin and xmax:
    to-report squashed [x xmin xmax]
      report min (list (max (list x xmin)) xmax)
    end
    

bot behaviors

  • aggressive
    crossed excitatory
    mtrL = gain * snsR
    mtrR = gain * snsL
  • coward
    uncrossed excitatory
    mtrL = gain * snsL
    mtrR = gain * snsR
  • love
    uncrossed inhibitory
    mtrL = 0.5 - gain * snsL
    mtrR = 0.5 - gain * snsR
  • explorer
    crossed inhibitory
    mtrL = 0.5 - gain * snsR
    mtrR = 0.5 - gain * snsL

Hints

Make sure that you define a new breed for the bot body. Don't just let the body be a 'turtle'. The problem is that when you 'ask turtles' it refers to every type of agent in the simulation (both bots and sensors). Also make sure that your bots own the proper variables, e.g.

bots-own [snsL snsR mtrL mtrR]

In this case snsL and snsR refer to the sensor 'agents', but mtrL and mtrR are just regular floating-point values (not agents). With these definitions your main routine might look something like this.

to go 

  ask bots [

    if (behavior = "aggressive") [
      set mtrL ( gain * ( [inten] of snsR ) )
      set mtrR ( gain * ( [inten] of snsL ) )
    ]
    
    let speed ( mtrL + mtrR ) / 2 
    let angle (57.3 * (mtrL - mtrR) / size)
    
    rt squashed angle -45 45
    fd squashed speed -1 1
  ]
  tick

end

Assignment

You can access a copy of the assignment file HERE, or copy and paste from the text below.

=================================================================
MCB 419 Homework 4 (Spring 2009)

When you've finished answering all the questions, email a copy 
of this file (hw04.txt) with your responses as PLAIN TEXT in
the main body of the email message, and attach a copy of your
Netlogo simulation file (e.g. hw04.nlogo). 

Email to mcb419@gmail.com with 'hw04' in the Subject line. 

=================================================================

Part I: Braitenberg Vehicles


1. About how much time would you estimate that you
   spent developing and debugging your simulation?
   
2. What were the most confusing / difficult aspects 
   of creating your own simulation in NetLogo without
   a template?
  
3. For each of the four behaviors that you implemented,
   describe how changing the "gain" changes the observed
   behavior.


Part II: Weekly Reading Assignment


4. In your own words, explain what Braitenberg means by
   "the law of uphill analysis and downhill invention".
   How does this apply to the current homework assignment?

 
=================================================================
END OF THE ASSIGNMENT
=================================================================

Solution

This is just one possible solution. You can download the full NetLogo file (hw04_brait.nlogo), or just look at the code below.



Copyright © Mark E. Nelson, University of Illinois at Urbana-Champaign, 2005-2009. All rights reserved.