Example #1
0
 def addPersonalityTypes(self, agents):
     """
     Stores all of the needed data for each personality.
     
     agents: list of Person objects
     """
     
     if len(self.acceptedTypes) == 0 or (VType.personalityGraphs in self.acceptedTypes):
         for agent in agents:
             self.personalityPostsSent[agent.p_type - 1] += agent.posts_sent
             self.personalityConnections[agent.p_type - 1] += len(agent.affinity_map)
             self.personalityFriends[agent.p_type - 1] += len(agent.friends)
             self.personalityEnemies[agent.p_type - 1] += len(agent.enemies)
             
             friendsDistance = 0.0
             for friend in agent.friends:
                 friendsDistance += M.find_distance(agent, friend)
                 
             enemiesDistance = 0.0
             for enemy in agent.enemies:
                 enemiesDistance += M.find_distance(agent, enemy)
             
             if len(agent.friends) != 0:
                 self.personalityFriendsDistance[agent.p_type - 1] += friendsDistance / len(agent.friends)
             if len(agent.enemies) != 0:
                 self.personalityEnemiesDistance[agent.p_type - 1] += enemiesDistance / len(agent.enemies)
             
         self.personalityConnections = (N.array(self.personalityConnections) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityFriends = (N.array(self.personalityFriends) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityEnemies = (N.array(self.personalityEnemies) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityFriendsDistance = (N.array(self.personalityFriendsDistance) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityEnemiesDistance = (N.array(self.personalityEnemiesDistance) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.updatePersonalityGraphs()
 def addPersonalityTypes(self, agents):
     """
     Stores all of the needed data for each personality.
     
     agents: list of Person objects
     """
     
     if len(self.acceptedTypes) == 0 or (VType.personalityGraphs in self.acceptedTypes):
         for agent in agents:
             self.personalityPostsSent[agent.p_type - 1] += agent.posts_sent
             self.personalityConnections[agent.p_type - 1] += len(agent.affinity_map)
             self.personalityFriends[agent.p_type - 1] += len(agent.friends)
             self.personalityEnemies[agent.p_type - 1] += len(agent.enemies)
             
             friendsDistance = 0.0
             for friend in agent.friends:
                 friendsDistance += M.find_distance(agent, friend)
                 
             enemiesDistance = 0.0
             for enemy in agent.enemies:
                 enemiesDistance += M.find_distance(agent, enemy)
             
             if len(agent.friends) != 0:
                 self.personalityFriendsDistance[agent.p_type - 1] += friendsDistance / len(agent.friends)
             if len(agent.enemies) != 0:
                 self.personalityEnemiesDistance[agent.p_type - 1] += enemiesDistance / len(agent.enemies)
             
         self.personalityConnections = (N.array(self.personalityConnections) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityFriends = (N.array(self.personalityFriends) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityEnemies = (N.array(self.personalityEnemies) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityFriendsDistance = (N.array(self.personalityFriendsDistance) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.personalityEnemiesDistance = (N.array(self.personalityEnemiesDistance) / N.array(P.categoryNumOfPeople(agents))).tolist()
         self.updatePersonalityGraphs()
Example #3
0
 def test_AddRelationToOther(self):
     person1_number = 1
     person2_number = 2
     person1 = Person(person1_number, "G")
     person2 = Person(person2_number, "G")
     person1.SetRelationTo(person2, 10)
     self.assertEqual(person1.relations[person2], 10)
Example #4
0
    def __init__(self, Na, Nb, R, l, g, Uab, Uba):

        # Feed in parameters
        self.Na = Na
        self.Nb = Nb
        self.R = R
        self.l = l
        self.g = g
        self.Uab = Uab
        self.Uba = Uba
        self.utility_list = []

        self.Person_List = []  # list of people objects

        # Generate initial configuration
        index = 0
        # Initialize "a" people

        print "Initializing A people"
        for i in range(Na):
            Position = np.array(
                [0.5 * random.random(), random.random()], dtype=float)
            self.Person_List.append(Person.Person('a', Position, index))
            index += 1
        print "Initializing B people"
        # Initialize "b" people
        for i in range(Nb):
            Position = np.array([1 - 0.5 * random.random(),
                                 random.random()],
                                dtype=float)
            self.Person_List.append(Person.Person('b', Position, index))
            index += 1
        return
    def validate(self, a_string):
        list_ = Editor.string_to_list(a_string)

        id_ = list_[0]
        gender = list_[1]
        age = list_[2]
        sales = list_[3]
        bmi = list_[4]
        income = list_[5]

        while not DataValidator.has_valid_id(id_):
            id_ = IDValueHandler.set_new_value(id_)

        while not DataValidator.has_valid_gender(gender):
            gender = GenderValueHandler.set_new_value(gender)

        while not DataValidator.has_valid_age(age):
            age = AgeValueHandler.set_new_value(age)

        while not DataValidator.has_valid_sales(sales):
            sales = SalesValueHandler.set_new_value(sales)

        while not DataValidator.has_valid_bmi(bmi):
            bmi = BmiValueHandler.set_new_value(bmi)

        while not DataValidator.has_valid_income(income):
            income = IncomeValueHandler.set_new_value(income)

        p = Person(DataCleaner.clean_id(id_), DataCleaner.clean_gender(gender), DataCleaner.clean_age(age), DataCleaner.clean_sales(sales), DataCleaner.clean_bmi(bmi), DataCleaner.clean_income(income))

        self._good_data.update({p.get_id(): p})
        self._raw_data.remove(a_string)
Example #6
0
def fcfs_nearest_idle(av_fleet, customers, t):
    idle_avs = list(j_veh for j_veh in av_fleet
                    if j_veh.status in ("idle", "relocating"))
    unassign_cust = list(i_cust for i_cust in customers
                         if i_cust.status == "unassigned")

    used_vehicles = []
    count_p = -1
    for i_cust in unassign_cust:
        count_p += 1
        min_dist = Set.inf
        win_veh_index = -1
        veh_index = -1
        for j_av in idle_avs:
            veh_index += 1
            dist = Distance.dist_manhat_pick(i_cust, j_av)
            # make sure that two persons aren't assigned to same vehicle
            if dist < min_dist and not (j_av.vehicle_id in used_vehicles):
                win_veh_index = veh_index
                min_dist = dist
        if win_veh_index >= 0:
            win_vehicle = idle_avs[win_veh_index]
            used_vehicles.append(win_vehicle.vehicle_id)

            temp_veh_status = "base_assign"
            Vehicle.update_vehicle(t, i_cust, win_vehicle, Regions.SubArea,
                                   temp_veh_status)
            Person.update_person(t, i_cust, win_vehicle)
    return
Example #7
0
 def test_GetRelationToUnknownPersonError(self):
     person1_number = 1
     person2_number = 2
     person1 = Person(person1_number, "G")
     person2 = Person(person2_number, "G")
     self.assertRaises(InvalidPersonOperation, person1.GetRelationTo,
                       person2)
Example #8
0
 def test_feature_one(self):
     print("TC1 test")
     F = Family("Smith")
     F.addPerson(Person("Joseph", "joe", 1961))
     F.addPerson(Person("Mary", "mare", 1966))
     self.assertEqual(F.summaryString(), "Smith family")
     self.assertEqual(F.lastYear(), 2051)
Example #9
0
    def add_user(self, first_name, last_name, personal_number):
        new_person = Person.Person()
        new_person.first_name = first_name
        new_person.last_name = last_name
        new_person.personal_number = personal_number

        Person.Person().add_user(new_person)
Example #10
0
    def addPerson(self, position):
        person = PE.Person(PE.Position(position.x, position.y),
                           ID=self.increasingID)

        self.people.append(person)
        self.increasingID += 1

        V.Visualizer.sharedVisualizer.addNode(person)
Example #11
0
def addtoList(name, description, photo):
    newUser = Person(username=name, description=description, image=photo)

    print(newUser.getUsername())
    print(newUser.getDescription())
    print(newUser.getImage())
    userlist.append(newUser)
    print(userlist)
Example #12
0
 def test_GetRelationToOther(self):
     person1_number = 1
     person2_number = 2
     person2_relation = 10
     person1 = Person(person1_number, "G")
     person2 = Person(person2_number, "G")
     person1.SetRelationTo(person2, person2_relation)
     self.assertEqual(person1.GetRelationTo(person2), person2_relation)
Example #13
0
	def setUp (self) :
		""" sets up two people"""
		self.person1 = Person("Black Knight", -100)
		self.healthEffect = -5
		self.person2 = Person("Knights who say Ni", self.healthEffect)
		self.person3 = Person("King Arthur")
		self.healthEffect2 = -55
		self.person3.setHealthEffect (self.healthEffect2)
Example #14
0
 def test_AddUp(self):
     person_number1 = 1
     person_type1 = "G"
     person1 = Person(person_number1, person_type1)
     person_number2 = 2
     person_type2 = "G"
     person2 = Person(person_number2, person_type2)
     person1.SetUp(person2)
     self.assertEqual(person1.GetUp(), person2)
Example #15
0
 def test_Medical_addPerson_UnHealthy_moreThanAvailable(self):
     people = [Person.Person() for p in range(10)]
     for p in people:
         p.setHealthStatus(50)  # Sick
         self.m.addPerson(p)
     self.assertEqual(self.m.getAvailable(), 0, "Should have 0 available")
     p = Person.Person()
     p.setHealthStatus(50)  # Sick
     self.m.addPerson(p)
     self.assertEquals(len(self.m.getStatusReport()["standbyStatus"]), 1)
Example #16
0
 def users(cls):
     user_list = []
     cls.c.execute("SELECT * FROM users")
     fetcher = cls.c.fetchall()
     for i in fetcher:
         if i[4] == "admin" or i[0] == "Gipsz Jakab":
             user_list.append(Person.admin(i[0], i[1], i[2], i[3]))
         else:
             user_list.append(Person.Student(i[0], i[1], i[2], i[3]))
     return user_list
Example #17
0
	def test_verify_identity(self):
		self.name = "Marcelo"
		self.last_name = "Vargas"
		
		expected_result = "Hello, my name is" + name + last_name
		
		new_person = Person("Marcelo","Vargas")
		
		salute = new_person.return_salute()
		
		self.assertEqual(salute,expected_result,"Mensaje personalizado")
Example #18
0
def create_person():
    names = create_names()
    params = create_params()
    person = Person(*names, *params)
    persons.append(person)
    print(person)
    body_index = get_bmi(person.get_mass(), person.get_height())
    print(f'{person.get_name()}, Ваш индекс массы тела: '
          f'{round(body_index, 2)}')
    print_scale(body_index)
    recomendation(person)
Example #19
0
 def tests(self):
     m = Model()
     seattleperson = Person.Person(m, location=(-122, -48))
     newyorkperson = Person.Person(m, location=(-74, -40))
     jakartaperson = Person.Person(m, location=(107, 6))
     self.assertEquals(int(find_distance(seattleperson, newyorkperson)),
                       2409)
     self.assertEquals(int(find_distance(newyorkperson, jakartaperson)),
                       10092)
     self.assertEquals(int(find_distance(jakartaperson, seattleperson)),
                       8361)
     m.run_simulation()
Example #20
0
    def test_distance_calculator(self):
        seattleperson = Person.Person(self.m, location=(-122, -48))
        newyorkperson = Person.Person(self.m, location=(-74, -40))
        jakartaperson = Person.Person(self.m, location=(107, 6))
        self.assertEquals(
            int(Model.find_distance(seattleperson, newyorkperson)), 2409,
            "SEA->NYC != 2409")
        self.assertEquals(
            int(Model.find_distance(newyorkperson, jakartaperson)), 10092,
            "NYC->JKT != 10092")
        self.assertEquals(
            int(Model.find_distance(jakartaperson, seattleperson)), 8361,
            "JKT->SEA != 8361")

        # edge cases
        people = []
        people.append(Person.Person(self.m, location=(180, 90)))
        people.append(Person.Person(self.m, location=(-180, 90)))
        people.append(Person.Person(self.m, location=(180, -90)))
        people.append(Person.Person(self.m, location=(-180, -90)))
        people.append(Person.Person(self.m, location=(0, 0)))
        for person in people:
            for person2 in people:
                self.m.logger.log(
                    5, "TestDistance: %r to %r = %r" %
                    (person, person2, Model.find_distance(person, person2)))
def testSetters():
    A = Person("A", "B")
    A.setFirstName("ralph")
    assert A.getFirstName() == "ralph"

    A.setLastName("jones")
    assert A.getLastName() == "jones"
Example #22
0
 def alterar(id, nome, endereco, telefone):
     while True:
         try:
             person = Person()
             person.setId(id)
             person.setName(nome)
             person.setAddress(endereco)
             person.setPhone(telefone)
             socket.setdefaulttimeout(5)
             updatePerson(person, db)
             socket.setdefaulttimeout(None)
             return True
         except Exception as ex:
             raise Exception("Erro ao alterar contato: " + str(ex))
             db.cursor().execute("ROLLBACK;")
Example #23
0
 def create_tree(self):
     familyTree = []
     for individual in self.csvReader:
         familyTree.append(Person(*individual))
     self.link_parents(familyTree)
     self.link_children(familyTree)
     return familyTree
Example #24
0
def create_persons():
    aux = []
    for _ in progressbar(range(50), 'Persons'):
        data = get_person()
        obj = Person(**data)
        aux.append(obj)
    Person.objects.bulk_create(aux)
 def people_tracking(self, rects):
     global pid
     global entered
     global exited
     for x, y, w, h in rects:
         new = True
         xCenter = x + w / 2
         yCenter = y + h / 2
         inActiveZone = xCenter in range(self.rangeLeft, self.rangeRight)
         for index, p in enumerate(persons):
             dist = math.sqrt((xCenter - p.getX())**2 +
                              (yCenter - p.getY())**2)
             if dist <= w / 2 and dist <= h / 2:
                 if inActiveZone:
                     new = False
                     if p.getX() < self.midLine and xCenter >= self.midLine:
                         print("[INFO] person going left " + str(p.getId()))
                         entered += 1
                     if p.getX() > self.midLine and xCenter <= self.midLine:
                         print("[INFO] person going right " +
                               str(p.getId()))
                         exited += 1
                     p.updateCoords(xCenter, yCenter)
                     break
                 else:
                     print("[INFO] person removed " + str(p.getId()))
                     persons.pop(index)
         if new == True and inActiveZone:
             print("[INFO] new person " + str(pid))
             p = Person.Person(pid, xCenter, yCenter)
             persons.append(p)
             pid += 1
Example #26
0
 def testGetRealName(self):
     '''Prueba unitaria para getRealName.'''
     self.person11 = Person.Person("Katy Perry")
     self.assertEqual("", self.person11.getRealName())
     self.person11.setRealName("Katheryn Elizabeth Hudson")
     self.assertEqual("Katheryn Elizabeth Hudson",
                      self.person11.getRealName())
Example #27
0
def swap(a, b):
    c = Person()
    c = a
    a = b
    b = c
    del c
    return a, b
Example #28
0
 def testGetDeathDate(self):
     '''Prueba unitaria para getDeathDate.'''
     self.person13 = Person.Person("John Lennon")
     self.assertEqual("", self.person13.getDeathDate())
     self.person13.setDeathDate("8 de diciembre de 1980")
     self.assertEqual("8 de diciembre de 1980",
                      self.person13.getDeathDate())
Example #29
0
def read():
    reading = True
    while reading:
        query = input('Search for NAME or PID: ').lower()
        if query == 'name' or query == 'pid':
            uinput = input('Type the {}: '.format(query)).lower()
            conn = sqlite3.connect('person.db')
            c = conn.cursor()
            c.execute('SELECT * FROM person WHERE {} = "{}"'.format(
                query, uinput))
            p = c.fetchone()

            if p:
                print('\n')
                person = Person.Person(p[0], p[1], p[2], p[3], p[4])
                print(person)

                clip.copy(str(person))

                conn.close()
                reading = False

            else:
                print('Entry not found in database')
                prompt = input('Do you want to try again? y/n: ')
                if prompt == 'n':
                    reading = False

        else:
            print('You should type NAME or PID.')
            prompt = input('Do you want to try again? y/n: ')
            if prompt == 'n':
                reading = False
 def __init__(self):
     dict_path = os.path.split(
         os.path.realpath(__file__))[0] + "/people.dict"
     reload(sys)
     sys.setdefaultencoding('utf-8')
     self.pd = re.compile(
         u'(\d{4}(\-|\/|\.|年)\d{1,2}(\-|\/|\.|月)\d{1,2}日?|\d{4}(\-|\/|\.|年)\d{1,2}月?|\d{1,2}(\-|\/|\.|月)\d{1,2}日?|\d{1,4}年|\d{1,2}月|\d{1,2}日|\d{1,4}年代|\d{4}(0[1-9]|10|11|12)(([0-2][0-9])|30|31)|\d{1,2}点\d{1,2}分|\d{1,2}点|\d{1,2}分|\d{1,2}:\d{1,2}|\d{1,3}岁|\d{1}\.\d{1,2}(M|m|米)|\d{2,3}(CM|Cm|cm|厘米|公分)|\d{1,2}(kg|KG|Kg|千克|公斤)|[a-zA-Z]+)'
     )
     self.time = re.compile(
         u'\d{1,2}点\d{1,2}分|\d{1,2}:\d{1,2}|\d{1,2}点|\d{1,2}分')
     self.date = re.compile(
         u'(\d{4}(\-|\/|\.|年)\d{1,2}(\-|\/|\.|月)\d{1,2}日?|\d{4}(\-|\/|\.|年)\d{1,2}月?|\d{1,2}(\-|\/|\.|月)\d{1,2}日?|\d{1,4}年|\d{1,2}月|\d{1,2}日|\d{1,4}年代|\d{4}(0[1-9]|10|11|12)(([0-2][0-9])|30|31))'
     )
     self.digit = re.compile(u'\d+')
     self.eng_word = re.compile(u'[a-zA-Z]+')
     self.age = re.compile(u'\d{1,3}岁')
     self.height = re.compile(
         u'\d{1}\.\d{1,2}(M|m|米)|\d{2,3}(CM|Cm|cm|厘米|公分)')
     self.weight = re.compile(u'\d{1,2}(kg|KG|Kg|千克|公斤)')
     self.ner_mark = re.compile(u'__@@@\w+@@@__')
     self.ner1 = re.compile(u'__@@@')
     self.ner2 = re.compile(u'@@@__')
     self.pseg = jieba.posseg
     f = open(dict_path)
     self.ner_dict = {}
     import Person
     self.person = Person.Person()
     for line in f:
         data = line.split('\t')
         self.ner_dict[unicode(data[0].strip(), 'utf8')] = data[1].strip()
         self.pseg.add_word(data[0].strip())
     f.close()
Example #31
0
 def testSetRealName(self):
     '''Prueba unitaria para setRealName.'''
     self.person2 = Person.Person("Gareth Emery")
     self.assertEqual("", self.person2.getRealName())
     self.person2.setRealName("Gareth Thomas Rhys Emery")
     self.assertEqual("Gareth Thomas Rhys Emery",
                      self.person2.getRealName())
Example #32
0
def main():
    # Local variables
    name = ''
    address = ''
    phone_number = ''
    cust_number = 0
    on_list_flag = False

    # Get Customer Information
    name = input("Enter the Customer's name: ")
    address = input("Enter the Customer's address: ")
    phone_number = input("Enter the Customer's phone number: ")
    cust_number = input("Enter the Customer's ID number: ")
    on_list = input("Does the Customer wish to be on the mailing list?" +
                    "\nEnter Yes or No: ")

    if on_list == 'Yes':
        on_list_flag = True
    else:
        on_list_flag = False

    customer = Person.Customer(name, address, phone_number, cust_number,
                               on_list_flag)

    # Display Customer Information
    print('\nCustomer Information: ')
    print('Name: ' + customer.get_name())
    print('Address: ' + customer.get_address())
    print('Customer Number: ' + customer.get_cust_number())
    print('On List: ' + str(customer.get_on_list()))
Example #33
0
    def initialize_state(self):
        '''
		-> self (self)
		<- None
		Place the initial conditions of the magazine
		'''

        #unpack variables
        size = self.size
        margin = self.margin

        #place objects
        self.place_objects()

        #place people
        n_pe = self.N
        people = self.people
        for i in range(n_pe):

            position = (self.size - 19) * np.random.rand(2) + 10
            r = random.random() * 2 * np.pi
            direction = np.array([np.sin(r), np.cos(r)])

            info = Info(position, direction)
            people.append(Person(info))
        self.calculate_way_to_exit()
Example #34
0
    def validate(self, a_string):
        list_ = Validator.clean_input(a_string)

        id_ = list_[0]
        if len(list_) > 1:
            gender = list_[1]
        else:
            gender = ""
        if len(list_) > 2:
            age = list_[2]
        else:
            age = ""
        if len(list_) > 3:
            sales = list_[3]
        else:
            sales = ""
        if len(list_) > 4:
            bmi = list_[4]
        else:
            bmi = ""
        if len(list_) > 5:
            income = list_[5]
        else:
            income = ""

        while not Validator.has_valid_id(id_):
            id_ = Validator.clean_id(self.set_new_value(id_, "A123", "id"))

        while not Validator.has_valid_gender(gender):
            gender = Validator.clean_gender(self.set_new_value(gender, "M", "gender"))

        while not Validator.has_valid_age(age):
            age = Validator.clean_age(self.set_new_value(age, "01", "age"))

        while not Validator.has_valid_sales(sales):
            sales = Validator.clean_sales(self.set_new_value(sales, "001", "sales"))

        while not Validator.has_valid_bmi(bmi):
            bmi = Validator.clean_bmi(self.set_new_value(bmi, "Normal, Overweight, Obesity, Underweight", "bmi"))

        while not Validator.has_valid_income(income):
            income = Validator.clean_income(self.set_new_value(income, "00-100", "income"))

        p = Person(Validator.clean_id(id_), Validator.clean_gender(gender), Validator.clean_age(age), Validator.clean_sales(sales), Validator.clean_bmi(bmi), Validator.clean_income(income))

        self._good_data.update({p.get_id(): p})
        self._raw_data.remove(a_string)
Example #35
0
def testSetters():
    A = Person("A","B")
    A.setFirstName("ralph")
    assert A.getFirstName()=="ralph"
    
    A.setLastName("jones")
    assert A.getLastName()=="jones"
 def run_analysis(self):
     self.run_the_analysis= True
     print "run analysis"
     while self.run_the_analysis:
         images_data_file = open("images_data")
         face_number=0
         face_data =[]
         #wyszukuje linii definiujacych osobe
         for line in images_data_file:
             if(line.find("face")!=-1):
                 try:
                     face_number = eval(line[4:5].strip())   # zamienic na TRY bo sie czasem pierdoli
                     f_rect = eval(line.split(":")[1].strip())
                     face_data.append(face_number)
                     face_data.append(f_rect)
                 except:
                     break
             if(line.find("NOSE:")!=-1):
                 try:
                     nose_rect = eval(line.split(":")[1].strip())
                     face_data.append(nose_rect)
                 except:
                     break
             if(line.find("POINTS:")!=-1): 
                 try:
                     points_rect = eval(line.split(":")[1].strip())
                     face_data.append(points_rect)
                 except:
                     break
                 new_person = Person(face_data,  self.sectors,   self.white_level, self.note_file_url)
                 face_data =[]
                 #jak nadaje sie do analizy to tworze nowa osobe
                 if new_person.is_person_created():
                     print "twarz ",  face_number,  " nadaje sie do analizy"
                     person_class = self.is_a_new_person(new_person)
                     if person_class[0]:
                         print "to byla nowa osoba, dodalem ja"
                     else:
                         print "juz widzialem ta osobe, to byla osoba", person_class[1]," updatuje ja"
                         self.room.people_list[person_class[1]]=new_person
                 else:
                     print "osoba nie stworzona"
         images_data_file.close()
         time.sleep(self.sleep_period_value)
Example #37
0
def run(_name, _type, _excl, _genres, runtime):
	# API key, content url constants
	tmdb_key = "e6e136a71855baad76ee2360bac5595f"
	tmdb     = "http://api.themoviedb.org/3/"
	omdb     = 'http://www.omdbapi.com/'

	# Only two options for selection
	if _type != 'd' and _type != 'a':
		print "Must enter either \'a\' for actor or \'d\' for director."
		sys.exit()

	# Two inputs
	t = ''
	if _type == 'a':
		t = 'with_cast' 
	if _type == 'd':
		t = 'with_crew' 

	person = Person(_name, t)
	if person.get_person_ID(_name, tmdb, tmdb_key) == 0:
		return json.dumps({
			'Error': 1,
			'Person': person.name
		})

	# Get hash of person's coworkers and their collaborative work
	person.discover_person(tmdb, tmdb_key)
	films = []
	for movie in person.movies:
		films.append(find_ratings(movie['title'], omdb))
	
	films = filterByCriteria(films, _excl, _genres, runtime)

	return json.dumps({
		'Person': person.name,
		'Type': 'Director' if _type == 'd' else 'Actor',
		'Films': films,
		'Error': 0
	})
Example #38
0
    def post(self) :

        User = users.get_current_user()

        PERSON = Person.UserExists( User )
        if( PERSON != None ) :
            #Edit existing User
            PERSON.Prefix = self.request.get('Prefix')
            PERSON.FirstName = self.request.get('FirstName')
            PERSON.LastName = self.request.get('LastName')
            PERSON.Email = db.Email( self.request.get('Email') )
            PERSON.Contact = db.PhoneNumber( "(" + filter(lambda x: x.isdigit() , self.request.get('CountryCode')) + ") " +
                                            self.request.get('Contact') )
            PERSON.Profile = db.Text( self.request.get('Profile') )

        else :
            #Add the new User
            PERSON = Person( 
                             USER = users.get_current_user() ,
                             Prefix = self.request.get('Prefix'),
                             FirstName = self.request.get('FirstName'),
                             LastName = self.request.get('LastName'),
                             Email = db.Email( self.request.get('Email') ),
                             Contact = db.PhoneNumber( "(" + filter(lambda x: x.isdigit() , self.request.get('CountryCode')) + ") " +
                                                      self.request.get('Contact') ),
                             Profile = db.Text( self.request.get('Profile') ),
                           )

        ProfilePic = self.request.get('ProfilePic')

        if( ProfilePic != "" ) :
            PERSON.Picture = db.Blob( ProfilePic )
        
        PERSON.put()

        #Redirect to the home page
        self.redirect("/")
Example #39
0
def setup(): 
	count  = 0
	inTest = 0
	inTrain = 0
	L = glob.glob('Data/*')
	for nextFile in L: #check each text file within Data
			
		text = open(nextFile, 'r')

		for line in text:
			newPerson = Person()       #new person object		

			if (nextFile == 'Data\\test.txt'):
				newPerson.test = True
				newPerson.train = False
				Person.testPeople += 1
			elif (nextFile == "Data\\training.txt"):
				newPerson.test = False
				newPerson.train = True
				Person.trainingPeople += 1
			else: 
				print 'test/train error'
				
			line = line.lower().rstrip()
			line = ''.join([char.strip('.') for char in line])
			if('?' in line): 
				newPerson.use = False
				count +=1
			
			attributes = line.split(',')
			
			newPerson.describePerson(attributes)
			if((newPerson.use == True) and ( newPerson.test == True)):
			        inTest +=1
			elif((newPerson.use == True) and (newPerson.train == True)):
			        inTrain +=1
			
			Person.totalPeople += 1
			
			Person.allPeople.append(newPerson) #add paper to list of paper objects
		text.close()
		
	check(count, inTest, inTrain)
	def read_file(self):
		df = read_csv(self.in_file, skipinitialspace=True, true_values=[' Yes', 'Yes', 'Free', ' Free'], false_values=['No', ' No', 'Busy', ' Busy', ''])

		rows = map(list, df.values)
		num_ppl = len(rows)
		col_names = []
		shift_counter = 0
		first_shift_idx = len(rows)
		for i in range(len(df.columns)):
		    col_names.append(df.columns[i])
		    if df.columns[i].startswith('['):
		        if i < first_shift_idx:
		            first_shift_idx = i
		        # Create shift constraint
		        shift = Shift(shift_counter)
		        # Parse and add details
		        title = df.columns[i]
		        shift.set_str(title.strip('[]'))
		        a = title.strip('[]').split('(')
		       	if len(a) > 1:
			        shift_name = a[0][:-1]
			        shift_time = a[1].strip(')')
			        shift_start = shift_time.split(' - ')[0]
			        shift_end = shift_time.split(' - ')[1]
			        # set details
			        shift.set_name(shift_name)
			        shift.set_start(shift_start)
			        shift.set_end(shift_end)
		        self.shifts.append(shift)
		        shift_counter = shift_counter + 1
		        
		for row in rows:
		    p = Person()
		    # Add all attributes to Person object    
		    for j in range(1, first_shift_idx):
		        p.add_attribute(col_names[j], row[j])
		    # Add name attribute
		    p.add_name()

		    # List of available times
		    availability = row[first_shift_idx:]
		    for k in range(len(availability)):
		        if availability[k] == False:
		            p.add_constraint(self.shifts[k])
		    self.all_people.append(p)
Example #41
0
    def parseFile(self, filename):
        file = open(filename)

        dataFile = csv.reader(file)

        data = [line for line in dataFile]
        data = data[1:]

        #make person
        for row in data:
            name = row[0]
            person = Person(name)
            person.gender = row[1]
            person.conflictDates = row[2].split(",")
            person.experience = row[3]
            conflictServices = row[4].split(",")
            if "Large Group" in conflictServices:
                person.largeGroup = False
            if "9:30" in conflictServices:
                person.nineThirty = False
            if "12:30" in conflictServices:
                person.twelveThirty = False
            person.car = row[5]
            data.append(person)
Example #42
0
def personMenuItem__on_click():
    Person.launch()
Example #43
0
	def setUp( self ):
		self.p = Person()
Example #44
0
class testPerson( unittest.TestCase ):
	def setUp( self ):
		self.p = Person()
	def test_Person_getHealthStatus( self ):
		self.assertEqual( self.p.getHealthStatus(), 100, "Health should be 100")
	def test_Person_getMass( self ):
		self.p.setMass( 113 )
		self.assertEqual( self.p.getMass(), 113 )
	
	def test_Person_setHealthStatus( self ):
		self.p.setHealthStatus( 50 )
		self.assertEqual( self.p.getHealthStatus(), 50, "Health should be about 50" )
		self.p.setHealthStatus( 0 )
		self.assertEqual( self.p.getHealthStatus(), 0, "Health should be about 0" )
		self.assertRaises( ValueError, self.p.setHealthStatus, -1 )
		self.assertRaises( ValueError, self.p.setHealthStatus, 101 )
	def test_Person_raiseHealthStatus( self ):
		self.p.setHealthStatus( 50 )
		self.p.raiseHealthStatus()
		self.assertEquals( self.p.getHealthStatus(), 51 )
	def test_Person_lowerHealthStatus( self ):
		self.p.setHealthStatus( 50 )
		self.p.lowerHealthStatus()
		self.assertEquals( self.p.getHealthStatus(), 49 )
	def test_Person_setName( self ):
		self.p.setName( "Bob" )
	def test_Person_getName( self ):
		self.p.setName( "Fred" )
		self.assertEquals( self.p.getName(), "Fred" )
	def test_Person_Display( self ):
		self.p.setName( "Dave" )
		self.assertEquals( str( self.p ), "Dave" )
	def test_Person_2People( self ):
		self.p2 = Person()
		self.p2.setHealthStatus( 50 )
		self.assertEqual( self.p2.getHealthStatus(), 50 )
		self.assertEqual( self.p.getHealthStatus(), 100 )
	def test_Person_healthStatusFalls_Accelerated( self ):
		import time
		self.p.setFailInterval( 1 )
		self.p.tick()
		time.sleep(1)
		self.p.tick()
		self.assertEqual( self.p.healthStatus, 99 )
		self.assertEqual( self.p.functionalStatus, 100 )
	def test_Person_functionalStatusFalls_Accelerated( self ):
		import time
		self.p.setFailInterval( 1 )
		self.p.setHealthStatus( 60 )
		self.p.tick()
		time.sleep(1)
		self.p.tick()
		self.assertEqual( self.p.healthStatus, 59 )
		self.assertEqual( self.p.functionalStatus, 99 )
	def test_Person_healthStatusRaisesIfSleeping_Accelerated( self ):
		import time
		self.p.setFailInterval( 1 )
		self.p.setHealthStatus( 50 )
		self.p.isSleeping = True
		self.p.tick()
		time.sleep(1)
		self.p.tick()
		self.assertEqual( self.p.healthStatus, 52 )
		self.assertEqual( self.p.functionalStatus, 99 )
	def test_Person_functionalStatusRaises_Accelerated( self ):
		import time
		self.p.setFailInterval( 1 )
		self.p.setHealthStatus( 82 )
		self.p.setFunctionalStatus( 50 )
		self.p.tick()
		time.sleep(1)
		self.p.tick()
		self.assertEqual( self.p.healthStatus, 81 )
		self.assertEqual( self.p.functionalStatus, 51 )
	def test_Person_24hCycle_Accelerated( self ):
		""" 24h cycle at 30 minutes can be simmed in 48s """
		import time
		self.p.setFailInterval( 1 )
		self.p.setHealthStatus( 96 )
		self.assertEqual( self.p.healthStatus, 96 )
		self.assertEqual( self.p.functionalStatus, 100 )
		
		self.p.tick()
		self.p.raiseHealthStatus(3)    # breakfast
		#	self.p.eatMeal()
		time.sleep( 1 )    # 30 minute breakfast
		self.p.tick()
		self.p.isWorking = True
		for lcv in range(8):	# 4 hour shift
			time.sleep( 1 )
			self.p.tick()
		self.p.isWorking = False
		self.p.raiseHealthStatus(3)    # lunch
		for lcv in range(2):    # 1 hour lunch
			time.sleep( 1 )
			self.p.tick()
		self.p.isWorking = True
		for lcv in range(8):	# 4 hour shift
			time.sleep( 1 )
			self.p.tick()
		self.p.isWorking = False
		self.p.raiseHealthStatus(5)    # dinner
		for lcv in range(2):    # 1 hour dinner
			time.sleep( 1 )
			self.p.tick()
		for lcv in range(11):    # 5.5 hour rest time
			time.sleep( 1 )
			self.p.tick()
		self.p.isSleeping = True
		for lcv in range(16):    # 8 hour sleep
			time.sleep( 1 )
			self.p.tick()
		self.p.isSleeping = False
		
		#	self.p.eatMeal()
		self.assertEqual( self.p.healthStatus, 91 )
		self.assertEqual( self.p.functionalStatus, 100 )
		
		
	def test_Person_tick( self ):
		self.p.tick()
Example #45
0
class testPerson(unittest.TestCase) :
	
	def setUp (self) :
		""" sets up two people"""
		
		self.person1 = Person("Black Knight", -100)
		self.healthEffect = -5
		self.person2 = Person("Knights who say Ni", self.healthEffect)
		self.person3 = Person("King Arthur")
		self.healthEffect2 = -55
		self.person3.setHealthEffect (self.healthEffect2)


	def test_UpdateHealthAt0 (self) :
		"""tests that updating the health of person works correctly"""
		
		self.person2.updateHealth ()
		self.assertEqual(self.person2.getHealth(), \
		100 + self.healthEffect)
	
	def test_UpdateHealthLessThan0 (self) :
		"""tests that updating the health of person works correctly"""
		
		self.person3.updateHealth ()
		self.assertEqual(self.person3.getHealth(), \
		100 + self.healthEffect2)
		self.person3.updateHealth ()
		self.assertEqual(self.person3.getHealth(), 0)
		
	def test_DeadPersonTrue (self) :
		""" tests that checking if a person is dead works correctly"""
		
		self.person1.updateHealth ()
		self.assertEqual(self.person1.getHealth(), 0)
		self.assertTrue(self.person1.DeadPerson())
		
	def test_DeadPersonFalse (self) :
		""" tests that checking if a person is dead works correctly"""
		
		self.person1.updateHealth ()
		self.assertFalse(self.person2.DeadPerson())
Example #46
0
			
		group_ant = nodesSchedule[i][1]
	contacts.sort(key=lambda x: x[2])
	for i in range(len(contacts)):
		if contacts[i][3] > 0:
			f.write(str(contacts[i][0])+" "+str(contacts[i][1])+" "+str(contacts[i][2])+" "+str(contacts[i][3])+"\n")
	f.close()


#socialGraph = soc.generateGaussian(1200,100, 20,0.5,0.002);
#socialGraph = soc.generateGaussian(1200,20, 10,0.7,0.05);
socialGraph = soc.readSocialGraph("../../mestrado/datasets2/dartmouth/1200_sample.csv",1200, 1*3600)
print("Social Graph Generated")
groups = gs.defineGroups(1199,10,socialGraph)
print("Groups Defined")
nodesSchedule = per.allNodesSchedule(1200,groups)
print("Nodes Schedule Defined")
generateContacts(nodesSchedule)
for i in range(3,20):
	for j in range (2,12):
		print("Contacts Generated")
		G = soc.readSocialGraph("contacts.csv",1200, j*3600)
		print("Reading Contacts")
		soc.plotUnweightedCommunities(G, i, 1200,j)
		print("w,k:")
		print(i,j)
		print("Ploting Communities in Synthetic Graph")



Example #47
0
 def __init__(self, name, age, gender, mood, greeting, farewell):
     Person.__init__(self, name, age, gender, "Customer", mood)
     self.greeting = greeting
     self.farewell = farewell
Example #48
0
def testConstructor():
    A = Person("joe","smith")
    assert A.getFirstName()=="joe"
    assert A.getLastName()=="smith"
Example #49
0
pygame.key.set_repeat(1,1)
pygame.mixer.music.load("music.mp3")
pygame.mixer.music.play(-1)
screen = pygame.display.set_mode((800,600))
background = pygame.Surface((800,600))
points=0
timeleft=60
maxcoins=5
ctime=0
defeat=False
victory=False
grass = Ground()
grass.draw(background)
money=Coins()
changedrecs = []
guy = Person(50,50)
guy.cinterval=5000
guy.cs=0
guy.maxcs=5
pyramid=Pyramid(650,30)
pbase=Base(650,88)
#oldman= OldMan(random.randint(0,783),random.randint(0,577))
oldman = OldMan(100,200)
clerk = Clerk(200,100)
collector= Collector(200,200)
runner= Runner(400,400)
font = pygame.font.Font(None, 36)
text = font.render("Money: "+str(guy.cs), 1, (10, 10, 10))
peoplelist=[oldman,clerk,collector,runner]
blist=[pbase]
while True:
Example #50
0
 def __init__(self, name, age, gender, mood, speed):
     Person.__init__(self, name, age, gender, "Cook", mood)
     self.speed = speed
Example #51
0
	def __init__(self,name,email,phone,dept,company):
		Person.__init__(self,name)
		self.email=email
		self.phone=phone
		self.dept=dept
		self.company=company
Example #52
0
	def __init__(self, id):
		Person.__init__(self, name, age)					# call the parent constructor
		self.id = id
Example #53
0
def main():

	# Setup stuff such as getting the surface and starting the engine
	pygame.init()
	DISPLAYSURF = pygame.display.set_mode((600, 600))
	pygame.display.set_caption('Hero of Greece') # Title
	DISPLAYSURF.fill(WHITE)
	people2 = {}
	allSprites  = {}

	#Loading up NPC's images
	hydraPic = [pygame.image.load('hydra.png'), pygame.image.load('hydra.png'), pygame.image.load('hydra.png')]
	npcL = [pygame.image.load('npc_left.png'), pygame.image.load('npc_left_L.png'), pygame.image.load('npc_left_R.png')]
	npcR = [pygame.image.load('npc_right.png'), pygame.image.load('npc_right_L.png'), pygame.image.load('npc_right_R.png')]
	npcU = [pygame.image.load('npc_up.png'), pygame.image.load('npc_up_L.png'), pygame.image.load('npc_up_R.png')]
	npcD = [pygame.image.load('npc_down.png'), pygame.image.load('npc_down_L.png'), pygame.image.load('npc_down_R.png')]

	npc2L = [pygame.image.load('npc2_left.png'), pygame.image.load('npc2_left_L.png'), pygame.image.load('npc2_left_R.png')]
	npc2R = [pygame.image.load('npc2_right.png'), pygame.image.load('npc2_right_L.png'), pygame.image.load('npc2_right_R.png')]
	npc2U = [pygame.image.load('npc2_up.png'), pygame.image.load('npc2_up_L.png'), pygame.image.load('npc2_up_R.png')]
	npc2D = [pygame.image.load('npc2_down.png'), pygame.image.load('npc2_down_L.png'), pygame.image.load('npc2_down_R.png')]

	farmerL = [pygame.image.load('helot_farmer_left.png'), pygame.image.load('helot_farmer_left_L.png'), pygame.image.load('helot_farmer_left_R.png')]
	farmerR = [pygame.image.load('helot_farmer_right.png'), pygame.image.load('helot_farmer_right_L.png'), pygame.image.load('npc_right_R.png')]
	farmerU = [pygame.image.load('helot_farmer_up.png'), pygame.image.load('helot_farmer_up_L.png'), pygame.image.load('helot_farmer_up_R.png')]
	farmerD = [pygame.image.load('helot_farmer.png'), pygame.image.load('helot_farmer_down_L.png'), pygame.image.load('helot_farmer_down_R.png')]

	soldierL = [pygame.image.load('Soldier_left.png'), pygame.image.load('Soldier_left_L.png'), pygame.image.load('Soldier_left_R.png')]
	soldierR = [pygame.image.load('Soldier_right.png'), pygame.image.load('Soldier_right_L.png'), pygame.image.load('Soldier_right_R.png')]
	soldierU = [pygame.image.load('Soldier_up.png'), pygame.image.load('Soldier_up_L.png'), pygame.image.load('Soldier_up_R.png')]
	soldierD = [pygame.image.load('Soldier_down.png'), pygame.image.load('Soldier_down_L.png'), pygame.image.load('Soldier_down_R.png')]

	enemyL = [pygame.image.load('enemy_left.png'), pygame.image.load('enemy_left_L.png'), pygame.image.load('enemy_left_R.png')]
	enemyR = [pygame.image.load('enemy_right.png'), pygame.image.load('enemy_right_L.png'), pygame.image.load('enemy_right_R.png')]
	enemyD = [pygame.image.load('enemy_up.png'), pygame.image.load('enemy_up_L.png'), pygame.image.load('enemy_up_R.png')]
	enemyU = [pygame.image.load('enemy_down.png'), pygame.image.load('enemy_down_L.png'), pygame.image.load('enemy_down_R.png')]

	#scene one - eight buildings
	building1 = Building(210,50, (0,0))
	building2 = Building(150, 100, (0,50))
	building3 = Building(100, 140,(0,150))
	building4 = Building(155, 50, (0,545))
	building5 = Building(155,50,(445,545))
	building6 = Building(150,190,(445,0))
	building7 = Building(50, 50, (547,260))
	building8 = Building(50, 50, (400,90))
	building9 = Building(50,40, (400,0))

    #scene 9 buildings
	building91 = Building(405,360,(0,100))
	building92 = Building(100, 360, (495,100))

	#scene 10 buildings
	buildingS1 = Building(100, 130, (0,70))
	buildingS2 = Building(100,200,(150,0))
	buildingS3 = Building(205,80,(350,0))
	buildingS4 = Building(250,230,(0,255))
	buildingS5 = Building(105,120,(360,130))
	buildingS6 = Building(105,40,(360,315))
	buildingS7 = Building(85,80,(480,470))
	buildingS8 = Building(65,105,(530,250))

	#scene 2 buildings
	buildingA1 = Building(255, 100, (0,0))
	buildingA2 = Building(255, 75, (0,130))
	buildingA3 = Building(210, 45, (0,205))
	buildingA4 = Building(200, 75, (0,295))
	buildingA5 = Building(55, 130, (0,465))
	buildingA6 = Building(100, 130, (100,465))
	buildingA7 = Building(100, 45, (345,550))
	buildingA8 = Building(90, 100, (505,450))
	buildingA9 = Building(250, 55, (345,0))
	buildingA10 = Building(50, 300, (545,80))
	buildingA11 = Building(150, 130, (350,100))
	buildingA12 = Building(110, 140, (390,230))
	
    #people
	first = Hero(50, 50, (300,300))
	first.setSurface(DISPLAYSURF)
	second = Person((0,400), soldierL, soldierR, soldierU, soldierD)
	soldier1 = Person((0,400), soldierL, soldierR, soldierU, soldierD)
	soldier2 = Person((0,470), soldierL, soldierR, soldierU, soldierD)


	'''
	Important NPC's
	'''
	# The starting NPC's
	scaredW1 = Person((280,0), npcL, npcR, npcU, npcD)
	scaredM1 = Person((320,0), npc2L, npc2R, npc2U, npc2D)
	allSprites["scaredW1"] = scaredW1
	allSprites["scaredM1"] = scaredM1
	scene1People = {}
	scene1People["scaredW1"] = scaredW1
	scene1People["scaredM1"] = scaredM1
	scene1People["building1"] = building1
	scene1People["building2"] = building2
	scene1People["building3"] = building3
	scene1People["building4"] = building4
	scene1People["building5"] = building5
	scene1People["building6"] = building6
	scene1People["building7"] = building7
	scene1People["building8"] = building8
	scene1People["building9"] = building9

	Guard1 = Person((310,0), soldierL, soldierR, soldierU, soldierD)
	Guard2 = Person((260,0), soldierL, soldierR, soldierU, soldierD)
	Guard1.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	Guard1.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	Guard1.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	Guard2.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	Guard2.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	Guard2.addDialogue(Dialogue("You cannot pass until you have the people's favor. We need a true champion to fight the beast."))
	allSprites["Guard1"] = Guard1
	allSprites["Guard2"] = Guard2
	'''
	Useless NPC's just giving information about the city, they have five different responses based on you likability
	'''
	# Spartan People
	spartanW1 = Person((0, 245), npcL, npcR, npcU, npcD)
	spartanW1.addDialogue(Dialogue("Spartans are a people of honor, maybe you should understand that before entering this city"))
	spartanW1.addDialogue(Dialogue("You are a scum without honor, how dare you show your face here"))
	spartanW1.addDialogue(Dialogue("Hello fine warrior, I cannot believe that you are not a native spartan"))
	allSprites["spartanW1"] = spartanW1

	spartanM1 = Person((200, 500), npc2L, npc2R, npc2U, npc2D)
	spartanM1.addDialogue(Dialogue("Hmmm if only were you a more suitable fighter, Sparta would honor you as a hero."))
	spartanM1.addDialogue(Dialogue("You consider yourself a hero? More a coward than anything."))
	spartanM1.addDialogue(Dialogue("I speak for the rest of Sparta and I say that you are truly a hero!"))
	allSprites["spartanM1"] = spartanM1

	scene10People = {}
	scene10People['spartanW1'] = spartanW1
	scene10People['spartanM1'] = spartanM1
	scene10People['buildingS1'] = buildingS1
	scene10People['buildingS2'] = buildingS2
	scene10People['buildingS3'] = buildingS3
	scene10People['buildingS4'] = buildingS4
	scene10People['buildingS5'] = buildingS5
	scene10People['buildingS6'] = buildingS6
	scene10People['buildingS7'] = buildingS7
	scene10People['buildingS8'] = buildingS8

    #stuff for scene 9
	poorFarmer = Person((150, 150), farmerL, farmerR, farmerU, farmerD)
	poorFarmer.addDialogue(Dialogue("Thank you, maybe you are the Greece needs in order to destroy the Hydra"))
	allSprites['poorFarmer'] = poorFarmer
	scene9People = {}
	scene9People['building91'] = building91
	scene9People['building92'] = building92
	scene9People['poorFarmer'] = poorFarmer
	
	#stuff for scene 2
	scene2People = {}
	scene2People['buildingA1'] = buildingA1
	scene2People['buildingA2'] = buildingA2
	scene2People['buildingA3'] = buildingA3
	scene2People['buildingA4'] = buildingA4
	scene2People['buildingA5'] = buildingA5
	scene2People['buildingA6'] = buildingA6
	scene2People['buildingA7'] = buildingA7
	scene2People['buildingA8'] = buildingA8
	scene2People['buildingA9'] = buildingA9
	scene2People['buildingA10'] = buildingA10
	scene2People['buildingA11'] = buildingA11
	scene2People['buildingA12'] = buildingA12

	# Athens People
	athensW1 = Person((250, 250), npcL, npcR, npcU, npcD)
	athensW1.addDialogue(Dialogue("The blessed Athena believes justice should be settled by the people"))
	athensW1.addDialogue(Dialogue("You are a lawless monster, how dare you tarnish this city with your presence"))
	athensW1.addDialogue(Dialogue("You are truly the suymbol of justics, Athena blesses you"))
	allSprites["athensW1"] = athensW1

	athensM1 = Person((300, 400), npc2L, npc2R, npc2U, npc2D)
	athensM1.addDialogue(Dialogue("Killing people may satisfy one's vengeance but it does not cleanse the soul"))
	athensM1.addDialogue(Dialogue("Your anger consumes you. You must learn to control yourself before you fight the darkness"))
	athensM1.addDialogue(Dialogue("Your reputation precedes you, I believe you are the true hero of Athens. Do not lose sight of justice"))
	allSprites["athensM1"] = athensM1

	scene2People = {}
	scene2People["athensW1"] = athensW1
	scene2People["athensM1"] = athensM1
	#buildings for scene 2
	scene2People['buildingA1'] = buildingA1
	scene2People['buildingA2'] = buildingA2
	scene2People['buildingA3'] = buildingA3
	scene2People['buildingA4'] = buildingA4
	scene2People['buildingA5'] = buildingA5
	scene2People['buildingA6'] = buildingA6
	scene2People['buildingA7'] = buildingA7
	scene2People['buildingA8'] = buildingA8
	scene2People['buildingA9'] = buildingA9
	scene2People['buildingA10'] = buildingA10
	scene2People['buildingA11'] = buildingA11
	scene2People['buildingA12'] = buildingA12

	# Delphi People
	delphiW1 = Person((175, 445), npcL, npcR, npcU, npcD)
	delphiW1.addDialogue(Dialogue("There is a monster out there in the north, I wonder who can stop him"))
	delphiW1.addDialogue(Dialogue("I know you may be strong but I think you aren't fit to be a hero. Delphi will never vote for you"))
	delphiW1.addDialogue(Dialogue("Hurry save us hero"))
	allSprites["dephiW1"] = delphiW1

	oldManQuest = Person((480, 115), npc2L, npc2R, npc2U, npc2D)
	oldManQuest.addDialogue(Dialogue("I am a great philosopher and I have great deciples but one of them has went rogue and killed my son. Athenian law wants to stop him but I want to make sure he pays"))
	oldManQuest.addDialogue(Question("Will you exact my vengeance", ["Yes", "No"], ["LooseApprentence", "NoApprentence"]), True)
	allSprites["oldManQuest"] = oldManQuest

	delphiM1 = Person((215, 135), farmerL, farmerR, farmerU, farmerD)
	delphiM1.addDialogue(Dialogue("Many have left due to the attacks of the monsters, the cities are trying to determine who they should send. \
		Perhaps it would be ideal if all cities liked a single person but they are so divided"))
	delphiM1.addDialogue(Dialogue("I don't know what to say about Sparta and Athens but I know for sure that Delphi will never choose you as their hero with all your blasphehemy."))
	delphiM1.addDialogue(Dialogue("I hope you were able to get Sparta and Athens to choose you, because the city of Delphi adores you and your holy blade"))
	allSprites["dephiM1"] = delphiM1

	scene11People = {}
	scene11People["delphiW1"] = delphiW1
	scene11People["delphiM1"] = delphiM1
	scene11People["Guard1"] = Guard1
	scene11People["Guard2"] = Guard2
	scene11People["oldManQuest"] = oldManQuest
	#scene 11 buildings
	buildingD1 = Building(205, 85, (0,0))
	buildingD2 = Building(100, 95, (355,0))
	buildingD3 = Building(85, 95, (510,0))
	buildingD4 = Building(240, 75, (0,160))
	buildingD5 = Building(130, 105, (0,235))
	buildingD6 = Building(80, 75, (170,290))
	buildingD7 = Building(85, 200, (360,155))
	buildingD8 = Building(80, 200, (515,150))
	buildingD9 = Building(130, 125, (0,470))
	buildingD10 = Building(80, 125, (170,470))
	buildingD11 = Building(100, 125, (355,470))
	buildingD12 = Building(85, 105, (510,490))
	scene11People["buildingD1"] = buildingD1
	scene11People["buildingD2"] = buildingD2
	scene11People["buildingD3"] = buildingD3
	scene11People["buildingD4"] = buildingD4
	scene11People["buildingD5"] = buildingD5
	scene11People["buildingD6"] = buildingD6
	scene11People["buildingD7"] = buildingD7
	scene11People["buildingD8"] = buildingD8
	scene11People["buildingD9"] = buildingD9
	scene11People["buildingD10"] = buildingD10
	scene11People["buildingD11"] = buildingD11
	scene11People["buildingD12"] = buildingD12

	#Scene 7 enemies
	enemy1 = Enemy((200,300),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemy2 = Enemy((400,300),6, people2, enemyL, enemyR, enemyD, enemyU)
	soldier1Enemy = Enemy((0,0), 20, scene9People, soldierL, soldierR, soldierU, soldierD, 3)
	soldier2Enemy = Enemy((0,0), 20, scene9People, soldierL, soldierR, soldierU, soldierD)
	soldier3Enemy = Enemy((0,360), 10, {}, soldierL, soldierR, soldierU, soldierD,4)
	soldier4Enemy = Enemy((0,410), 16, {}, soldierL, soldierR, soldierU, soldierD,3)
	apprentence = Enemy((300, 300), 8, {},  npcL, npcR, npcU, npcD, 10)

	hydra = Enemy((300, 100), 40, {}, hydraPic, hydraPic, hydraPic, hydraPic, 12)
	boss = [hydra]

	allSprites['apprentence'] = apprentence
	allSprites['soldier1Enemy'] = soldier1Enemy
	allSprites['soldier2Enemy'] = soldier2Enemy
	allSprites['soldier3Enemy'] = soldier3Enemy
	allSprites['soldier4Enemy'] = soldier4Enemy
	enemies7 = [enemy1, enemy2]

        #scene 8 enemy
	enemy3 = Enemy((100,400),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemy8 = Enemy((300,200),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemies8 = [enemy3,enemy8]

	#scene 3 enemy
	enemy4 = Enemy((500,400),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemy7 = Enemy((300,200),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemies3 = [enemy4,enemy7]

	#scene 5 enemies
	enemy5 = Enemy((200,325),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemy6 = Enemy((100,400),6, people2, enemyL, enemyR, enemyD, enemyU)
	enemies5 = [enemy5, enemy6]

	# Add buildings for all the cities
	building = Building(80,80,(0,520))

	second.addDialogue(Dialogue("Will you help me?"))
	second.addDialogue(Question("Will you help?", ["Help", "Do not Help"], ["guyThanks", "guyHates"]), True)
	allSprites["guy"] = second
	allSprites["Hero"] = first
	allSprites["soldier1"] = soldier1
	allSprites["soldier2"] = soldier2


	people2["building1"] = building1
	people2["building2"] = building2
	people2["building3"] = building3
	people2["building4"] = building4
	people2["building5"] = building5
	people2["building6"] = building6
	people2["building7"] = building7
	people2["building8"] = building8
	people2["building9"] = building9


	#hero sprite is 25 pixels wide, 40 tall											
	scene1 = Scene(DISPLAYSURF, scene1People, first, background = pygame.image.load('midpoint.png').convert(), transition_points = {1:[250,350,0,0], 2:[0,0,365,465], 4:[575,600,365,465]}, entranceTrigger = "startScene")
	scene2 = Scene(DISPLAYSURF, scene2People, first, background = pygame.image.load('fran_athens_city.png').convert(), transition_points = {2:[0,0,365,465], 3:[250,350,560,600], 4:[575,600,365,465]})
	scene3 = Scene(DISPLAYSURF, {}, first, enemies3, background = pygame.image.load('rightbottomL.png').convert(), transition_points = {2:[0,0,365,465], 3:[250,350,560,600]})
	scene4 = Scene(DISPLAYSURF, {}, first, background = pygame.image.load('leftLroad.png').convert(), transition_points = {1:[250,350,0,0], 2:[0,0,365,465]}, entranceTrigger = "beginning")
	scene5 = Scene(DISPLAYSURF, people2, first, enemies5, background = pygame.image.load('rightLroad.png').convert(), transition_points = {1:[250,350,0,0], 4:[575,600,365,465]})
	#scene6 doesn't exist anymore, but left it there so we don't have to rename everything
	scene6 = Scene(DISPLAYSURF, people2, first)
	scene7 = Scene(DISPLAYSURF, people2, first, enemies7, background = pygame.image.load('leftLroad.png').convert(), transition_points = {1:[250,350,0,0], 2:[0,0,365,465]})
	scene8 = Scene(DISPLAYSURF, people2, first, enemies8, background = pygame.image.load('rightLroad.png').convert(), transition_points = {1:[250,350,0,0], 4:[575,600,365,465]})
	scene9 = Scene(DISPLAYSURF, scene9People, first, background = pygame.image.load('fran_sparta_helotfarm.png').convert(), transition_points = {3:[250,350,560,600], 4:[575,600,487,584]}, entranceTrigger = "poorFarmer")
	scene10= Scene(DISPLAYSURF, scene10People, first, background = pygame.image.load('fran_sparta_city.png').convert(), transition_points = {2:[0,0,487,584], 3:[250,350,560,600], 4:[575,600,365,465]})
	scene11= Scene(DISPLAYSURF, scene11People, first, background = pygame.image.load('fran_delphi_city.png').convert(), transition_points = {1:[250,350,0,0], 3:[250,350,560,600]})
	scene12= Scene(DISPLAYSURF, people2, first, boss, background = pygame.image.load('finalmonster_room_withopening.png').convert(), transition_points = {3:[250,350,560,600]})

	scenes_list = [scene1, scene2, scene3, scene4, scene5, scene6, scene7, scene8, scene9, scene10, scene11, scene12]

	theGame = Game(scenes_list, allSprites, DISPLAYSURF, first)

	current_scene = scenes_list[0]
	current_scene_num = 1
	current_hero_coords = (300,400)

	while True:
		#print(current_scene_num)
		state_of_current_scene, last_hero_coords = current_scene.run(current_hero_coords)
		if state_of_current_scene == "Dead":
			break
		if state_of_current_scene > 0:
			new_scene_num, current_hero_coords = getNextScene(current_scene_num, state_of_current_scene, last_hero_coords)
			current_scene_num = new_scene_num
			current_scene = scenes_list[new_scene_num-1]
	DISPLAYSURF.fill(WHITE)
	DISPLAYSURF.blit(pygame.font.Font(None, 22).render("You Lose", True, BLACK), (300, 300))
	pygame.display.update()
	pygame.time.wait(2000)
Example #54
0
File: Main.py Project: l2sega/OOP
# 3_Inheritance

from Person import* 
from House import*
from Programmer import*

person1 = Programmer("John", 23)
person2 = Person("Mike", 34)

house1 = House("1street")

house1.settle_person(person1)
house1.settle_person(person2)

person1.description_of_person() 
person2.description_of_person()

house1.description_of_house()



Example #55
0
File: Main.py Project: l2sega/OOP
# 4_encapsulation

from Person import*
from Programmer import*
from House import*

person = Person("John", 23)
sub_person = Programmer("Mike", 34)

person._test_protected_method()
person._Person__test_private_method()

sub_person._test_protected_method()
sub_person._Person__test_private_method()

person.test_public_method()



Example #56
0
 def __init__(self, name, age, gender, mood, money, isHungry, patience):
     Person.__init__(self, name , age, gender, "Customer", mood)
     self.money = money
     self.isHungry = isHungry
     self.patience = patience
Example #57
0
File: Main.py Project: l2sega/OOP
# 2_D_a_M

from Person import* 
from House import*

person1 = Person("John", 23)
person2 = Person("Mike", 34)

house1 = House("1street")

house1.settle_person(person1)
house1.settle_person(person2)

person1.description_of_person() 
person2.description_of_person()

house1.description_of_house()

#house1.evict_person(person1)
#house1.evict_person(person2)

person1.testClassMethod()
person1.testStaticMethod()

Person.testClassMethod()
Person.testStaticMethod()

Example #58
0
	def test_Person_2People( self ):
		self.p2 = Person()
		self.p2.setHealthStatus( 50 )
		self.assertEqual( self.p2.getHealthStatus(), 50 )
		self.assertEqual( self.p.getHealthStatus(), 100 )
Example #59
0
import Person
import Simulator
import sys


if __name__ == "__main__":

	if len(sys.argv)<2:
		print "Please specify Config file."
		exit(-1)
		
	config = sys.argv[1]
	people = Person.getResponders()
	print "Survey initiated" 
	for person in people:
		print person
		Simulator.take_survey(person, config)
		print "***************************************"
		
Example #60
0
 def __init__(self, name, age, gender, mood, speed):
     Person.__init__(self, name, age, gender, "announcer", mood)