当前位置: 首页>>代码示例>>Python>>正文


Python utility.Logger类代码示例

本文整理汇总了Python中monopyly.utility.Logger的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unmortgage_properties

    def unmortgage_properties(self, game_state, player):
        '''
        Called near the start of the player's turn to give them the
        opportunity to unmortgage properties.

        Unmortgaging costs half the face value plus 10%. Between deciding
        to unmortgage and money being taken the player will be given the
        opportunity to make deals or sell other properties. If after this
        they do not have enough money, the whole transaction will be aborted,
        and no properties will be unmortgaged and no money taken.

        Return a list of property names to unmortgage, like:
        [old_kent_road, bow_street]

        The properties should be Property objects.

        The default is to return an empty list, ie to do nothing.
        '''
        props_to_unmortgage = []
        if len(self.mortgaged_properties) > 0:
            cash_to_spend = player.state.cash - self.cash_reserve
            mortgaged = sorted(self.mortgaged_properties, key = lambda p: p.price)
            while cash_to_spend > 0.0 and len(mortgaged) > 0:
                mc = int(mortgaged[0].price * 0.5)
                cash_to_spend -= mc
                if cash_to_spend >= 0.0:
                    props_to_unmortgage.append(mortgaged[0])
                    mortgaged.pop(0)
            if len(props_to_unmortgage) > 0:
                Logger.log("# {0}: Unmortgaging: {1}".format(self.get_name(), str(props_to_unmortgage)), Logger.INFO)
        for i in range(0, len(props_to_unmortgage)):
            self.mortgaged_properties.remove(props_to_unmortgage[i])
        return props_to_unmortgage
开发者ID:mlong14,项目名称:monopyly,代码行数:33,代码来源:xander.py

示例2: auction_result

    def auction_result(self, status, property, player, amount_paid):
        '''
        Called with the result of an auction. All players receive
        this notification.

        status is either AUCTION_SUCCEEDED or AUCTION_FAILED.

        If the auction succeeded, the property, the player who won
        the auction and the amount they paid are passed to the AI.

        If the auction failed, the player will be None and the
        amount paid will be 0.

        No response is required.
        '''
        if player is None:
            return

        if player.name != self.get_name():
            return

        if status == PlayerAIBase.Action.AUCTION_SUCCEEDED:
            Logger.log("# {0}: Property {1} won at auction".format(self.get_name(), property), Logger.INFO)
        else:
            Logger.log("# Property lost at auction", Logger.INFO)

        return
开发者ID:mlong14,项目名称:monopyly,代码行数:27,代码来源:xander.py

示例3: start_of_turn

    def start_of_turn(self, game_state, player):
        '''
        Called when an AI's turn starts. All AIs receive this notification.

        No response is required.
        '''
 

        self.num_turns += 1

        self.turn_properties_in_deal = set()

        self.deals_proposed_this_turn = []
        self.cash_spent_in_turn = 0

        self.behaviour_for_turn = BEHAVIOUR_NONE
        self.deal_proposals_for_turn = [] # used if behaviour is to sell properties
        self.propose_deal_turn_num = 0

        ( self.cash_reserve, self.high_water_mark) = self._calc_cash_reserve(game_state, player)

        if self.cash_reserve > player.state.cash:
            Logger.log("# {0}: SOT {1} - cash_reserve = {2}, HWM = {3}, Cash = {4}.".format(self.get_name(), self.num_turns, self.cash_reserve, self.high_water_mark, player.state.cash), Logger.INFO)
            if int(self.cash_reserve * CASH_RESERVE_FRACTION_SELL_TRIGGER) >= player.state.cash:
                self.behaviour_for_turn = BEHAVIOUR_SELL_PROPERTY

        self.amount_to_raise = 0.0


        Logger.log("# Start of Turn {0} - cash_reserve = {1}, HWM = {2}.".format(self.num_turns, self.cash_reserve, self.high_water_mark), Logger.INFO)

        return
开发者ID:mlong14,项目名称:monopyly,代码行数:32,代码来源:xander.py

示例4: deal_proposed

    def deal_proposed(self, game_state, player, deal_proposal):
        '''
        Called when a deal is proposed by another player.
        '''


        if len(deal_proposal.properties_wanted) > 0 and len(deal_proposal.properties_offered) == 0:
            (bid_price, ask_price) = self._calc_value_of_properties(game_state, player, deal_proposal.properties_wanted)

            if ask_price < self.amount_to_raise:
                ask_price = self.amount_to_raise

            Logger.log("# Accepted proposed deal of wanted properties {0} for {1}".format(str(deal_proposal.properties_wanted), ask_price))
            return DealResponse(
                action=DealResponse.Action.ACCEPT,
                minimum_cash_wanted = ask_price
                )

        if self.amount_to_raise > 0.0:
            return DealResponse(DealResponse.Action.REJECT)

        # We only accept deals for single properties wanted from us...
        if len(deal_proposal.properties_offered) > 0 and len(deal_proposal.properties_wanted) == 0:
            (bid_price, ask_price) = self._calc_value_of_properties(game_state, player, deal_proposal.properties_offered)
            if player.state.cash > bid_price + self.high_water_mark:
                Logger.log("# Accepted proposed deal of offered properties {0} for {1}".format(str(deal_proposal.properties_offered), bid_price))
                return DealResponse(
                    action=DealResponse.Action.ACCEPT,
                    maximum_cash_offered = bid_price
                    )



        return DealResponse(DealResponse.Action.REJECT)
