Due Nov 15, 11:55pm.
Submit via eClass submission link on the main eClass course page.
Late submission (with 20% deduction) Nov 17, 11:55pm.
Submit via separate eClass link for late submissions.
In this assignment, you develop and then improve a simulation-based player for the game of Gomoku. You add your improvements to the same starter code as for Assignment 2, which is a random Gomoku player.
assignment3
contains:
Go3
player
Create a new file Gomoku3.py
inside your assignment3 folder.
Then implement a simulation-based "Flat Monte Carlo" player there.
The default player, when run without any of the behavior-changing
options below,
should work as follows:
In rule-based simulations, we restrict the number of moves that we choose from during simulation. For example, in class we looked at the MoGo patterns and some tactical rules in the case of Go. In this part of the assignment, you implement a rulebased policy with the rules below for your Gomoku3 player. The policy recognizes five types of moves. Go through the rules in order from most urgent (higher up in the list) to least urgent. For each rule, create the list of moves that match the rule. If the rule generates one or more moves, then randomly pick one of these moves. If the rule leads to an empty list of moves (no moves match), then proceed to the next rule.
Win
: if you can win directly, in one move, then only
consider one of the winning moves.BlockWin
: if the opponent can win directly, then
only play a move that blocks the win. For example, OO.OO
can be blocked
by a move OOXOO
.
Even if you cannot prevent the win, as in the case .OOOO.
,
or when there is more than one open four on the board,
you should generate a blocking move.
OpenFour
: if you have a move that creates an open four position
of type .XXXX.
, then play it.
Examples of this scenario are: .X.XX.
and .XXX..
BlockOpenFour
: play a move that prevents the opponent from getting
an open four. For example, the situation ..OOO..
can be blocked by
moves .XOOO..
or ..OOOX.
. Note that all moves that
block an open four should be generated.
Specifically, in patterns
.OO.O.
and
X.OOO..
all three moves work to block the open four and should be generated.Random
: if none of the previous cases applies, then
generate a move uniformly at random, as in part 1.
All the examples above are given for X
to play.
However, your code should work for both players.
In Gomoku, there are more rules that make sense.
For example, it is often a good move to make a threat that can be blocked, such as playing one of the empty points in
..XXXO
However, in this assignment you do not implement such other rules.
policy policytypeSets the playout policy to be used from now on to the given type. The argument
policytype
is either random
or rule_based
.
policy_moves
This command prints the set of moves considered by the simulation policy for the current player in the current position, in the format
= MoveType movelist
Where MoveType
is one of:
{Win, BlockWin, OpenFour, BlockOpenFour, Random}
.
Movelist
is an alphabetically sorted list of moves
(same sorting order as implemented in gogui-rules_legal_moves).
Example:
= BlockOpenFour b3 c2 d4
If playout policy is set to random
, then the policy_moves response should
also be of MoveType Random
.
If playout policy is set to rule_based
, then the command should
generate the move list according to the five types above.
genmove colorYour
genmove
command should generate a move
using the rule-based simulation player with your
new improved simulation policy.
assignment3.tgz
which can be uncompressed
with
tar -xf assignment3.tgz
Gomoku3.py
and put it in the assignment3
directory.
Follow the same general steps as in assignment 1 to
create your
presubmission.log
file and your
submission,
but (of course) using your assignment3
directory,
assignment3.tgz
as file name,
and assignment3-public-tests.gtp
as test.
Remember to include your new
presubmission.log
and readme.txt
.
play
commands will be for the color toPlay.
Clearing the board resets toPlay to Black.
There will again be 5 marks for this assignment.
presubmission.log
which shows
the log of your correct test execution, and your readme.txt
file
(as in Assignment 1).Created: Feb 25, 2019 Last modified: Aug 6, 2021
Martin Müller and Ting-Han Wei