def create_citizen( faction, city ):
    citizen = person.person( morality = faction.morality +
                                        (rand * (random.random() - 0.5)),

                             ambition = 5
                             )

    return citizen
Example #2
0
def info_input():
    name = raw_input("Enter name:")
    address = raw_input("Enter address:")
    group = raw_input("Enter group:")
    persontuple = (name, address, group)
    persondict = person(persontuple)

    return persondict
Example #3
0
 def setUp(self):
     self.fname = "Car"
     self.lname = "Owner"
     self.age = 30
     self.gender = "Male"
     self.address = '16600 LaughAlot St #306'
     self.city = 'Sioux Falls'
     self.zipcode = '57104'
     unittest.TestCase.setUp(self)
     self.person=person(self.fname, self.lname, self.age, self.gender, self.address, self.city, self.zipcode)
Example #4
0
def runs(num,run,infectivity):

    global numVaccinated
    numVaccinated = num

    #initialize list of people and their coordinates,
    plist = [person([randint(0,GRIDSIZE),randint(0,GRIDSIZE)],SCALE) for i in range(int(size))]

    #create the initial infected
    for infected in range(initialInfected):
        #set starting number of infected
        plist[infected].set_infected(SCALE)

    #create the initial vaccinated
    for vaccinated in range(numVaccinated):
        #initialize the vaccinated persons
        plist[vaccinated+initialInfected].set_vaccinated()
        
    #set runs to 0    
    runs = 0
    inf = getInf(plist)
    v = getVac(plist)
    c = getCont(plist)
    print("infected:{}".format(inf))
    logger(runs,inf,size-(inf+v),v,c,infectivity,run)

    #run program until everyone not vaccinated is infected
    while inf !=(size-v) and not (inf == 0 and c == 0):
        #counts runs
        runs+=1
        
        #move people each turn
        plist = move(plist,GRIDSIZE)
        
        #check for collisions with infected
        collisions(plist,infectivity)
        
        inf = getInf(plist)
        #log every 100 runs
        if runs %1000 == 0:
            print(runs)
            v = getVac(plist)
            c = getCont(plist)
            print("infected:{}".format(inf))
            print("immune: {}".format(v))
            print("contagious: {}".format(c))
            logger(runs,inf,size-(inf+v),v,c,infectivity,run)


    inf = getInf(plist)
    v = getVac(plist)
    c = getCont(plist)
    print("infected:{}".format(inf))
    logger(runs,inf,size-(inf+v),v,c,infectivity,run)
Example #5
0
 def getyears(inputString):
     if len(inputString)== 0:
         return
     else:
         inputString = inputString.rstrip('\n')
         inputString = inputString.split(":")
         temp = input.validateYears(inputString)
         if temp is not None:
             return (person(temp[0], temp[1]))
         else:
             input.printInvalid(inputString)
Example #6
0
def person_spawn():
    if random.randint(0,100) < 1:
        name = names[random.randint(0,len(names)-1)]
        name = name[:len(name) - 1]
        fc = random.randint(0,6)
        if fc <= 1:
            faction = "Opener"
        elif fc <= 3:
            faction = "Closer"
        else:
            faction = "Neutral"
        pnew = person.person(0, random.randint(1,9), resources.person_image, name, faction)
        floors[0].append(pnew)
    def add_person(self):
        name = input('Please input name-->')
        address = input('Please input address-->')
        phone = input('Please input phone-->')

        from person import person
        person = person(name, address, phone)

        if person.name in addr_book.book.keys():
            print('The person already exists')
        else:
            addr_book.book[person.name] = person
        
        del person
