Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
exapunks-hackmatch-bot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
exapunks-hackmatch-bot
Commits
d0515a68
Commit
d0515a68
authored
Apr 11, 2020
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamic programming: reuse changes made by common prefix moves
parent
409354ab
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
89 deletions
+170
-89
bot.py
bot.py
+15
-8
strategy.py
strategy.py
+155
-81
No files found.
bot.py
View file @
d0515a68
...
@@ -56,10 +56,8 @@ if __name__ == '__main__':
...
@@ -56,10 +56,8 @@ if __name__ == '__main__':
vprint_state
(
state
)
vprint_state
(
state
)
vprint
()
vprint
()
start
=
time
.
time
()
assert
state
.
exa
is
not
None
newstate
=
state
.
solve
()
end
=
time
.
time
()
vprint
(
'thought for'
,
round
((
end
-
start
)
*
1000
,
1
),
'ms'
)
except
(
TypeError
,
AssertionError
):
except
(
TypeError
,
AssertionError
):
vprint
(
'
\
r
error during parsing, wait for a bit...'
,
end
=
''
)
vprint
(
'
\
r
error during parsing, wait for a bit...'
,
end
=
''
)
time
.
sleep
(
0.050
)
time
.
sleep
(
0.050
)
...
@@ -69,14 +67,23 @@ if __name__ == '__main__':
...
@@ -69,14 +67,23 @@ if __name__ == '__main__':
time
.
sleep
(
0.500
)
time
.
sleep
(
0.500
)
continue
continue
try
:
start
=
time
.
time
()
newstate
=
state
.
solve
()
end
=
time
.
time
()
vprint
(
'thought for'
,
round
((
end
-
start
)
*
1000
,
1
),
'ms'
)
except
AssertionError
:
print
(
'error board 99:'
)
state
.
print
()
board
.
convert
(
'RGB'
).
save
(
'screens/board99.png'
)
break
if
state
.
held
==
NOBLOCK
and
any
(
map
(
newstate
.
loops
,
buf
)):
if
state
.
held
==
NOBLOCK
and
any
(
map
(
newstate
.
loops
,
buf
)):
vprint
(
'
\
r
loop detected, wait for a bit...'
,
end
=
''
)
vprint
(
'
\
r
loop detected, wait for a bit...'
,
end
=
''
)
time
.
sleep
(
0.03
)
time
.
sleep
(
0.03
)
elif
newstate
.
moves
:
elif
newstate
.
moves
:
vprint
(
'moves:'
,
newstate
.
keys
())
vprint
(
'moves:'
,
newstate
.
keys
())
vprint
(
' score:'
,
newstate
.
score
)
vprint
(
'score:'
,
newstate
.
score
)
if
buf
:
vprint
(
'prev score:'
,
buf
[
-
1
].
score
)
vprint
()
vprint
()
vprint
(
'target after moves:'
)
vprint
(
'target after moves:'
)
...
@@ -88,7 +95,7 @@ if __name__ == '__main__':
...
@@ -88,7 +95,7 @@ if __name__ == '__main__':
#moves_delay = max(0, newstate.delay() - keys_delay)
#moves_delay = max(0, newstate.delay() - keys_delay)
#vprint('wait for', moves_delay, 'ms')
#vprint('wait for', moves_delay, 'ms')
#time.sleep(moves_delay / 1000)
#time.sleep(moves_delay / 1000)
time
.
sleep
(
0.0
75
)
time
.
sleep
(
0.0
80
)
elif
state
.
nrows
-
2
<=
MAX_SPEED_ROWS
:
elif
state
.
nrows
-
2
<=
MAX_SPEED_ROWS
:
vprint
(
'no moves, speed up'
)
vprint
(
'no moves, speed up'
)
press_keys
(
win
,
'l'
)
press_keys
(
win
,
'l'
)
...
...
strategy.py
View file @
d0515a68
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment