Exemple #1
0
	def __init__(self, name, price, value, type, lxry_rtng, difficulty):
		'constructor'
		Gift.__init__(self, name, price, value, type)
		self.lxry_rtng = lxry_rtng
		'''@ivar: luxury rating of the luxury gift'''
		self.difficulty = difficulty
		'''@ivar: difficulty to obtain the luxury gift'''
 def __init__(self, name, price, value, type, utlty_value, utlty_class):
     'constructor'
     Gift.__init__(self, name, price, value, type)
     self.utlty_value = utlty_value
     '''@ivar: utility value of the utility gift'''
     self.utlty_class = utlty_class
     '''@ivar: utility class of the utility gift'''
def main():
    boys = open('./boys_list.csv')
    getBoy = csv.reader(boys, delimiter=',')

    girls = open('./girls_list.csv')
    getGirls = csv.reader(girls, delimiter=',')

    boy_list = []
    girl_list = []
    couple_list = []
    virtual_couple_list = []

    for i in getBoy:
        boy_list += [
            Boys(i[0], int(i[1]), int(i[2]), int(i[3]), int(i[4]), i[5])
        ]

    for i in getGirls:
        girl_list += [Girls(i[0], int(i[1]), int(i[2]), int(i[3]), i[4])]

    # Create gift list to be sent to happiness calculator
    with open('./gift_list.csv', 'r') as gift_file:
        gift_list = csv.reader(gift_file, delimiter=',')
        for row in gift_list:
            gifts = [Gift(row[0], int(row[1]), int(row[2]), row[3])]
        gift_file.close()

    gifts = sorted(gifts, key=lambda item: item.cost)

    for girl in girl_list:
        for boy in boy_list:
            # Create Log
            create_log(boy.name + ' is trying for ' + girl.name)
            if boy.status == 'Single' and girl.status == 'Single' and \
                    boy.check_eligibility(girl.maintenance_budget, girl.attractiveness):
                boy.gf = girl.name
                girl.bf = boy.name

                # Update relationship status
                boy.status = 'Committed'
                girl.status = 'Committed'

                text = girl.name + ' is in relationship with ' + boy.name
                print text
                # Create Log
                create_log(text)
                couple_list += [(girl, boy)]
                break

    for i in couple_list:
        # Create couples first to be sent to happiness calculator
        virtual_couple_list += [Couple(i[0], i[1])]

    print "Couples in relationship are : "
    for couple in virtual_couple_list:
        print couple.girl.name + " is in a relationship with " + couple.boy.name

    calc_happiness(virtual_couple_list, gifts)
def calculate_happiness(C):
    with open('Gifts.csv', 'r') as csvfile:
        read = reader(csvfile, delimiter=',')
        GFT = [Gift(row[0], int(row[1]), int(row[2]), row[3]) for row in read]
        csvfile.close()

    GFT = sorted(GFT, key=lambda k: k.price)
    info('Gifting')
    for c in C:
        if (c.boy.type == 'Miser'):
            happy_miser(GFT, c)

        if (c.boy.type == 'Generous'):
            happy_generous(GFT, c)

        if (c.boy.type == 'Geek'):
            happy_geek(GFT, c)

    print_gifts(C)
def calculate_happiness(C, G, B):
    with open('Gifts.csv', 'r') as csvfile:
        reader = csv.reader(csvfile, delimiter=',')
        GFT = [
            Gift(row[0], int(row[1]), int(row[2]), row[3]) for row in reader
        ]
        csvfile.close()

    GFT = sorted(GFT, key=lambda k: k.price)
    for c in C:
        if (c.boy.type == 'Miser'):
            happy_miser(GFT, c)

        if (c.boy.type == 'Generous'):
            happy_generous(GFT, c)

        if (c.boy.type == 'Geek'):
            happy_geek(GFT, c)

    #p is used for atleast k happy value of happiness.
    p = randint(1, 100)
    break_up(C, p, G, B)
def main():
    boys = open('./boys_list.csv')
    getBoy = csv.reader(boys, delimiter=',')

    girls = open('./girls_list.csv')
    getGirls = csv.reader(girls, delimiter=',')

    boy_list = []
    girl_list = []
    couple_list = []
    virtual_couple_list = []

    after_breakup_girl_list = []

    for i in getBoy:
        boy_list += [
            Boys(i[0], int(i[1]), int(i[2]), int(i[3]), int(i[4]), i[5])
        ]

    for i in getGirls:
        girl_list += [Girls(i[0], int(i[1]), int(i[2]), int(i[3]), i[4])]

    # Create gift list to be sent to happiness calculator
    with open('./gift_list.csv', 'r') as gift_file:
        gift_list = csv.reader(gift_file, delimiter=',')
        for row in gift_list:
            gifts = [Gift(row[0], int(row[1]), int(row[2]), row[3])]
        gift_file.close()

    gifts = sorted(gifts, key=lambda item: item.cost)

    for girl in girl_list:
        for boy in boy_list:
            # Create Log
            create_log(boy.name + ' is trying for ' + girl.name)
            if boy.status == 'Single' and girl.status == 'Single' and \
                    boy.check_eligibility(girl.maintenance_budget, girl.attractiveness):
                boy.gf = girl.name
                girl.bf = boy.name

                # Update relationship status
                boy.status = 'Committed'
                girl.status = 'Committed'

                text = girl.name + ' is in relationship with ' + boy.name
                print(text)
                # Create Log
                create_log(text)
                couple_list += [(girl, boy)]
                break

    for i in couple_list:
        # Create couples first to be sent to happiness calculator
        virtual_couple_list += [Couple(i[0], i[1])]

    print("Couples in relationship are : ")
    for couple in virtual_couple_list:
        print(couple.girl.name + " is in a relationship with " +
              couple.boy.name)

    calc_happiness(virtual_couple_list, gifts)

    for girl in girl_list:
        for i in range(0, 10):
            if girl == virtual_couple_list[i].girl:
                # Add the boy to girl's blacklist , thus removing any chance
                # of their matching up again
                girl.blacklist = virtual_couple_list[i].boy.name

                # Create the new list of girls after breakup
                after_breakup_girl_list.append(girl)

                # Remove them from couple list
                virtual_couple_list.remove(virtual_couple_list[i])

    # Now rerun the matchup loop after breakup
    for girl in after_breakup_girl_list:
        for boy in boy_list:
            # Create Log
            create_log(boy.name + ' is trying for ' + girl.name)
            if boy.status == 'Single' and girl.status == 'Single' and \
                    boy.check_eligibility(girl.maintenance_budget, girl.attractiveness):
                boy.gf = girl.name
                girl.bf = boy.name

                # Update relationship status
                boy.status = 'Committed'
                girl.status = 'Committed'

                text = girl.name + ' is in relationship with ' + boy.name
                print(text)
                # Create Log
                create_log(text)
                virtual_couple_list.append(Couple(girl, boy))
                break
