import random, math

class Ai_player():
    def __init__(self,playernumber, value_preference, rewarded_preference, behind_in_score_dislike, turn_count_modifier):

        self.behaviour=[value_preference,rewarded_preference, behind_in_score_dislike,turn_count_modifier] #tells the ai what he should value

        for yy in range(0,len(self.behaviour)): #this block prevents the calculations for the ai's priorities to get out of hand.
            if self.behaviour[yy]>20:
                for zz in range(0,len(self.behaviour)):
                    self.behaviour[zz]+= -20

        self.priorities=[]
        self.money=5
        self.victory_points=0
        self.playernumber=playernumber
        self.max_known_victory_points=0
        self.score=[]
        self.who_rewarded=[]
        self.turn_count=1

 #       self.preferences=[value_preference, rewarded_preference]

    def asktoinvest(self,companies_ingame):
        self.set_priorities(companies_ingame)

        for x in range(0,self.money):
            randomizes=random.uniform(0,1)
            target_of_investment=0

            total=0
            subtotal=0
            for x in range(0,len(companies_ingame)):
                total+=self.priorities[x]
                if randomizes > subtotal  and randomizes < total:
                    target_of_investment=x
                subtotal=total

            companies_ingame[target_of_investment].ownership[self.playernumber]+=1

        self.money=0


    def set_priorities(self,companies_ingame):
        #set priorities
        self.priorities=[]

        #sets up prioritization of valueable companies
        for x in range(0,len(companies_ingame)):
            self.priorities.append(companies_ingame[x].return_value()*math.pow(2,self.behaviour[0]))

        #sets up prioritization of victory points if player is behind proportional to how much player is behind
        if self.victory_points < max(self.score):
            for x in range(6,len(companies_ingame)):
                self.priorities[x]=self.priorities[x]+math.pow(2,self.behaviour[2])*(max(self.score)-self.victory_points)

        #adjusts priorities based on whether the player owns the company
        for x in range(0,len(self.who_rewarded)):
            self.priorities[self.who_rewarded[x]]=self.priorities[self.who_rewarded[x]]+math.pow(2,self.behaviour[1])
        self.who_rewarded=[]

        #priotitizes victory points later in the game.
        for x in range(6,len(companies_ingame)):
            self.priorities[x]=self.priorities[x]+self.turn_count*math.pow(2,self.behaviour[3])
            self.turn_count+=1

        #normalize priorities.
        total=0
        for x in range(0,len(self.priorities)):
            total=total+self.priorities[x]
        for x in range(0,len(self.priorities)):
            self.priorities[x]=self.priorities[x]/total


    def reward_money(self,money):
        self.money+=money
    def reward_victory_points(self,victory_points):
        self.victory_points+=victory_points
    def return_victory_points(self):
        return self.victory_points
    def tell_score(self,score):
        self.score=score
    def tell_rewarded(self,company_number):
        self.who_rewarded.append(company_number)
2372d3c993dfaabb6b2553a351096d60b147bbe8
<mask token>


class Ai_player:

    def __init__(self, playernumber, value_preference, rewarded_preference,
        behind_in_score_dislike, turn_count_modifier):
        self.behaviour = [value_preference, rewarded_preference,
            behind_in_score_dislike, turn_count_modifier]
        for yy in range(0, len(self.behaviour)):
            if self.behaviour[yy] > 20:
                for zz in range(0, len(self.behaviour)):
                    self.behaviour[zz] += -20
        self.priorities = []
        self.money = 5
        self.victory_points = 0
        self.playernumber = playernumber
        self.max_known_victory_points = 0
        self.score = []
        self.who_rewarded = []
        self.turn_count = 1
    <mask token>
    <mask token>

    def reward_money(self, money):
        self.money += money
    <mask token>

    def return_victory_points(self):
        return self.victory_points
    <mask token>
    <mask token>

<mask token>