def main():
    student1 = student("John Smith", "*****@*****.**")
    student2 = student("Name Surname Suffix", "*****@*****.**", False)
    admin1 = admin("Joe Admin", "*****@*****.**")
    admin2 = admin("root", "root@localhost", False)
    placeholder = person("", "")

    #desired output is commented next to each print statement
    print("Testing get name from student")
    print(student1.get_name()) #John Smith
    print(student2.get_name()) #Name Surname Suffix
    print("Testing get name from admin")
    print(admin1.get_name()) #Joe Admin
    print(admin2.get_name()) #root
    print("Testing get name from person")
    placeholder = student1 #John Smith
    print(placeholder.get_name())
    placeholder = student2 #Name Surname Suffix
    print(placeholder.get_name())
    placeholder = admin1 #Joe Admin
    print(placeholder.get_name())
    placeholder = admin2 #root
    print(placeholder.get_name())

    print("")
    print("Testing get email from student")
    print(student1.get_email()) #[email protected]
    print(student2.get_email()) #[email protected]
    print("Testing get email from admin")
    print(admin1.get_email()) #[email protected]
    print(admin2.get_email()) #root@localhost
    print("Testing get email from person")
    placeholder = student1
    print(placeholder.get_email()) #[email protected]
    placeholder = student2
    print(placeholder.get_email()) #[email protected]
    placeholder = admin1
    print(placeholder.get_email()) #[email protected]
    placeholder = admin2
    print(placeholder.get_email()) #root@localhost

    print("")
    print("Testing get attendance from student")
    print(student1.get_attendance()) #True
    print(student2.get_attendance()) #False

    print("")
    print("Testing get request from admin")
    print(admin1.get_admin_request()) #True
    print(admin2.get_admin_request()) #False
 def __init__(self, width = 500, height = 200, days = 50, pop_size = 3, num_cities = 1, num_villages = 1):
     self.width = width      # width of map
     self.height = height    # height of map
     self.days = days        # number of days to simulate
     self.pop_size = pop_size # population size
     
     self.grid = [[[] for i in range(self.width)] for j in range(self.height)] # store list of population indices at each grid cell
     self.grid_home = [[[] for i in range(self.width)] for j in range(self.height)]
     self.pop = [person() for i in range(self.pop_size)]
     self.cities = [city(self.width, self.height, 20) for i in range(num_cities)]
     
     # list of probabilities
     self.travel_prob = 0.2
     self.home_prob = 0.5 # chance go home each timestep
     self.non_local_prob = 0.1 # chance for non-local travel
     self.fam_size_a = 3
     self.fam_size_b = 6
Example #10
0
def process():
    '''main process'''
    person_hash = read_info()
    # person_hash = {}
    f = file("info.db", 'w')
    running = 1
    while running:
        name = raw_input("Enter name:")
        if name == 'q':
            break
        phone = int(raw_input("Enter phone:"))

        p = person.person(name, phone)
        person_hash[name] = p

    # person_hash[name].display()
    cPickle.dump(person_hash, f)
    f.close()
Example #11
0
def load(file_name):
    ppl_list = {}
    
    with open(file_name, newline='') as csvfile:
        filereader = csv.reader(csvfile, delimiter=',')
        first_row = False
        for row in filereader:
            if not first_row:
                first_row = True
            else:
                [id, nick_name, real_name, bday, gender, father, mother, mar, chi, death_dte, imp_flg, notes] = row
                
                marriage = mar.split('-')
                
                if chi == '-':
                    children = chi
                else:
                    children = chi.split('-')
                    
                imp_flg = True if imp_flg == '1' else False
                    
                ppl_list[id] = person.person(id, nick_name, real_name, bday, gender, father, mother, marriage, children, death_dte, imp_flg, notes)
                
    return ppl_list
Example #12
0
from person import person

incomplete = True
press = person("press")
kardashian = person("celeb")
print "Note, kicking has a lower hit chance than punching, but does higher damage.\n"

while incomplete:
    kardashian.user(press)
    if not press.alive:
        break
    press.ai(kardashian)
    if not kardashian.alive:
        break

print "\nHere are your stats!\nHealth lost: " + str(
    kardashian.healthorig - kardashian.health
) + " points.\nHits taken: " + str(kardashian.hits_taken) + "\nSuccessful hits: " + str(
    kardashian.hits
) + "\nMisses: " + str(
    kardashian.misses
) + "\nHit percent: " + str(
    100 * (float(kardashian.hits) / float(kardashian.hits + kardashian.misses))
) + "%"
Example #13
0
#load data from files

df = open("defaultperson.txt", "r")
lines = df.readlines()
df.close()

nf = open("names.txt", "r")
names = nf.readlines()
nf.close()

dialogue = text.Label("", font_name="Tulpen One", font_size=20, color=(255,255,255,255), x=0,y=24,width=360,multiline=True, halign='center')

#alarmButton = text.Label("ALARM", font_name="VT323", color=(255,255,255,255), x=300,y=500,halign='center')

person1 = person.person(0, 5,  resources.person_image, "Steve")
person2 = person.person(2, 5,  resources.person_image, "Rachel")

talking = ""

#add to objects list

#objects.append(building)

for i in range(0, 10):
    w = gameobject.gameobject(78.0, 50.0 + i * 50 + 4, 4, 42, (255,255,255,255))
    menuImage.append(w)
    w2 = gameobject.gameobject(278.0, 50.0 + i * 50 + 4, 4, 42, (255,255,255,255))
    menuImage.append(w2)

