Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exapunks-hackmatch-bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
exapunks-hackmatch-bot
Commits
9b4a645b
Commit
9b4a645b
authored
5 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Improve bomb detection
parent
c91e1e2e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parse.py
+21
-8
21 additions, 8 deletions
parse.py
with
21 additions
and
8 deletions
parse.py
+
21
−
8
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
h
,
s
,
v
=
board
.
getpixel
((
x
+
DETECT_BOMB_X
,
y
+
DETECT_BOMB_Y
))
if
s
>=
MIN_BOMB_SAT
:
for
ty
,
hexpect
in
enumerate
(
BOMB_HUES
):
if
is_hue
(
h
,
hexpect
):
return
ty
+
BOMB_OFFSET
# 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
+
offset
))
if
s
>=
MIN_BOMB_SAT
:
for
basic_ty
,
hexpect
in
enumerate
(
BOMB_HUES
):
if
is_hue
(
h
,
hexpect
):
return
basic_ty
+
BOMB_OFFSET
# no basic block or bomb -> empty slot
return
NOBLOCK
...
...
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