-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnegotiator_base.py
executable file
·50 lines (43 loc) · 2.09 KB
/
negotiator_base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
##Base Negotiator Class
##Base Methods and Fields needed
##To further develop the Negotiator
class BaseNegotiator:
# Constructor - Note that you can add other fields here; the only
# required fields are self.preferences and self.offer
def __init__(self):
self.preferences = {}
self.offer = []
self.iter_limit = 0
# initialize(self : BaseNegotiator, preferences : list(String), iter_limit : Int)
# Performs per-round initialization - takes in a list of items, ordered by the item's
# preferability for this negotiator
# You can do other work here, but still need to store the preferences
def initialize(self, preferences, iter_limit):
self.preferences = preferences
self.iter_limit = iter_limit
# make_offer(self : BaseNegotiator, offer : list(String)) --> list(String)
# Given the opposing negotiator's last offer (represented as an ordered list),
# return a new offer. If you wish to accept an offer & end negotiations, return the same offer
# Note: Store a copy of whatever offer you make in self.offer at the end of this method.
def make_offer(self, offer):
pass
# utility(self : BaseNegotiator) --> Float
# Return the utility given by the last offer - Do not modify this method.
def utility(self):
total = 0
for s in self.offer:
total += self.preferences.get(s,0)
return total
# receive_utility(self : BaseNegotiator, utility : Float)
# Store the utility the other negotiator received from their last offer
def receive_utility(self, utility):
pass
# receive_results(self : BaseNegotiator, results : (Boolean, Float, Float, count))
# Store the results of the last series of negotiation (points won, success, etc.)
def receive_results(self, results):
pass
# set_diff(self: BaseNegotiator)
##Returns the set difference of the current offer and the total list of items
def set_diff(self):
diff = (self.preferences.keys())
return [aa for aa in diff if aa not in self.offer]