1 | package agents.rlboa;
|
---|
2 |
|
---|
3 | import genius.core.Bid;
|
---|
4 | import genius.core.BidHistory;
|
---|
5 | import genius.core.actions.Action;
|
---|
6 | import genius.core.actions.EndNegotiation;
|
---|
7 | import genius.core.events.MultipartyNegoActionEvent;
|
---|
8 |
|
---|
9 | @SuppressWarnings("serial")
|
---|
10 | public class LookBackQlearner extends Qlearner {
|
---|
11 |
|
---|
12 | @Override
|
---|
13 | public AbstractState getStateRepresentation(MultipartyNegoActionEvent negoEvent) {
|
---|
14 |
|
---|
15 | Bid oppLastBid = negotiationSession.getOpponentBidHistory().getLastBid();
|
---|
16 | Bid myLastBid = negotiationSession.getOwnBidHistory().getLastBid();
|
---|
17 |
|
---|
18 | Bid myPreviousBid = this.getPreviousBid(negotiationSession.getOwnBidHistory());
|
---|
19 | Bid oppPreviousBid = this.getPreviousBid(negotiationSession.getOpponentBidHistory());
|
---|
20 |
|
---|
21 | Bid agreement = negoEvent.getAgreement();
|
---|
22 | Action currentAction = negoEvent.getAction();
|
---|
23 |
|
---|
24 | if (agreement != null || currentAction.getClass() == EndNegotiation.class) {
|
---|
25 | return LookBackState.TERMINAL;
|
---|
26 | }
|
---|
27 |
|
---|
28 | int myBin = this.getBinIndex(myLastBid);
|
---|
29 | int myPrevBin = this.getBinIndex(myPreviousBid);
|
---|
30 | int oppBin = this.getBinIndex(oppLastBid);
|
---|
31 | int oppPrevBin = this.getBinIndex(oppPreviousBid);
|
---|
32 |
|
---|
33 | double time = negotiationSession.getTime();
|
---|
34 |
|
---|
35 | LookBackState state = new LookBackState(myBin, oppBin, myPrevBin, oppPrevBin, this.getTimeBinIndex(time));
|
---|
36 |
|
---|
37 | return state;
|
---|
38 | }
|
---|
39 |
|
---|
40 | private Bid getPreviousBid(BidHistory history) {
|
---|
41 | Bid bid = null;
|
---|
42 |
|
---|
43 | if (history.size() > 1) {
|
---|
44 | return history.getHistory().get(history.size() - 1).getBid();
|
---|
45 | }
|
---|
46 |
|
---|
47 | return bid;
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public String getName() {
|
---|
52 | return "LookBackQlearner";
|
---|
53 | }
|
---|
54 | }
|
---|