======Reversi====== [[http://en.wikipedia.org/wiki/Reversi|Reversi]] is a two player game. =====The Problem===== Let us take a square playing board consisting of N x N square fields. The playing board is clearly delimited and board's edges do not neighbor each other. We have stones of two colors(traditionally black and white), one color per player. AT the beginning there are four stones in the middle of the board in this configuration: |B|W| |W|B| Player whose turn it is, then places a stone so that it closes off his opponents row. These stones then turn into his. It works like this: |B|W| |W|B| | |W| Player A placed his stone at the bottom, and this is the result: |B|W| |W|W| | |W| It is now Player B's turn. You can place stones either diagonally, horizontally or vertically. If a player cannot place a stone in a way that would take at least one stone, he loses his turn. The game ends when either the board is full, or neither player can place his piece. The objective is to have more stones than your opponent after the game ends. =====The Assignment===== You are to create a player, that will play properly (no exceptions and obeying the rules) and better than every other player. =====Objectives===== During this assignment we will see properties of following kinds of problems: *Basic pitfalls of searching within state space with an opponent, in dynamically changing environment. *Problems of search as combinatorial explosion. *Effectivity of search algorithms * Generalization of the assignment to other tasks, that can be solved using the same or very similar approach. =====Evaluation===== Just like in the whole course, foremost we value your effort. You do not have to worry about not finishing this course just because of this assignment if you at least try. However, during the upcoming weeks, there will be several control points, where we check your progress. At the end, all the algorithms will be compared by playing against the algorithms of all the other students and you should try to score as high as you can. *You should be able to understand the assignment and implement a simple player *You should be able to design and implement more sophisticated player, which can play (and win) against other players. More details are [[.:evaluation_and_terms|here]]. =====Submission===== Submission is done in two phases: - Upload of simple player, that can play according to the game rules - Upload of sophisticated player for the tournament * Upload only one .java file - ''Player''//Username//''.java'' that extends ''ReversiPlayer''. If you need more classes, create those as internal. =====Instructions for Running Reversi===== - Download {{:courses:a4b99rph:cviceni:reversi:reversi.zip|Reversi JAR ZIP file(new version 20. 11. 2014)}}. - In your favourite IDE create project ''Reversi'' - There is a quick walkthrough about creating project in NetBeans [[.:..:..:tutorials:netbeans:start|here]]. - Add dependency on ''reversi.jar'' (get reversi.jar by unpacking reversi.jar.zip) - google "How to add jar in ''$$$''", and replace ''$$$'' with the name of your favourite IDE (NetBeans, Eclipse, Intellij Idea, ...) - Create package ''cz.cvut.agents.rph.reversi.players'' - In this package create class ''PlayerXxxxxxxx'', and replace ''Xxxxxxxx'' with your username - e.g. student with username novakja1 should name his player ''PlayerNovakja1'' - NOTE: the name is case sensitive. - This class should extend ''ReversiPlayer'' - It should implement following methods: - **''getName()''**, that returns your username - **''makeNextMove(int[][] board)''**, that returns your move as ''ReversiMove'' for given game state (defined in variable ''board''). For finding out your player's colour, use method ''getMyColor()'' implemented in class ''ReversiPlayer''. - optionally you can override method **''init(...)''** for own initialization of the player. In that case, it is necessary to call ''super.init(...)'' as a first command in your method to ensure correct initialization of the player's parameters. - JavaDoc for library reversi.jar is {{:courses:a4b99rph:cviceni:reversi:javadoc.zip|HERE}} - For help with adding JavaDoc to the JAR library in you IDE use Google - **Source-code for the reversi.jar library will be available after the submission of simple players** - For running one game of one Reversi game, run ''cz.cvut.agents.rph.reversi.main.ReversiCreator'' - You can define which players will be started by using their class names as arguments of method **main(args)** - As testing oponent you can use already implmented player ''DummyPlayer'', i.e. player that randomly selects valid moves - So, our hypothetical student novakja1 should run the class ''ReversiCreator'' with parameters ''cz.cvut.agents.rph.reversi.players.PlayerNovakja1 cz.cvut.agents.rph.reversi.players.DummyPlayer'' ===== Tips & Tricks ===== You can set the time limit used for limitation of the reasoning time by setting the parameter ''timeout''. This can be set by %%--timeout=XXX%% parameter of class ''ReversiCreator'' where XXX is maximal time (in milliseconds) for which your player can stay in method ''makeNextMove()''. During debug and testing it can be helpful to set this parameter high, e.g. run the class ''ReversiCreator'' with parameters ''%%cz.cvut.agents.rph.reversi.players.PlayerNovakja1 cz.cvut.agents.rph.reversi.players.DummyPlayer --timeout=99000000%%'' ==== Source Code ==== Source code for the reversi.jar framework will be at your disposal after the submission of the siplme player. /*{{:courses:a4b99rph:cviceni:reversi:reversi-src.zip|ZDE}}. */ > {{page>courses:a4b99rph:internal:cviceni:tyden08#NetBeans}} =====For Download===== {{filelist>:courses:a4b99rph:cviceni:reversi:reversi.jar.zip&style=table&tableheader=1&tableshowdate=1&tableshowsize=1}} =====Hyperlinks===== * You can play against computer [[http://www.online-game.tv/play/reversi|here]]. * And [[http://www.flyordie.com/board-games/reversi.html|here]] you can play against other players.