开发者ID:mlong14,项目名称:monopyly,代码行数:34,代码来源:brettai.py

示例5: property_offered_for_auction

    def property_offered_for_auction(self, game_state, player, property):
        '''
        Called when a property is put up for auction.

        Properties are auctioned when a player lands on an unowned square but does
        not want to buy it. All players take part in the auction, including the
        player who landed on the square.

        The property will be sold to the highest bidder using the eBay rule,
        ie, for £1 more than the second-highest bid.

        Return the amount you bid. To put in a bid this must be a positive integer.
        Zero means that you are not bidding (it does not mean that you are bidding
        zero).

        The default behaviour is not to bid.
        '''

        if player.ai is not self:
            Logger.log("# !!! ERROR player is NOT me in property_offered_for_auction")

        if self.amount_to_raise > 0.0:
            return 0.0

        if len(self.mortgaged_properties) > 0 and DONT_BID_ON_AUCTIONS_WITH_MORTAGED_PROPS:
            return 0

        price_to_bid = 0.0
        (bid_price, ask_price) = self._calc_value_of_properties(game_state, player, [ property ])
        if player.state.cash > bid_price + self.cash_reserve:
            price_to_bid = bid_price
        
        Logger.log("# Property being auctioned and bidding {0}".format(price_to_bid), Logger.INFO)

        return price_to_bid
开发者ID:mlong14,项目名称:monopyly,代码行数:35,代码来源:brettai.py

示例6: money_taken

    def money_taken(self, player, amount):
        '''
        Called when money has been taken from the player.

        No response is required.
        '''
        Logger.log("# Money taken : {0}".format(amount), Logger.INFO)
        return
开发者ID:mlong14,项目名称:monopyly,代码行数:8,代码来源:brettai.py

示例7: landed_on_unowned_property

 def landed_on_unowned_property(self,game_state,player,property):
     if self.want_property(game_state,player,property):
         if player.state.cash>(self.cashReserve+property.price):
             Logger.log(self.get_name()+" buying: "+property.name)
             return PlayerAIBase.Action.BUY
         else:
             Logger.log(self.get_name()+" can't buy: {0}, price: {1}, cash: {2}, reserve: {3}".format(property.name,property.price,player.state.cash,self.cashReserve,))
     return PlayerAIBase.Action.DO_NOT_BUY
开发者ID:kkanagal,项目名称:monopyly,代码行数:8,代码来源:snowboarderAI.py

示例8: sell_houses

    def sell_houses(self, game_state, player):
        '''
        Gives the player the option to sell properties.

        This is called when any debt, fine or rent has to be paid. It is
        called just before mortgage_properties (below).

        Notes:
        - You cannot mortgage properties with houses on them, so if you
          plan to mortgage, make sure you sell all the houses first.

        - For each house sold you receive half the price that they were
          bought for.

        - Houses on a set must end up 'balanced', ie no property can have
          more than one more house than any other property in the set.

        Return a list of tuples of the streets and number of houses you
        want to sell. For example:
        [(old_kent_road, 1), (bow_street, 1)]

        The streets should be Property objects.

        The default is not to sell any houses.
        '''
        houses_to_sell = []
        if self.amount_to_raise > 0.0:
            money_generated = 0

            for prop_set in HOUSE_PROP_SET_SELL_ORDER:
                (num_houses, owned_prop_list) = self._get_owned_houses_in_property_set(game_state, player, prop_set)
                num_house_list = [ 0 for p in owned_prop_list ]
                houses_sold = 0
                while num_houses < houses_sold and money_generated < self.amount_to_raise:
                    for i in range(0, len(owned_prop_list)):
                        if num_house_list[i] < owned_prop_list[i].number_of_houses:
                            num_house_list[i] += 1
                            houses_sold += 1
                            money_generated += int(owned_prop_list[i].house_price / 2)
                if houses_sold > 0:
                    for i in range(0, len(owned_prop_list)):
                        if num_house_list[i] > 0:
                            houses_to_sell.append( (owned_prop_list[i], num_house_list[i], ))


            # update amount_to_raise
            self.amount_to_raise -= money_generated
            if self.amount_to_raise < 0:
                self.amount_to_raise = 0.0

        if len(houses_to_sell) > 0:
            Logger.log("# {0}: Selling the following houses: {1}".format(self.get_name(), str(houses_to_sell)), Logger.INFO)
            
        return houses_to_sell
开发者ID:mlong14,项目名称:monopyly,代码行数:54,代码来源:xander.py

示例9: player_landed_on_square

    def player_landed_on_square(self, game_state, square, player):
        '''
        Called when a player lands on a square. All AIs receive this notification.

        No response is required.
        '''
        if player.ai != self:
            return

        Logger.log("# Landed on Square {0}".format(square), Logger.INFO)
        return
