Your task is to download the ZIP file and alter the downloaded player.py
file for the Reversi game and then win a Reversi tournament against the players of the rest of the class.
This task will teach you about:
The solution can be generalized to other classical games, although in some cases this strategy does not lead to optimal solutions and you would use different approaches (e.g.: Go).
See README_EN.md
in reversi.zip.
The package containg also the file 'game_board.py' that contains the class of the gameboard. You can also test your player in a Reversi game using the reversi_creator.py
or headless_reversi_creator.py
scripts.
The file player.py
contains the MyPlayer
class with a few methods. You can use the method that is already implemented in the MPlayer
class called get_all_valid_moves
in order to get all the valid moves and thus focus only on your strategy and decision how to play the game.
method | input | output | explanation |
---|---|---|---|
_ _init_ _ | my_color , opponent_color | None | A player contructor. The color is either 0 or 1 |
get_all_valid_moves | board | list of coordinate tuples | Method returns for a given board all the valid moves. |
move | board (n x n game board) | r , c (row, column) a tuple - coordinates of your move | The input is 2D list - current game board. Method should return a valid move. Example: (0,0) means putting your stone to the position board[r][c] . If no valid move is possible return None . board values -1 for empty space and 0/1 for the stone color. The max time spent within the move method is 3 secs. This is the method you are supposed to alter. |
Example of MyPlayer implementation
class MyPlayer: '''super-smart indeed''' def __init__(self, my_color,opponent_color): self.name = 'username' #username of the studen def move(self,board): return (*,*)
Late submissions do not take part in the tournament and receive 0 points.
Points are given in the following way:
Evaluation | min | max | note |
---|---|---|---|
Algorithm quality | 0 | 4 | Evaluated based on automatic evaluation whether the player follows the Reversi game rules. |
Code quality | 0 | 5 | Comments, code structure, cleanliness, proper naming… |
Rank in the tournament | 0 | 6 | The tournament truly pits your code against the others. Based on the order in the tournament, we distinguish five levels and give them their respected point count: 1-2-3-4-6. If your player does not finish the tournament because of his mistake, you get 0 points. |
Upload a ZIP archive with the module agent.py
and any other possible modules you created to the Upload system. All the files must to be in the archive's root folder! The archive cannot contain any other folders!