othello_4
othello_4
AI - Fall 2024
Now that you have an Othello infrastructure in place, you are ready to do something useful with it. In
particular, you can imagine your script playing a game against another script by way of a moderator
script whose job it is to query each of the two scripts in turn asking them: given this board and a token
(corresponding to their side), what move should be made? At this point, the queried script should
respond with a preferred move.
For this to be practical, time has to be taken into account. In particular, it is often the case that when you
look at a situation (any situation), you might amend your initial impression with a subsequent view. It
is this way with game playing, too, in that if your script has more time, it might be able to come up with
a better course of action (move to play). Therefore, what constitutes a move declaration, when called
from the command line, is the final integer that a script prints before it either terminates voluntarily or
gets cut off.
Othello Lab 4: Play 2000 games against Random, getting the largest percent of tokens.
In particular, the moderator (the Othello 4 grader) will pit your script against Random in 2000 games,
where your script will play alternating games as x and 0, with the grader accumulating the following two
numbers at the end of each game: total number of tokens on your script’s side and the total number of
tokens on the board. You are looking to maximize this ratio.
The Othello 4 lab is an extension of your Othello 3 lab. The extensions are:
(A) define a quickMove() function which can be directly called by the grader
(B) display the preferred move (quickMove()) when called from the command line
(C) accept a condensed game transcript as a command line argument.
(D) accept an s flag on the command line, suppressing all but the first and last snapshot from printing
When called from the command line, your Othello 4 receives the same input as your Othello 3 lab (with
the addition of condensed move transcripts and print suppression, described below). After the Othello
3 part of your script has run, if the game is not over, it should print out a preferred move according to:
Where mvPref is your preferred move from among all the possible moves. Please see the description
of quickMove(), below, for details on how the preferred move could be determined.
When the Othello 4 grader is running as a moderator, it is the moderator’s responsibility to make each
indicated move, to determine whether one side or another must pass, and also when the game is over. In
this mode, your script will always receive a board and a token where a move is possible, and the
responsibility of your script is to print or return a valid move, depending on how it is called.
def main():
. Othello 3 script to run if called from cmd line ...
A trivial way to finish quickMove() is by doing: return [*possibleMoves |[@], but this would
be quite poor as it is equivalent to what Random does.
When the moderator nee grader is running a tournament, it will call quickMove() on the order of
2000*30 times. Printing in this function is a bad idea when submitting to the grader. At the end of the
tournament, the moderator will print out a condensed transcript of the three worst games. A particularly
grievous example is: 19344352371110 9262951453059465544233340202125241842. Each
move occupies two bytes and single digit moves have an underscore as the first character (note the _9
in the example). Condensed transcripts may have negative numbers, which should be ignored. The only
one you will see in this lab is a -1, indicating a pass. Your script must be able to handle a condensed
transcript being handed to it in place of a move.
In addition, the inclusion of an s or S on the command line says that all snapshots that are not the first
and the last ones should be suppressed from printing. This is because for some debugging you are not
interested in the (presumed correct) intermediate states, but you do want to know the resulting situation
after certain moves.
It turns out that analyzing an Othello board is a non-trivial task, and there is no uniform rule of thumb.
Strategies such as the obvious ‘make the move giving you the most number of tokens’ may not actually
work in your favor. The below describes some possible strategies.
Othello strategies
You may wish to consider implementing some form of the strategies below or craft your own preferred
move. You may also research this topic on the internet. You may share ideas with your colleagues, but
sharing your code, as always, is an integrity violation, as is using another person’s code.
2) If you can play to a safe edge position (one that can’t be converted), then do so. => ~ 69%
3) If you can avoid playing next to a corner that isn’t yours, then don’t => ~ 74%
Other strategy concepts include mobility and stability. Places where you may read about other strategy
ideas include:
http://radagast.se/othello/Help/strategy.html
https://bonaludo.com/2017/01/04/how-to-win-at-othello-part-1-strategy-basics-stable-discs-and-
mobility/
https://www.ultraboardgames.com/othello/tips.php
and
http://samsoft.org.uk/reversi/strategy htm
The current grading on this lab, where the ratio is your tokens vs. total tokens, is defined by the
piecewise function:
81% ratio => 100% grade
71% => 88%
52% => 50%