class Ai_player:

    def __init__(self, playernumber, value_preference, rewarded_preference,
        behind_in_score_dislike, turn_count_modifier):
        self.behaviour = [value_preference, rewarded_preference,
            behind_in_score_dislike, turn_count_modifier]
        for yy in range(0, len(self.behaviour)):
            if self.behaviour[yy] > 20:
                for zz in range(0, len(self.behaviour)):
                    self.behaviour[zz] += -20
        self.priorities = []
        self.money = 5
        self.victory_points = 0
        self.playernumber = playernumber
        self.max_known_victory_points = 0
        self.score = []
        self.who_rewarded = []
        self.turn_count = 1
    <mask token>

    def set_priorities(self, companies_ingame):
        self.priorities = []
        for x in range(0, len(companies_ingame)):
            self.priorities.append(companies_ingame[x].return_value() *
                math.pow(2, self.behaviour[0]))
        if self.victory_points < max(self.score):
            for x in range(6, len(companies_ingame)):
                self.priorities[x] = self.priorities[x] + math.pow(2, self.
                    behaviour[2]) * (max(self.score) - self.victory_points)
        for x in range(0, len(self.who_rewarded)):
            self.priorities[self.who_rewarded[x]] = self.priorities[self.
                who_rewarded[x]] + math.pow(2, self.behaviour[1])
        self.who_rewarded = []
        for x in range(6, len(companies_ingame)):
            self.priorities[x] = self.priorities[x
                ] + self.turn_count * math.pow(2, self.behaviour[3])
            self.turn_count += 1
        total = 0
        for x in range(0, len(self.priorities)):
            total = total + self.priorities[x]
        for x in range(0, len(self.priorities)):
            self.priorities[x] = self.priorities[x] / total

    def reward_money(self, money):
        self.money += money
    <mask token>

    def return_victory_points(self):
        return self.victory_points
    <mask token>
    <mask token>

<mask token>


class Ai_player:

    def __init__(self, playernumber, value_preference, rewarded_preference,
        behind_in_score_dislike, turn_count_modifier):
        self.behaviour = [value_preference, rewarded_preference,
            behind_in_score_dislike, turn_count_modifier]
        for yy in range(0, len(self.behaviour)):
            if self.behaviour[yy] > 20:
                for zz in range(0, len(self.behaviour)):
                    self.behaviour[zz] += -20
        self.priorities = []
        self.money = 5
        self.victory_points = 0
        self.playernumber = playernumber
        self.max_known_victory_points = 0
        self.score = []
        self.who_rewarded = []
        self.turn_count = 1
    <mask token>

    def set_priorities(self, companies_ingame):
        self.priorities = []
        for x in range(0, len(companies_ingame)):
            self.priorities.append(companies_ingame[x].return_value() *
                math.pow(2, self.behaviour[0]))
        if self.victory_points < max(self.score):
            for x in range(6, len(companies_ingame)):
                self.priorities[x] = self.priorities[x] + math.pow(2, self.
                    behaviour[2]) * (max(self.score) - self.victory_points)
        for x in range(0, len(self.who_rewarded)):
            self.priorities[self.who_rewarded[x]] = self.priorities[self.
                who_rewarded[x]] + math.pow(2, self.behaviour[1])
        self.who_rewarded = []
        for x in range(6, len(companies_ingame)):
            self.priorities[x] = self.priorities[x
                ] + self.turn_count * math.pow(2, self.behaviour[3])
            self.turn_count += 1
        total = 0
        for x in range(0, len(self.priorities)):
            total = total + self.priorities[x]
        for x in range(0, len(self.priorities)):
            self.priorities[x] = self.priorities[x] / total

    def reward_money(self, money):
        self.money += money

    def reward_victory_points(self, victory_points):
        self.victory_points += victory_points

    def return_victory_points(self):
        return self.victory_points
    <mask token>

    def tell_rewarded(self, company_number):
        self.who_rewarded.append(company_number)

<mask token>


