Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AZULSimu
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Xiaofei Wang
AZULSimu
Commits
6dc17896
Commit
6dc17896
authored
5 years ago
by
Xiaofei Wang
Browse files
Options
Downloads
Patches
Plain Diff
上传新文件
parent
5c44cc45
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
AZUL/naive_player.py
+50
-0
50 additions, 0 deletions
AZUL/naive_player.py
with
50 additions
and
0 deletions
AZUL/naive_player.py
0 → 100644
+
50
−
0
View file @
6dc17896
# Written by Michelle Blom, 2019
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from
model
import
*
from
utils
import
*
class
NaivePlayer
(
Player
):
def
__init__
(
self
,
_id
):
super
().
__init__
(
_id
)
def
SelectMove
(
self
,
moves
,
game_state
):
# Select move that involves placing the most number of tiles
# in a pattern line. Tie break on number placed in floor line.
most_to_line
=
-
1
corr_to_floor
=
0
best_move
=
None
for
mid
,
fid
,
tgrab
in
moves
:
if
most_to_line
==
-
1
:
best_move
=
(
mid
,
fid
,
tgrab
)
most_to_line
=
tgrab
.
num_to_pattern_line
corr_to_floor
=
tgrab
.
num_to_floor_line
continue
if
tgrab
.
num_to_pattern_line
>
most_to_line
:
best_move
=
(
mid
,
fid
,
tgrab
)
most_to_line
=
tgrab
.
num_to_pattern_line
corr_to_floor
=
tgrab
.
num_to_floor_line
elif
tgrab
.
num_to_pattern_line
==
most_to_line
and
\
tgrab
.
num_to_pattern_line
<
corr_to_floor
:
best_move
=
(
mid
,
fid
,
tgrab
)
most_to_line
=
tgrab
.
num_to_pattern_line
corr_to_floor
=
tgrab
.
num_to_floor_line
return
best_move
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