for i in range(0, 10):
with open(result,'wb') as writeFile:
	wD = csv.DictWriter(writeFile, headersList,restval='', extrasaction='raise', dialect='excel')
	wD.writeheader()

	personList =[]

	for f in getFiles(source):
		chapter = f.split('/')[-1].replace('.txt','').replace('_',' ')
		print chapter.upper()
		print
	
		with open(f, 'rb') as text:
			chunks = textChunker(text)
			for chunk in chunks:
				p = person(chunk)
				p.category = chapter
				p.analyse()
				personList.append(p)
				p.plotRaw()
	
	for person in personList:
		wD.writerow(person.asDict())

print 'done!'





Example #15
0
    usrInput = ''
    people = []

    promptHeader = '\n'+'_'*20
    prompt1 = promptHeader+'\n1. Create Person\n2. Create Student\n3. Create Instructor\n\nSelect: '
    prompt2 = '\nEdit:\n1. Major \n2. GPA\n\nSelect:'
    prompt3 = '\nEdit:\n1. Salary\n\nSelect:'

    #while usrInput != '4':
    usrInput = int(raw_input(prompt1))
    if 0 < usrInput < 4:
        name = str(raw_input('Name: '))
        year = str(raw_input('Birth Year: '))
    if usrInput is 1:
        me = person.person(name,year)
    elif usrInput is 2:
        major = str(raw_input('Major: '))
        gpa = str(raw_input('GPA: '))
        me = person.student(name,year,major,gpa)
    elif usrInput is 3:
        salary = str(raw_input('Salary: '))
        me = person.instructor(name,year,salary)
    #elif usrInput is 4:
    #    for person in people:
    #        print person
    else:
        print 'INVALID INPUT\n'
        usrInput = 0
    
    while usrInput != 0:
Example #16
0
#!/usr/bin/python

import person

p = person.person("zenki", 25)

def show():
	global person_id
	person_id = 100
	print person_id

show()
print person_id

Example #17
0
        if flag != False:
            print "addressBook added successfully."

    elif option == "update" or option == "u":
        print "Enter the person you want to update:"
        pU = info_input()
        flag = pU.update_person(addressdict)
        write_address(addressfile, addressdict)
        if flag != False:
            print "addressBook updated successfully."

    elif option == "delete" or option == "d":
        print "Enter the person <name> you want to delete:"
        name = raw_input()
        persontuple = (name, "", "")
        pD = person(persontuple)
        flag = pD.delete_person(addressdict)
        write_address(addressfile, addressdict)
        if flag != False:
            print "addressBook person %s delete successfully." % name

    elif option == "search" or option == "s":
        print "Enter the person <name> you want to search:"
        name = raw_input()
        if name != "":
            persontuple = (name, "", "")
            pS = person(persontuple)
            personInfo = pS.search_person(addressdict)
            if personInfo != False:
                print "%s's information is (address,group):%s" % (name, personInfo)
        else:
Example #18
0
def printList(thelist):
    for element in thelist:
        print (str(element)+"")



for line in file:

    text = line.split()
    
    if text[0] is 'E':
        if getPerson(text[1]) is not False:
            person1 = getPerson(text[1])
        else:
            person1 = person(text[1])
            
        if getPerson(text[2]) is not False:
            person2 = getPerson(text[2])
        else:
            person2 = person(text[2])
            
        if text[3]:
            if getPerson(text[3]) is not False:
                person3 = getPerson(text[3])
            else:
                person3 = person(text[3])
                
            person1.setSpouse(person2)
            person1.addChild(person3)
            isCreated(person1)
Example #19
0
import shelve
from person import person
fieldnames=('name','age','job','pay')
db=shelve.open('class-shelve')
while True:
    key=raw_input('\nkey?=> ')
    if not key:break
    if key in db.keys():
         record=db[key]
    else:
        record=person(name='?',age='?')
    for field in fieldnames:
        currval=getattr(record,field)
        newtext=raw_input('\t[%s]=%s\n\t\tnew?=>' % (field,currval))
        if newtext:
            setattr(record,field,eval(newtext))
    db[key]=record
db.close()
Example #20
0
    if data_type >= len(data):
        return []
    data = data[data_type]
    L = []
    for i in range(len(data[0])):
        s = []
        for k in range(len(data)):
            s.append([k+1,data[k][i][1], '20150623102807123456'])
        L.append(s)
    return L

if __name__ == '__main__':

    for i in range(1, 501):
        people_idle.append(person(i))

    for i in readAllRegionInfo():
        maparea.append(i)
    buslines.update(readAllLineInfo())
    busroutes.update(readAllRouteInfo())
    print(busroutes)

    a = SimulateBus(1, 0, 10, 10, 0)
    # a.stop(30, 10)
    # a.stop(40, 20)
    a.generateData()
    b = SimulateBus(1, 100, 10, 5, 100)
    b.generateData()
    s = simulate()
    s.addSimulateBus(a)