开发者ID:mlong14,项目名称:monopyly,代码行数:11,代码来源:xander.py

示例10: landed_on_unowned_property

    def landed_on_unowned_property(self, game_state, player, property):
        '''
        price the property / evaluate the risks of buying
        '''
        ret = PlayerAIBase.Action.DO_NOT_BUY
        act = "not buying"
        if player.state.cash > (self.cash_reserve + property.price):
            ret = PlayerAIBase.Action.BUY
            act = "buying"

        Logger.log("# Landed on unowned property and {0}".format(act), Logger.INFO)
        return ret
开发者ID:mlong14,项目名称:monopyly,代码行数:12,代码来源:brettai.py

示例11: start_of_game

    def start_of_game(self):
        '''
        Called at the start of the game.

        No response is required.
        '''
        Logger.log("# Start of Game.", Logger.INFO)
        self.num_turns = 0
        self.num_get_out_of_jail_cards = 0
        self.amount_to_raise = 0.0
        self.mortgaged_properties = []

        return
开发者ID:mlong14,项目名称:monopyly,代码行数:13,代码来源:brettai.py

示例12: mortgage_properties

    def mortgage_properties(self, game_state, player):
        '''
        Gives the player an option to mortgage properties.

        This is called before any debt is paid (house building, rent,
        tax, fines from cards etc).

        Notes:
        - You receive half the face value of each property mortgaged.

        - You cannot mortgage properties with houses on them.
          (The AI will have been given the option to sell houses before this
          function is called.)

        Return a list of properties to mortgage, for example:
        [bow_street, liverpool_street_station]

        The properties should be Property objects.

        Return an empty list if you do not want to mortgage anything.

        The default behaviour is not to mortgage anything.
        '''
        if DONT_MORTGAGE_ANY_PROPERTIES:
            return []

        if self.behaviour_for_turn == BEHAVIOUR_SELL_PROPERTY:
            Logger.log("{0}: Behaviour is to sell properties - Not Mortgaging!".format(self.get_name()), Logger.INFO)
            return []

        properties_to_mortage = []
        if self.amount_to_raise > 0.0:
            money_generated = 0
            board = game_state.board
            for sq in board.squares:
                if isinstance(sq, Property) and sq.owner == player and sq.is_mortgaged == False:
                    money_generated += int(sq.price / 2)
                    properties_to_mortage.append(sq)

                    if money_generated > self.amount_to_raise:
                        break
            self.amount_to_raise -= money_generated
            if self.amount_to_raise < 0.0:
                self.amount_to_raise = 0.0

        if len(properties_to_mortage) > 0:
            Logger.log("# {0}: Mortgaging the following properties: {1}".format(self.get_name(), str(properties_to_mortage)), Logger.INFO)
            self.mortgaged_properties.extend(properties_to_mortage)
            
        return properties_to_mortage
开发者ID:mlong14,项目名称:monopyly,代码行数:50,代码来源:xander.py

示例13: landed_on_unowned_property

    def landed_on_unowned_property(self, game_state, player, property):
        '''
        price the property / evaluate the risks of buying
        '''
        ret = PlayerAIBase.Action.DO_NOT_BUY
        act = "not buying"
        if player.state.cash > (self.cash_reserve + property.price):
            ret = PlayerAIBase.Action.BUY
            act = "buying"

            self.cash_spent_in_turn += property.price
            Logger.log("# {0}: Turn {1}, landed on unowned property and buying for {2}, cash = {3}".format(self.get_name(), self.num_turns, property.price, player.state.cash), Logger.INFO)


        Logger.log("# Landed on unowned property and {0}".format(act), Logger.INFO)
        return ret
开发者ID:mlong14,项目名称:monopyly,代码行数:16,代码来源:xander.py

示例14: money_given

    def money_given(self, player, amount):
        '''
        Called when money has been given to the player.

        No response is required.
        '''
        if player.name != self.get_name():
            return

        if self.amount_to_raise > 0:
            self.amount_to_raise -= amount
            if self.amount_to_raise < 0:
                self.amount_to_raise = 0

            Logger.log("# {0}: Money given {1}, amount_to_raise: {2}".format(self.get_name(), amount, self.amount_to_raise), Logger.INFO)
        return
开发者ID:mlong14,项目名称:monopyly,代码行数:16,代码来源:xander.py

示例15: want_property

 def want_property(self,game_state,player,property):
     try:
         if len(player.state.properties)<self.propertyCountLower: # Get a 'critical mass' of properties for trading
             if player.board._name_to_index_map[property.name][0]>player.board._name_to_index_map["Jail"][0]:
                 return True
             else:
                 return False
         else:
             if str(property.property_set)!='Station' and str(property.property_set)!='Utility':
                 squareGroup=property.property_set.__str__()
                 if squareGroup!=None:
                     if squareGroup in self.targetSquareGroup:
                         return True
     except Exception as err:
         Logger.log("Exception thrown in 'landed_on_unowned_property': "+str(err))
     return False
开发者ID:kkanagal,项目名称:monopyly,代码行数:16,代码来源:snowboarderAI.py


注:本文中的monopyly.utility.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。