def main():
    boys = open('./boys_list.csv')
    getBoy = csv.reader(boys, delimiter=',')

    girls = open('./girls_list.csv')
    getGirls = csv.reader(girls, delimiter=',')

    boy_list = []
    girl_list = []
    couple_list = []
    virtual_couple_list = []

    for i in getBoy:
        boy_list += [
            Boys(i[0], int(i[1]), int(i[2]), int(i[3]), int(i[4]), i[5])
        ]

    for i in getGirls:
        girl_list += [Girls(i[0], int(i[1]), int(i[2]), int(i[3]), i[4])]

    # Create gift list to be sent to happiness calculator
    with open('./gift_list.csv', 'r') as gift_file:
        gift_list = csv.reader(gift_file, delimiter=',')
        for row in gift_list:
            gifts = [Gift(row[0], int(row[1]), int(row[2]), row[3])]
        gift_file.close()

    gifts = sorted(gifts, key=lambda item: item.cost)

    for girl in girl_list:
        for boy in boy_list:
            # Create Log
            create_log(boy.name + ' is trying for ' + girl.name)
            if boy.status == 'Single' and girl.status == 'Single' and \
                    boy.check_eligibility(girl.maintenance_budget, girl.attractiveness):
                boy.gf = girl.name
                girl.bf = boy.name

                # Update relationship status
                boy.status = 'Committed'
                girl.status = 'Committed'

                text = girl.name + ' is in relationship with ' + boy.name
                print(text)
                # Create Log
                create_log(text)
                couple_list += [(girl, boy)]
                break

    for i in couple_list:
        # Create couples first to be sent to happiness calculator
        virtual_couple_list += [Couple(i[0], i[1])]

    print("Couples in relationship are : ")
    for couple in virtual_couple_list:
        print(couple.girl.name + " is in a relationship with " +
              couple.boy.name)

    calc_happiness(virtual_couple_list, gifts)

    virtual_couple_list = sorted(virtual_couple_list,
                                 key=lambda x: x.happiness,
                                 reverse=True)
    print('\n')
    print('10 most happy couple : ')
    for i in range(0, 10):
        print(virtual_couple_list[i].boy.name + " and " +
              virtual_couple_list[i].girl.name)
    print("\n")
    # print(virtual_couple_list[i].happiness)
    print('10 most compatible couple : ')

    virtual_couple_list = sorted(virtual_couple_list,
                                 key=lambda x: x.compatibility,
                                 reverse=True)
    for i in range(0, 10):
        print(virtual_couple_list[i].boy.name + ' and ' +
              virtual_couple_list[i].girl.name)

    print('The 1st day : ')
    for couple in virtual_couple_list:
        print(couple.boy.name + ' and ' + couple.girl.name)

    t = input()
    for i in range(0, t - 1):
        for couple in virtual_couple_list:
            if couple.happiness < t:
                couple.girl.status = 'Single'
                girl = couple.girl
                for boy in boy_list:
                    create_log(girl.name + ' is looking guy ' + boy.name)
                    if boy.status == girl.status and boy.status == 'Single' and \
                            boy.check_eligibility(girl.maintenance_budget, girl.attractiveness) \
                            and girl.check_eligibility(boy.budget):
                        boy.gf = girl.name
                        girl.bf = boy.name

                        # Update relationship status
                        boy.status = 'Committed'
                        girl.status = 'Committed'
                        text = girl.name + ' is in relationship with ' + boy.name
                        print(text)

                        # Create Log
                        create_log(text)
                        virtual_couple_list.append(Couple(boy, girl))
                        break

                couple.boy.status = 'Single'
                virtual_couple_list.remove(couple)
        calc_happiness(virtual_couple_list, gifts)
        print('\n')
        print('After ' + str(i + 2) + ' day ')
        for couple in virtual_couple_list:
            print(couple.boy.name + ' and ' + couple.girl.name)
	def __init__(self, name, price, value, type):
		'constructor'
		Gift.__init__(self, name, price, value, type)