Homework 1: Exploding Collisions
Introduction
Create a new version of your Particle World model called Particle Smash. In this version, you will let the space be bounded rather toroidal, so that agents will bounce off the walls. Moreover, crashing into other agents will now have more dire consequences.
Instructions
To keep things relatively simple, restrict agent movement to straight lines in the absence of collisions (\(whimsy=0\)). Initialize your agents with random sizes from 1 to 10.
Set the boundaries to fixed instead of toroidal. Change the dynamics so that the turtles “bounce” off the walls if they contact the edge of the world. Recall from physics that the angle of incidence equals the angle of reflection. For example, when a moving turtle hits the wall on a shallow angle, it should bounce off at a similarly shallow angle.
Alter the code so that every time an agent collides with either a wall or another agent, it changes color to a random new color.
Update the code so that any time an agent collides with another agent, each agent splits into two smaller agents with half of their sizes heading in random directions (if size is an odd number, round it to the nearest number using the command
round
). It may be useful to know that the NetLogo primitivehatch
cause an agent to spawn new agents, and that the primitivesize
controls an agent’s size. When smaller agents with size 1 collide, they should remain the same size and not split anymore.
Outcomes
Plot the amount of collisions over time.
What happens if all particles start with size 1? And if they all start with size 10? Answer these questions in the Info tab in your Netlogo program.
Grading Rubric:
This lab will be graded the following way: 10 pts total
- Coding: 5 pts
- Code works and simulation runs: 2.5 pts
- Code is clean, perfectly indented, hospitable: 1pts
- Good interface and graphics: 1.5 pts.
- Documentation: 5 pts.
- Your Info tab has good documentation that helps another person to understand and replicate what you’ve done.
Ways students may lose points:
- -5: No documentation at all
- -1.5: No graphics
- -5: Code does not run
Submission
Submit your code on Moodle.