Example #21
0
#load data from files

df = open("defaultperson.txt", "r")
lines = df.readlines()
df.close()

nf = open("names.txt", "r")
names = nf.readlines()
nf.close()

dialogue = text.Label("", font_name="Tulpen One", font_size=20, color=(255,255,255,255), x=0,y=24,width=360,multiline=True, halign='center')

#alarmButton = text.Label("ALARM", font_name="VT323", color=(255,255,255,255), x=300,y=500,halign='center')

person1 = person.person(0, 5, "Steve")
person2 = person.person(2, 5, "Rachel")

talking = ""

#add to objects list

#objects.append(building)

for i in range(0, 10):
    w = gameobject.gameobject(78.0, 50.0 + i * 50 + 4, 4, 42, (255,255,255,255))
    menuImage.append(w)
    w2 = gameobject.gameobject(278.0, 50.0 + i * 50 + 4, 4, 42, (255,255,255,255))
    menuImage.append(w2)

for i in range(0, 10):
Example #22
0
 def __init__(self, width = 70, height = 70, days = 500, pop_size = 1000, var = [], density = []):
     self.width = width      # width of map
     self.height = height    # height of map
     self.days = days        # number of days to simulate
     self.pop_size = pop_size # population size
     self.num_cities = len(var)
     self.city_den = copy.deepcopy(density)
     
     self.grid = [[[] for j in range(self.width)] for i in range(self.height)] # store list of population indices at each grid cell
     self.grid_home = [[[] for j in range(self.width)] for i in range(self.height)]
     self.pop = [person() for i in range(self.pop_size)]
     self.cities = [city(self.width, self.height, var[i], density[i]) for i in range(self.num_cities)]
     #for i in range(self.num_cities):
     #    print self.cities[i].loc.x, self.cities[i].loc.y
     self.R = [0 for i in range(self.pop_size)]
     self.repro = 0
     
     # TODO: list of probabilities - maybe change this?
     self.travel_prob = 0.2
     self.home_prob = 0.5        # chance go home each timestep
     self.non_local_prob = 0.5   # chance for non-local travel
     self.fam_size_a = 3
     self.fam_size_b = 6
     # CONTACT RATES
     self.b_fam = 0.1
     self.b_com = 0.006
     self.b_fun = 0.2          # funeral contact rate
     # PROBABILITIES
     self.i_mortality = 0.5
     self.h_prob = 0.233 #0.248 
     self.h_mortality = 0.5
     # TIMEOUTS
     self.incubation_time = 11
     self.i_death_time = 8   # use random timeout, [7,9]
     self.i_death_time_a = 7
     self.i_death_time_b = 9
     self.funeral_time = 2.01    # use constant, 2
     self.funeral_time_c = 2
     self.r_time = 10            # use constant, 15
     self.pre_h_time = 4.5 #4.6      # use random timeout, 1-5
     self.pre_h_time_a = 3
     self.pre_h_time_b = 6
     self.h_recover_time = 5.5 # use random timeout, 13-18
     self.h_recover_time_a = 5
     self.h_recover_time_b = 6
     self.h_death_time = 3.51   # use random timeout, 8-12
     self.h_death_time_a = 3
     self.h_death_time_b = 4
     
     # count number infected in each way
     self.funeral_count = 0
     self.family_count = 0
     self.comm_count = 0
     self.numberoffunerals = 0
     self.num = [0 for i in range(7)]
     # total number in each state SEIHRFD
     for i in range(7):
         if i == 0:
             self.num[i] = self.pop_size
         else:
             self.num[i] = 0
     self.numlist = [[] for i in range(7)]
Example #23
0
import shelve
from person import person
from manager import manager
bob=person('bob smith',42,30000,'sweng')
sue=person('sue jones',45,40000,'music')
tom=manager('tom doe',50,50000)
db=shelve.open('class-shelve')
db['bob']=bob
db['sue']=sue
db['tom']=tom
db.close()

Example #24
0
def main():

    # Create name lists
    person.person(1)
    community.communify(1)
    sys.exit("done!")
Example #25
0
 def setup(self, app):
     self.app = app
     rect = self.app.screen.get_rect()
     self.p = person.person('sprites/maleprotagonist.png', rect.center)
Example #26
0
from person import person


class RecordSystem:
    def __init__(self):
        self.people = []

    def add_person(self, person):
        self.people.append(person)

    def display(self):
        print(self.people)


record_system = RecordSystem()

Gura = person("Gura")