Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2048
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wen Yao Jin
2048
Commits
31a4f82d
Commit
31a4f82d
authored
8 years ago
by
Wen Yao Jin
Browse files
Options
Downloads
Patches
Plain Diff
go
parent
9ff0c414
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
__pycache__/agent_afterstate.cpython-35.pyc
+0
-0
0 additions, 0 deletions
__pycache__/agent_afterstate.cpython-35.pyc
agent_afterstate.py
+12
-4
12 additions, 4 deletions
agent_afterstate.py
puzzle.py
+2
-1
2 additions, 1 deletion
puzzle.py
with
14 additions
and
5 deletions
__pycache__/agent_afterstate.cpython-35.pyc
+
0
−
0
View file @
31a4f82d
No preview for this file type
This diff is collapsed.
Click to expand it.
agent_afterstate.py
+
12
−
4
View file @
31a4f82d
...
...
@@ -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
)],
\
...
...
This diff is collapsed.
Click to expand it.
puzzle.py
+
2
−
1
View file @
31a4f82d
...
...
@@ -177,6 +177,7 @@ if __name__ == '__main__':
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
(
"
-u
"
,
"
--tuple
"
,
dest
=
"
tuple
"
,
help
=
"
the tuple to use
"
)
(
options
,
args
)
=
parser
.
parse_args
()
print
(
vars
(
options
))
start_time
=
time
.
time
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment