MCB419 logo  




Homework

MCB 419 Homework 1 (Spring 2009)


Your first NetLogo simulation!

Your main task for this assignment is to create a simple simulation similar to the one found on the 'Demo' tab. You will write Netlogo code to create a variable number of agents and have them execute one of two simple movement patterns ('circle' or 'wander'). If you have time and want an extra challenge, you can add a third movement pattern ('square'), which is a bit trickier to implement. Specific guidelines for the simulation can be found on the 'Specs' tab.

After creating and debugging your simulation, you will use it to answer some questions found on the 'Assignment' tab, along with some questions about this week's readings. When you've finished the assignment, email your responses and a copy of your NetLogo simulation file to mcb419@gmail.com with 'hw01' in the Subject line.

Here is a NetLogo file that you can download to help get you started: hw01_template.nlogo

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

Specific Design Requirements/Guidelines

building the user interface

  • use the default values for patch settings
  • set the 'view updates' option to be 'on ticks' (rather than 'continuous')
  • add 1 slider labeled num-bots to control the number of agents (range 1-20, default 5)
  • add 3 buttons labeled setup, step, and go
  • add 1 chooser labeled behavior with the choices: 'circle', 'wander' and 'square' (optional).

button functionality

  • when the setup button is pressed
    • the simulation should be cleared (clear-all)
    • background patches should be shaded randomly to aid in visualizing patch size; feel free to pick your own background color scheme (the Demo uses shades of gray).
    • from 1-20 bots should be created, based on value of 'num-bots' slider
    • initial bot positions should be randomized
    • bots should start with their drawing pen in the 'down' state
  • when the step button is pressed
    • all bots execute a SINGLE STEP of the chosen movement pattern (circle or wander or square)
  • when the go button is pressed
    • all bots move CONTINUOUSLY in the chosen pattern (circle or wander or square)

bot behaviors

  • circle
    on each tick:
    bots should turn right by 10 degrees
    and then move forward 1 unit
  • wander
    on each tick:
    bots should turn by a random amount between -10 and +10 degrees
    and then move forward 1 unit
  • square (OPTIONAL)
    bots should turn right by 90 degrees on every 10th tick;
    bots move forward 1 unit on each tick
  • (Note: 'square' is a bit trickier to implement than 'circle' or 'wander'; you'll need to explore the Netlogo documentation to find the additional functions that you need; if you can't figure it out, don't worry... it's truly optional.)

Assignment

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

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

When you've finished answering all the questions, email a copy 
of this file (hw01.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. hw01.nlogo). 

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

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

1. When a bot is 'wandering', approximately how many ticks does 
   it take to move across the entire world (from one edge to the
   opposite edge?)     

2. a) If a bot turns by 10 degrees on each tick when it is 'circling', 
      how many ticks are required to complete a full circle?

   b) if the bot moves forward by 1 unit on each tick, how far would 
      it travel in the time needed to complete a full circle?

   c) what is the predicted diameter of the resulting circle?

   d) does that agree with the diameter that you observe when you
      run the simulation?

3. Which of the movement patterns that you implemented is most
   efficient at 'exploring' the world? Why?

4. Modify the 'wander' behavior so that the bot turns by a random
   angle between -180 and +180 on each tick. Rerun the simulation
   for a single bot. How does the behavior change, relative to the
   original 'wander' behavior?

5. Modify the 'wander' behavior so that the bot turns by a random
   angle between -5 and +20 on each tick. Describe the behavior.

6. Change the 'wander' behavior back to it's original values (random
   angle between -10 and +10). Click the 'Settings...' button and
   UNCHECK 'World wraps horizontally' and 'World wraps vertically'. 
   Rerun the simulation. Describe the behavior.

7. Set the num-bots slider to 1, click 'setup', then click 'go'.
   While the simulation is running, change the value of the 
   'num-bots' slider. What happens? Change the value of the 
   'behavior' chooser... what happens?  Why does the simulation
    respond to one user-interface element, but not the other?

8. Hawking thinks that continued evolution of intelligence may
   eventually shift from biological life forms to self-replicating 
   electromechanical "life" forms.  What do you think of that idea?

9. According to the article by Crist, what observations prompted
   Darwin to conclude that earthworms exhibit some degree of
   intelligence?  How does this fit with your own personal ideas
   about what qualifies as intelligence?  Are worms 'smart'? 

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

Solution

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


 

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