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
9b4a645b
Commit
9b4a645b
authored
Apr 06, 2020
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve bomb detection
parent
c91e1e2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
parse.py
parse.py
+21
-8
No files found.
parse.py
View file @
9b4a645b
...
...
@@ -22,7 +22,9 @@ HUE_TOLERANCE = 5
DETECT_BASIC_X
=
9
DETECT_BASIC_Y
=
15
DETECT_BOMB_X
=
22
DETECT_BOMB_Y
=
45
DETECT_BOMB_Y
=
43
DETECT_BOMB_Y_TOLERANCE
=
7
DETECT_BOMB_CHECK
=
9
,
20
,
137
,
230
,
9
# x, y, hue, value, tolerance
MIN_BASIC_SAT
=
180
MIN_BOMB_SAT
=
130
...
...
@@ -79,13 +81,24 @@ def detect_block_type(board, x, y):
if
is_hue
(
h
,
hexpect
):
return
ty
# if no basic block is detected, check another pixel for bomb contents
# if no basic block is detected, check another range of pixels for bomb
# contents
def
check_bomb
():
dx
,
dy
,
hexpect
,
minval
,
tolerance
=
DETECT_BOMB_CHECK
for
offset
in
range
(
tolerance
):
h
,
s
,
v
=
board
.
getpixel
((
x
+
dx
,
y
+
dy
+
offset
))
if
is_hue
(
h
,
hexpect
)
and
v
>=
minval
:
return
True
return
False
if
check_bomb
():
for
offset
in
range
(
DETECT_BOMB_Y_TOLERANCE
):
h
,
s
,
v
=
board
.
getpixel
((
x
+
DETECT_BOMB_X
,
y
+
DETECT_BOMB_Y
))
y
+
DETECT_BOMB_Y
+
offset
))
if
s
>=
MIN_BOMB_SAT
:
for
ty
,
hexpect
in
enumerate
(
BOMB_HUES
):
for
basic_
ty
,
hexpect
in
enumerate
(
BOMB_HUES
):
if
is_hue
(
h
,
hexpect
):
return
ty
+
BOMB_OFFSET
return
basic_
ty
+
BOMB_OFFSET
# no basic block or bomb -> empty slot
return
NOBLOCK
...
...
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