mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
79e1633ebc
commit
a6926b8bc4
32
city.py
32
city.py
|
@ -12,10 +12,16 @@ import random
|
||||||
import math
|
import math
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
|
PERSON_SLEEP = 0
|
||||||
|
PERSON_WORK = 1
|
||||||
|
PERSON_PLAY = 2
|
||||||
|
PERSON_SHOP = 3
|
||||||
|
PERSON_EVENING = 4
|
||||||
|
PERSON_PARTY = 5
|
||||||
|
|
||||||
|
|
||||||
def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float):
|
def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float):
|
||||||
"""The data decoy
|
"""This simulates expected average patterns of movement in a city.
|
||||||
This simulates expected average patterns of movement in a city.
|
|
||||||
Jane or Joe average lives and works in the city, commuting in
|
Jane or Joe average lives and works in the city, commuting in
|
||||||
and out of the central district for work. They have a unique
|
and out of the central district for work. They have a unique
|
||||||
life pattern, which machine learning can latch onto.
|
life pattern, which machine learning can latch onto.
|
||||||
|
@ -25,31 +31,25 @@ def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float):
|
||||||
"""
|
"""
|
||||||
randgen = random.Random(decoySeed)
|
randgen = random.Random(decoySeed)
|
||||||
variance = 3
|
variance = 3
|
||||||
busyStates = ("work", "shop", "play", "party")
|
busyStates = (PERSON_WORK, PERSON_SHOP, PERSON_PLAY, PERSON_PARTY)
|
||||||
dataDecoyState = "sleep"
|
dataDecoyState = PERSON_SLEEP
|
||||||
dataDecoyIndex = 0
|
|
||||||
weekday = currTimeOfDay.weekday()
|
weekday = currTimeOfDay.weekday()
|
||||||
minHour = 7 + randint(0, variance)
|
minHour = 7 + randint(0, variance)
|
||||||
maxHour = 17 + randint(0, variance)
|
maxHour = 17 + randint(0, variance)
|
||||||
if currTimeOfDay.hour > minHour:
|
if currTimeOfDay.hour > minHour:
|
||||||
if currTimeOfDay.hour <= maxHour:
|
if currTimeOfDay.hour <= maxHour:
|
||||||
if weekday < 5:
|
if weekday < 5:
|
||||||
dataDecoyState = "work"
|
dataDecoyState = PERSON_WORK
|
||||||
dataDecoyIndex = 1
|
|
||||||
elif weekday == 5:
|
elif weekday == 5:
|
||||||
dataDecoyState = "shop"
|
dataDecoyState = PERSON_SHOP
|
||||||
dataDecoyIndex = 2
|
|
||||||
else:
|
else:
|
||||||
dataDecoyState = "play"
|
dataDecoyState = PERSON_PLAY
|
||||||
dataDecoyIndex = 3
|
|
||||||
else:
|
else:
|
||||||
if weekday < 5:
|
if weekday < 5:
|
||||||
dataDecoyState = "evening"
|
dataDecoyState = PERSON_EVENING
|
||||||
dataDecoyIndex = 4
|
|
||||||
else:
|
else:
|
||||||
dataDecoyState = "party"
|
dataDecoyState = PERSON_PARTY
|
||||||
dataDecoyIndex = 5
|
randgen2 = random.Random(decoySeed + dataDecoyState)
|
||||||
randgen2 = random.Random(decoySeed + dataDecoyIndex)
|
|
||||||
angleRadians = \
|
angleRadians = \
|
||||||
(randgen2.randint(0, 100000) / 100000) * 2 * math.pi
|
(randgen2.randint(0, 100000) / 100000) * 2 * math.pi
|
||||||
# some people are quite random, others have more predictable habits
|
# some people are quite random, others have more predictable habits
|
||||||
|
|
Loading…
Reference in New Issue