Reversi / Othello
The game of Reversi was invented in London, in the last half of the 19th century. The game is played by two players: a red player and a green player. The players place counters of their respective colors alternately. Red plays first. Each counter must be placed such that it 'closes-in' a straight line of one or more of the opponent's counters (horizontal, vertical or diagonal) . All counters closed-in by the just placed counter then change color.
If it is not possible for a player to close in at least one of the opponents counters, he passes and his opponent can play.The game ends if the board is filled with 64 counters, or if none of the players can do a move. The player with the most counters of his color wins the game.
To help you play the game, the empty fields were you can play are marked with a number. The number indicates the number of counters changing sides with that move.
The java applet above allows you to play the game. It shows the board. It starts in a situation where red, the user is the first player, and green, the computer, moves second. You can change this by pressing new game: A window pops up where you can choose between several altenatives:
There is another button undo move in the applet. You can press this button to undo the last move. Note that you typically must press this button twice, because to change your move you must undo the computers move first, and then your move.
- Human versus computer: You play against the computer, and you move first.
- Human versus human: You can play the game against a friend (on the same computer. There is no network option).
- Computer versus human: You play against the computer, and the computer moves first. Note that you will have to click anywhere on the board before the computer does a move.
- Computer versus computer: This will let the computer play against itself. You will have to click in the board somewhere before each move: The players will wait to do something until you indicate you are ready for the next move. So if you do not mouseclick in the board, nothing happens.
There are two status lines. One indicates whose turn it is, and how many counters each player has. The other one tells you if the computer is thinking.
We encourage you to download the sourcecode. Here are a few reasons to do so.
- reversi.java just the java source. All you need if you have some experience with java
- reversi.zip a zipfile containing everything: the java file, a html page, the .class files and generated javadoc files.
- javadoc A description of the sourcecode in html form, just like the official java documentation.
- If you compile the code you can play reversi on your own computer, without any internet connection. You can also put this game on your own homepage, but please notify us and give a link to the source code.
- This applet comes with lots of detailed explanation of how this game was made. You can learn a lot about java applet programming by scrolling through it.
- It is a lot of fun to change the appearance, the difficulty level, or whatever. Try to improve it with your own ideas! If you run into trouble doing this, you may send us email and we will try to help you.
- This applet tells much about creating a board game in java. This applet uses the minimax principle that is very important in chess programs and many other games. It combines this principle with the alpha-beta search strategy that accelerates search. If you understand this program, it will be a lot easier for you to create other games.
- This applet has been trained with a genetic algorithm. The genetic algorithm is included in this sourcecode, so if you download it you can train it yourself. There is much experimentation to do here! If you want to learn more about Artificial Intelligence in board games, this is your chance.