Park of Afternoon

shulin zhang
Data Mining the City
2 min readSep 24, 2018

Description of Session A Project:

  • Title — Real-time Community Navigation System
  • Authors — Nengjing Deng (nd2559), Danting Luo (dl3149), Shulin Zhang(sz2586)
  • Description — In this project, we will build a simulated community with the distribution of various points of interest (POI). People have random start points and destinations for their daily trips, and they have several modes of transportations to choose for their movements. The real-time community navigation system will provide best routes, in terms of distance and time cost, for the users when traveling in the neighborhood. Street activities and traffic situation will be considered when calculating the best routes. Generally speaking, the main function of the study is that if we randomly select two points of interest as starting point and ending point, the shortest routes will be generated automatically, shown as the shortest distance and the shortest time. The route with the shortest distance is related to building layout and road network structure, while the route with the shortest time also needs to consider travel mode and even congestion.
  • Project/Learning Significance — The world expertise of worldwide navigation system like Google Map makes people’s life easy, efficient and convenient. Through simulating such navigation system at the community level and thinking about local activities such as small street events and community festivals, we hope to learn and develop a navigation system like Google map.

Rule:

The output displays how a population of 150, including professional working men and women, shopping housewives, and the aged people, walk and move in a park, on a weekday afternoon.

Gif:

People’s Movement in the Afternoon Park on A Weekday

Code:

import randomdef setup():
size(950,950) # roadwidth=50

global population,xs,ys,directions,speeds,humantypes, human1,shadow1,human2,shadow2,human3,shadow3,human4,shadow4
population=150
frameRate(10)
xs=[0 for n in range(population)]
ys=[0 for n in range(population)]
directions=[0 for n in range(population)]
humantypes=[0 for n in range(population)]
speeds=[0 for n in range(population)]
human1=loadImage("human1.png")
shadow1 = loadImage("shadow1.png")
human2=loadImage("human2.png")
shadow2 = loadImage("shadow2.png")
human3=loadImage("human3.png")
shadow3 = loadImage("shadow3.png")
human4=loadImage("human4.png")
shadow4 = loadImage("shadow4.png")

k=0
while k<population:
i=int(random.uniform(0,4))
directions[k]=int(random.uniform(0,4))
speeds[k]=random.uniform(0,15)+10
humantypes[k] = int(random.uniform(0,4))
xs[k] = int(random.uniform(0,width))
ys[k] = int(random.uniform(0,width))
fill(0,0,255)
noStroke()
if humantypes[k] == 0:
image(shadow1,xs[k]-36,ys[k]+23,55,12)
image(human1,xs[k],ys[k],25,35)
elif humantypes[k] == 1:
image(shadow2,xs[k]-36,ys[k]+23,55,12)
image(human2,xs[k],ys[k],25,35)
elif humantypes[k] == 2:
image(shadow3,xs[k]-36,ys[k]+23,55,12)
image(human3,xs[k],ys[k],25,35)
else:
image(shadow4,xs[k]-36,ys[k]+23,55,12)
image(human4,xs[k],ys[k],25,35)
k+=1

def draw():
clear()
noStroke()
background(0,155,0)
for k in range(0,population,1):
if directions[k] == 0:
xs[k]=(xs[k]+speeds[k] * noise(0.02 * xs[k]))%width
elif directions[k] == 1:
xs[k]=(xs[k]-speeds[k] * noise(0.02 * xs[k]))%width
elif directions[k] == 2:
ys[k]=(ys[k]+speeds[k] * noise(0.02 * ys[k]))%width
else:
ys[k]=(ys[k]-speeds[k] * noise(0.02 * ys[k]))%width
directions[k]=int(random.uniform(0,4))fill(0,0,255)
noStroke()
if humantypes[k] == 0:
image(shadow1,xs[k]-36,ys[k]+23,55,12)
image(human1,xs[k],ys[k],25,35)
elif humantypes[k] == 1:
image(shadow2,xs[k]-36,ys[k]+23,55,12)
image(human2,xs[k],ys[k],25,35)
elif humantypes[k] == 2:
image(shadow3,xs[k]-36,ys[k]+23,55,12)
image(human3,xs[k],ys[k],25,35)
else:
image(shadow4,xs[k]-36,ys[k]+23,55,12)
image(human4,xs[k],ys[k],25,35)
k+=1

--

--