Week 03 template

  YOUR NAME HERE
  
  due date: Tue Jan 31 by 9:00 PM
  email to: mcb419@gmail.com
  subject: hw03
  email content: url link to your jsbin project and answers to questions 
  

In this assignment you will see how agent-based simulations can be analyzed quantitatively using p5js. Your simulation will consist of a single agent foraging for food pellets in a confined environment. The agent wanders through the environment and consumes pellets. The main goal of the assignment is to explore foraging efficiency as a function of wander noise.

Foraging efficiency will be measured as the mean number of pellets collected in 2000 ticks, averaged over 10 trials. As you will see, if the wander noise is too low, efficiency suffers because the agent tends to get stuck against the walls; if the wander noise is too high, efficiency suffers because the agent's trajectory is very compact.

Simulation specifications
canvas: width=400, height=300
boundaries: solid (constrained) with no bouncing
bot: dia=30, speed=1.0, x0=width/2, y0=height/2, heading0=0
pellets: N=100, randomly distributed, treated as points, drawn as green dots
controller: wander, uniform random noise, heading += noise * random(-1,1);
noise values to test: [0.0, 0.1, 0.2, 0.5, 1.0, 2.0]
foraging performance: measured as the number of pellets collected in 2000 ticks
number of trials: repeat 10 trials for each value of wander noise
statistics: report MEAN ± STD ERR (a function called "calcArrayStats" has been provided for you)

Instructions

Edit the javascript code to implement the scenario described above. Feel free to add additional user-interface elements. Once the simulation is working correctly, measure foraging efficiency as a function of wander noise and report your results in the table below. (HINT: when wander noise is 0.2, the average number of pellets collected should be around 25.) You can run each trial manually and keep track of individual trial results using pen and paper (BEGINNER), or you can automate the entire data collection and analysis procedure so that the table below gets filled in automatically by your javascript code (ADVANCED).

In addition to filling out the table, answer the following questions in the body the email that you submit.

  1. About how long did you spend on this assignment?
  2. What part of the assignment was the most challenging?
  3. If the boundary conditions were "wrapped" instead of "solid", do you think foraging efficiency would generally increase or decrease? Explain.
  4. If the boundary conditions were "wrapped" instead of "solid", do you think the optimal value of wander noise would be higher, lower, or the same? Explain.

Results table

noise
value
collected
(mean ± err)
0.0 ?? ± ??
0.1 ?? ± ??
0.2 ?? ± ??
0.5 ?? ± ??
1.0 ?? ± ??
2.0 ?? ± ??