class Ai_player:

    def __init__(self, playernumber, value_preference, rewarded_preference,
        behind_in_score_dislike, turn_count_modifier):
        self.behaviour = [value_preference, rewarded_preference,
            behind_in_score_dislike, turn_count_modifier]
        for yy in range(0, len(self.behaviour)):
            if self.behaviour[yy] > 20:
                for zz in range(0, len(self.behaviour)):
                    self.behaviour[zz] += -20
        self.priorities = []
        self.money = 5
        self.victory_points = 0
        self.playernumber = playernumber
        self.max_known_victory_points = 0
        self.score = []
        self.who_rewarded = []
        self.turn_count = 1

    def asktoinvest(self, companies_ingame):
        self.set_priorities(companies_ingame)
        for x in range(0, self.money):
            randomizes = random.uniform(0, 1)
            target_of_investment = 0
            total = 0
            subtotal = 0
            for x in range(0, len(companies_ingame)):
                total += self.priorities[x]
                if randomizes > subtotal and randomizes < total:
                    target_of_investment = x
                subtotal = total
            companies_ingame[target_of_investment].ownership[self.playernumber
                ] += 1
        self.money = 0

    def set_priorities(self, companies_ingame):
        self.priorities = []
        for x in range(0, len(companies_ingame)):
            self.priorities.append(companies_ingame[x].return_value() *
                math.pow(2, self.behaviour[0]))
        if self.victory_points < max(self.score):
            for x in range(6, len(companies_ingame)):
                self.priorities[x] = self.priorities[x] + math.pow(2, self.
                    behaviour[2]) * (max(self.score) - self.victory_points)
        for x in range(0, len(self.who_rewarded)):
            self.priorities[self.who_rewarded[x]] = self.priorities[self.
                who_rewarded[x]] + math.pow(2, self.behaviour[1])
        self.who_rewarded = []
        for x in range(6, len(companies_ingame)):
            self.priorities[x] = self.priorities[x
                ] + self.turn_count * math.pow(2, self.behaviour[3])
            self.turn_count += 1
        total = 0
        for x in range(0, len(self.priorities)):
            total = total + self.priorities[x]
        for x in range(0, len(self.priorities)):
            self.priorities[x] = self.priorities[x] / total

    def reward_money(self, money):
        self.money += money

    def reward_victory_points(self, victory_points):
        self.victory_points += victory_points

    def return_victory_points(self):
        return self.victory_points

    def tell_score(self, score):
        self.score = score

    def tell_rewarded(self, company_number):
        self.who_rewarded.append(company_number)

import random, math

class Ai_player():
    def __init__(self,playernumber, value_preference, rewarded_preference, behind_in_score_dislike, turn_count_modifier):

        self.behaviour=[value_preference,rewarded_preference, behind_in_score_dislike,turn_count_modifier] #tells the ai what he should value

        for yy in range(0,len(self.behaviour)): #this block prevents the calculations for the ai's priorities to get out of hand.
            if self.behaviour[yy]>20:
                for zz in range(0,len(self.behaviour)):
                    self.behaviour[zz]+= -20

        self.priorities=[]
        self.money=5
        self.victory_points=0
        self.playernumber=playernumber
        self.max_known_victory_points=0
        self.score=[]
        self.who_rewarded=[]
        self.turn_count=1

 #       self.preferences=[value_preference, rewarded_preference]

    def asktoinvest(self,companies_ingame):
        self.set_priorities(companies_ingame)

        for x in range(0,self.money):
            randomizes=random.uniform(0,1)
            target_of_investment=0

            total=0
            subtotal=0
            for x in range(0,len(companies_ingame)):
                total+=self.priorities[x]
                if randomizes > subtotal  and randomizes < total:
                    target_of_investment=x
                subtotal=total

            companies_ingame[target_of_investment].ownership[self.playernumber]+=1

        self.money=0


    def set_priorities(self,companies_ingame):
        #set priorities
        self.priorities=[]

        #sets up prioritization of valueable companies
        for x in range(0,len(companies_ingame)):
            self.priorities.append(companies_ingame[x].return_value()*math.pow(2,self.behaviour[0]))

        #sets up prioritization of victory points if player is behind proportional to how much player is behind
        if self.victory_points < max(self.score):
            for x in range(6,len(companies_ingame)):
                self.priorities[x]=self.priorities[x]+math.pow(2,self.behaviour[2])*(max(self.score)-self.victory_points)

        #adjusts priorities based on whether the player owns the company
        for x in range(0,len(self.who_rewarded)):
            self.priorities[self.who_rewarded[x]]=self.priorities[self.who_rewarded[x]]+math.pow(2,self.behaviour[1])
        self.who_rewarded=[]

        #priotitizes victory points later in the game.
        for x in range(6,len(companies_ingame)):
            self.priorities[x]=self.priorities[x]+self.turn_count*math.pow(2,self.behaviour[3])
            self.turn_count+=1

        #normalize priorities.
        total=0
        for x in range(0,len(self.priorities)):
            total=total+self.priorities[x]
        for x in range(0,len(self.priorities)):
            self.priorities[x]=self.priorities[x]/total


    def reward_money(self,money):
        self.money+=money
    def reward_victory_points(self,victory_points):
        self.victory_points+=victory_points
    def return_victory_points(self):
        return self.victory_points
    def tell_score(self,score):
        self.score=score
    def tell_rewarded(self,company_number):
        self.who_rewarded.append(company_number)