Population — Assignment 3
Published in
1 min readOct 3, 2018
Rules
Population of 150 people shown in the form of colour-changing dots moving randomly in a confined square.
Code
x = []
y = []
xSpeed = []
ySpeed = []
populationSize = 150
radius = 12for i in range(populationSize):
x.append(random(0,800))
y.append(random(0,800))
xSpeed.append(random(-7.5,7.5))
ySpeed.append(random(-7.5,7.5))
def setup():
size(800, 800)
smooth()
def draw():
background(0)
for i in range(populationSize):
x[i] = x[i] + xSpeed[i]
y[i] = y[i] + ySpeed[i]
if (x[i] > width - radius) or (x[i] < radius):
xSpeed[i] = xSpeed[i] * -1
if (y[i] > height - radius) or (y[i] < radius):
ySpeed[i] = ySpeed[i] * -1
noStroke()
fill(random(255),random(255),random(255))
ellipse(x[i], y[i], radius, radius)
Session A Project Idea
Simulation of the population in and around Hudson city accessing food from mobile grocery stores (ex. Mobile Grocer) vs. the existing Walmart on the outskirts of the county - depending on proximity, access to public/private transport, cost of items and travel time.