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
a53c482a
Commit
a53c482a
authored
5 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Tweak strategy parameters
parent
9fe8ccd5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
strategy.py
+38
-29
38 additions, 29 deletions
strategy.py
with
38 additions
and
29 deletions
strategy.py
+
38
−
29
View file @
a53c482a
...
@@ -13,11 +13,13 @@ MIN_BASIC_GROUP_SIZE = 4
...
@@ -13,11 +13,13 @@ MIN_BASIC_GROUP_SIZE = 4
MIN_BOMB_GROUP_SIZE
=
2
MIN_BOMB_GROUP_SIZE
=
2
FIND_GROUPS_DEPTH
=
3
FIND_GROUPS_DEPTH
=
3
FRAG_DEPTH
=
3
FRAG_DEPTH
=
3
DEFRAG_PRIO
=
3
COLSIZE_PRIO
=
5
COLSIZE_PRIO
=
5
COLSIZE_PANIC
=
7
COLSIZE_PANIC
=
7
COLSIZE_MAX
=
8
COLSIZE_MAX
=
8
BOMB_POINTS
=
2
BOMB_POINTS
=
1
MIN_ROWS
=
2
MIN_ROWS
=
2
MAX_SPEED_ROWS
=
3
class
State
:
class
State
:
...
@@ -58,6 +60,9 @@ class State:
...
@@ -58,6 +60,9 @@ class State:
for
col
in
range
(
COLUMNS
):
for
col
in
range
(
COLUMNS
):
yield
self
.
nrows
()
-
self
.
colskip
(
col
)
yield
self
.
nrows
()
-
self
.
colskip
(
col
)
def
colsize_panic
(
self
):
return
int
(
max
(
self
.
colsizes
())
>=
COLSIZE_PANIC
)
def
empty_column_score
(
self
):
def
empty_column_score
(
self
):
skip
=
0
skip
=
0
for
i
,
block
in
enumerate
(
self
.
blocks
):
for
i
,
block
in
enumerate
(
self
.
blocks
):
...
@@ -75,18 +80,23 @@ class State:
...
@@ -75,18 +80,23 @@ class State:
return
score
return
score
def
score
(
self
,
points
,
moves
,
prev
):
def
score
(
self
,
points
,
moves
,
prev
):
frag
=
self
.
fragmentation
()
colsize_score
=
self
.
empty_column_score
()
#return -points, frag + colsize_score, len(moves)
frag
+=
colsize_score
prev_colsize
=
max
(
prev
.
colsizes
())
prev_colsize
=
max
(
prev
.
colsizes
())
points
=
self
.
score_points
()
if
prev_colsize
>=
COLSIZE_PANIC
:
if
prev_colsize
>=
COLSIZE_PANIC
:
return
colsize_score
,
len
(
moves
),
-
points
,
frag
colsize
=
self
.
empty_column_score
()
#frag = self.fragmentation()
return
colsize
,
len
(
moves
),
-
points
#, frag
elif
prev_colsize
>=
DEFRAG_PRIO
:
colsize
=
self
.
empty_column_score
()
frag
=
self
.
fragmentation
()
panic
=
self
.
colsize_panic
()
return
-
points
,
panic
,
frag
,
colsize
,
len
(
moves
)
elif
prev_colsize
>=
COLSIZE_PRIO
:
elif
prev_colsize
>=
COLSIZE_PRIO
:
return
-
points
,
colsize_score
,
frag
,
len
(
moves
)
colsize
=
self
.
empty_column_score
()
return
-
points
,
colsize
,
len
(
moves
)
else
:
else
:
return
-
points
,
frag
,
colsize_score
,
len
(
moves
)
return
-
points
,
len
(
moves
)
def
score_moves
(
self
):
def
score_moves
(
self
):
for
moves
in
self
.
gen_moves
():
for
moves
in
self
.
gen_moves
():
...
@@ -165,7 +175,6 @@ class State:
...
@@ -165,7 +175,6 @@ class State:
if
moves
and
max
(
self
.
colsizes
())
<
COLSIZE_MAX
:
if
moves
and
max
(
self
.
colsizes
())
<
COLSIZE_MAX
:
assert
max
(
s
.
colsizes
())
<=
COLSIZE_MAX
assert
max
(
s
.
colsizes
())
<=
COLSIZE_MAX
points
+=
s
.
score_points
()
return
points
,
s
return
points
,
s
def
find_groups
(
self
,
depth
=
FIND_GROUPS_DEPTH
,
minsize
=
2
):
def
find_groups
(
self
,
depth
=
FIND_GROUPS_DEPTH
,
minsize
=
2
):
...
@@ -233,31 +242,31 @@ class State:
...
@@ -233,31 +242,31 @@ class State:
for
i
,
j
in
combinations
(
color
,
2
))
for
i
,
j
in
combinations
(
color
,
2
))
def
score_points
(
self
,
multiplier
=
1
):
def
score_points
(
self
,
multiplier
=
1
):
remove
=
[]
#
remove = []
points
=
0
points
=
0
for
block
,
group
in
self
.
find_groups
():
for
block
,
group
in
self
.
find_groups
():
if
is_basic
(
block
)
and
len
(
group
)
>=
MIN_BASIC_GROUP_SIZE
:
if
is_basic
(
block
)
and
len
(
group
)
>=
MIN_BASIC_GROUP_SIZE
:
remove
.
extend
(
group
)
#
remove.extend(group)
points
+=
len
(
group
)
*
multiplier
points
+=
len
(
group
)
*
multiplier
elif
is_bomb
(
block
)
and
len
(
group
)
>=
MIN_BOMB_GROUP_SIZE
:
elif
is_bomb
(
block
)
and
len
(
group
)
>=
MIN_BOMB_GROUP_SIZE
:
points
+=
BOMB_POINTS
points
+=
BOMB_POINTS
remove
.
extend
(
group
)
#
remove.extend(group)
for
i
,
other
in
enumerate
(
self
.
blocks
):
#
for i, other in enumerate(self.blocks):
if
other
==
bomb_to_basic
(
block
):
#
if other == bomb_to_basic(block):
remove
.
append
(
i
)
#
remove.append(i)
remove
.
sort
()
#
remove.sort()
prev
=
None
#
prev = None
for
i
in
remove
:
#
for i in remove:
if
i
!=
prev
:
#
if i != prev:
while
self
.
blocks
[
i
]
!=
NOBLOCK
:
#
while self.blocks[i] != NOBLOCK:
self
.
blocks
[
i
]
=
self
.
blocks
[
i
-
COLUMNS
]
#
self.blocks[i] = self.blocks[i - COLUMNS]
i
-=
COLUMNS
#
i -= COLUMNS
prev
=
i
#
prev = i
if
points
:
#
if points:
points
+=
self
.
score_points
(
min
(
2
,
multiplier
*
2
))
#
points += self.score_points(min(2, multiplier * 2))
return
points
return
points
def
has_explosion
(
self
):
def
has_explosion
(
self
):
...
@@ -299,7 +308,7 @@ class State:
...
@@ -299,7 +308,7 @@ class State:
return
()
return
()
score
,
moves
=
min
(
self
.
score_moves
())
score
,
moves
=
min
(
self
.
score_moves
())
if
not
moves
:
if
not
moves
and
max
(
self
.
colsizes
())
<=
MAX_SPEED_ROWS
:
return
(
SPEED
,)
return
(
SPEED
,)
return
moves
return
moves
...
...
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