Commit 31a4f82d authored by Wen Yao Jin's avatar Wen Yao Jin
Browse files

go

parent 9ff0c414
......@@ -11,7 +11,7 @@ class Action(IntEnum):
RIGHT = 4
class afterstateAgent:
def __init__(self, mat, TD_lambda = 0.0, alpha = 0.0025, gamma = 0.95, epsilon = 0.01, verbose= True, symmetric=True):
def __init__(self, mat, TD_lambda = 0.0, alpha = 0.0025, gamma = 0.95, epsilon = 0.01, verbose= True, symmetric=True, tuple = 2):
self.state_per_tile = 12
self.commands = { Action.UP: up, Action.DOWN: down, Action.LEFT: left, Action.RIGHT: right}
self.alpha = alpha
......@@ -21,11 +21,12 @@ class afterstateAgent:
self.TD_lambda = TD_lambda
self.forget = self.TD_lambda
self.symmetric = symmetric
if self.symmetric:
# self.tuple = self._tuple_advance()
if tuple==0:
self.tuple = self._tuple()
elif tuple == 1:
self.tuple = self._tuple_advance()
else:
self.tuple = self._tuple()
self.tuple = self._tuple_advance_plus()
if verbose:
print(len(self.tuple))
self.W = self._generate_dict()
......@@ -58,7 +59,14 @@ class afterstateAgent:
print(list)
return list
def _tuple_advance(self):
return [[(0,0),(1,0),(2,0),(3,0)],\
[(0,1),(1,1),(2,1),(3,1)],\
[(0,1),(1,1),(2,1),(0,2),(1,2),(2,2)],\
[(0,2),(1,2),(2,2),(0,3),(1,3),(2,3)]]
def _tuple_advance_plus(self):
return [[(0,0),(1,0),(2,0),(3,0),(3,1),(2,1)],\
[(0,1),(1,1),(2,1),(3,1),(3,2),(2,2)],\
[(0,1),(1,1),(2,1),(0,2),(1,2),(2,2)],\
......
......@@ -176,7 +176,8 @@ if __name__ == '__main__':
parser.add_option("-a", "--alpha", dest="alpha", help ="alpha the learning rate")
parser.add_option("-t", "--train", dest="train", help ="training episodes")
parser.add_option("-s", "--symmetric", dest="symmetric", help ="symmetric sampling")
parser.add_option("-e", "--epsilon", dest="epsilon", help ="epsilon the exploration")
parser.add_option("-e", "--epsilon", dest="epsilon", help ="epsilon the exploration")
parser.add_option("-u", "--tuple", dest="tuple", help ="the tuple to use")
(options,args)= parser.parse_args()
print(vars(options))
start_time = time.time()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment