Courses/CS 461/Winter 2006/Justin Padilla/Week 3

From CSWiki

Jump to: navigation, search

[edit] JPopulation

For this model, I was hoping to simulate how a population lives, reproduces, and dies.

  • There are two breeds of turtles; male and female.
  • I made it so there is a specified starting population and ratio of males to females, and then these are generated in the setup method with randomly assigned ages and life spans.
  • Whenever a turtle lives to or beyond it's life span, it dies.
  • There are selectable time-steps, in months. For a larger time-step, turtles have less movement because they only move one space in a random direction per step.
  • When a "mature" female meets with a "mature" male, she becomes pregnant and waits 9 months of tmie before she has her child. (This part of the model does not seem to work yet)
  • Babies are born at the mother's location, and they start at age 1.
  • All turtles have to be beyond the age of "puberty" to be mature enough to mate.

[edit] JFreeway

This simulation was one I built from the social science model, Traffic. In this model, the cars look ahead and try to avoid hitting the car in front, to simulate a more realistic traffic. I am still unable to find an effective way to look at the cars ahead and act accordingly.

  • Cars within the "safe-distance" of the car in front of them will attempt to slow down at a percentage of the slow-down speed.
  • Cars who have more than the "safe-distance" in front of them will accelerate at the speed up until they reach either an unsafe distance between them and the car ahead, or they reach the speed limit.