1 | package agents.rlboa;
|
---|
2 |
|
---|
3 | import java.util.Objects;
|
---|
4 |
|
---|
5 | public class LookBackState extends AbstractState implements BinnedRepresentation {
|
---|
6 |
|
---|
7 | private int myBin;
|
---|
8 | private int oppBin;
|
---|
9 | private int prevMyBin;
|
---|
10 | private int prevOppBin;
|
---|
11 | private int time;
|
---|
12 |
|
---|
13 | public static LookBackState TERMINAL = new LookBackState(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
---|
14 | public static LookBackState INITIAL = new LookBackState(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
---|
15 |
|
---|
16 | // TODO: Initialize these values from config file
|
---|
17 | private static int initialActionSpace = 10;
|
---|
18 | private static int standardActionSpace = 3;
|
---|
19 |
|
---|
20 | public LookBackState(int myBin, int oppBin, int prevMyBin, int prevOppBin, int time) {
|
---|
21 | this.myBin = myBin;
|
---|
22 | this.oppBin = oppBin;
|
---|
23 | this.prevMyBin = prevMyBin;
|
---|
24 | this.prevOppBin = prevOppBin;
|
---|
25 | this.time = time;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public int getActionSize() {
|
---|
29 | if (this.getMyBin() < 0) {
|
---|
30 | return initialActionSpace;
|
---|
31 | }
|
---|
32 | else {
|
---|
33 | return standardActionSpace;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public int getMyBin() {
|
---|
38 | return this.myBin;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public int getOppBin() {
|
---|
42 | return this.oppBin;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public int getPrevMyBin() {
|
---|
46 | return this.prevMyBin;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public int getPrevOppBin() {
|
---|
50 | return this.prevOppBin;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public int getTime() {
|
---|
54 | return this.time;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public boolean isInitialState() {
|
---|
58 | return this.equals(LookBackState.INITIAL);
|
---|
59 | }
|
---|
60 |
|
---|
61 | public boolean isTerminalState() {
|
---|
62 | return this.equals(LookBackState.TERMINAL);
|
---|
63 | }
|
---|
64 |
|
---|
65 | public int hash() {
|
---|
66 | return Objects.hash(this.getMyBin(), this.getOppBin(), this.getPrevMyBin(), this.getPrevOppBin(), this.getTime());
|
---|
67 | }
|
---|
68 |
|
---|
69 | @Override
|
---|
70 | public String toString() {
|
---|
71 | return String.format("My bin: %d, Opp bin: %d, Prev My Bin: %d, Prev Opp Bin: %d, Time: %d", this.getMyBin(), this.getOppBin(), this.getPrevMyBin(), this.getPrevOppBin(), this.getTime());
|
---|
72 | }
|
---|
73 |
|
---|
74 | }
|
---|