3D Reversi Rules and User's Guide

Quick Links:

  1. Play the game
  2. Download a pdf version of this guide
  3. View a static image of the game page

Table of Contents

Scope

On this site you can play the game of Reversi in 2D or 3D, against a human, or one of a number of AI players. You can also play a Tournament among AI players or run an Evolution to try to improve the ability of one of the AI players. You can also develop your own AI players and see how they do against the built-in ones. The focus of this site, and the reason for creating it, is to make it possible to play in 3D. But 2D is available also.

If you are up to it, or you feel adventurous, you can click right here (or on the main heading of this page) and start playing Reversi right away. Otherwise, read the information here and then proceed to the actual game page. It probably is best to open the game table in a different window and refer to it, and try things out, as you proceed. However, you can also see a static image of the game table here.

If you are familiar with my Mill game you will find that the Reversi game is organized similarly.

↑ Back to contents

Comparison of Mill and Reversi

You can skip this section if you are interested only in the Reversi game. I developed the Mill game first and learned a lot in the process. While the organization and the basic approach for the two games are closely related, there are some significant differences:

↑ Back to contents

The Rules of the Game

The game of Reversi (also known as Othello) is usually played on an 8x8 2D Board, as shown in Figure 1. The novel feature of this online version is that you can play it in 3D. But the easiest way to understand the rules is to start with the 2D rules. The transfer of those rules to the 3D case will be straightforward.

Fig. 1: Initial Board

The game is played by two players, usually denoted as Black and White. However, when I first played Reversi many years ago the players were Red and Green and I have used that color scheme on this site. The players have a supply of markers (or pieces) that are red on one side and green on the other. Thus the markers can be reversed (or turned or flipped) and switch color.

Figure 1 shows the initial state of the 8x8 2D Board. There is a grid with 8x8 = 64 intersections. At the start of the game there are red markers on 4-5 (horizontal-vertical) and 5-4, and green markers on 4-4 and 5-5. The players take turns placing markers on the board. Their goal is to enclose contiguous chains of the opponent's pieces between two pieces of their own. If they can do that the pieces in the enclosed chain change colors. The player with the most pieces at the end wins. For example, at the beginning, Red could play on 4-3 or 3-4 and flip 4-4, or play on 6-5 or 5-6 and flip 5-5.

The following four boards illustrate a possible sequence of the first four moves. The picture shows the status of the board after the indicated move.

Red places on 3-4 and flips 4-4
Green places on 3-3 and flips 4-4
Red places on 4-3 and flips 4-4
Green places on 5-3 and flips 4-3 and 5-4

Here is a list of specific rules:

  1. Starting with Red, the players take turns placing their pieces. The player whose turn it is is the current player, the other player is the opponent.
  2. Any stone placed by the current player must flip at least one of the opponent's pieces.
  3. The current player must play a legal placement if possible. If no legal placement is available the current player forfeits the turn, and the opponent becomes the current player.
  4. After each placement all of the opponent's pieces contained in enclosed chains must be flipped.
  5. The game ends when neither player can make a legal move. The player with more pieces wins.
  6. The game is a draw if both players have the same number of pieces at the end of the game.

To illustrate some aspects of the game, note the following:

The 3D Game

The 3D game is played exactly like the 2D game, except that now there are more neighbors for each point, and the chains of enclosed pieces can run in more directions. In fact, the number of directions increases from 8 to 26 neighbors. To see this note that an interior point and its neighbors in the grid form a 3x3x3 cube which contains 27 points. The innermost point is not a neighbor of itself, so that point has a total of 33-1 = 26 neighbors, each corresponding to a potential chain of enclosed opposing pieces. (On a 2D board we have 32-1 = 8 neighbors, and in n dimensions we have 3n-1 neighbors). You can place pieces in a three-dimensional array by using the interactive 3D display or in a two-dimensional cross section of the board.

↑ Back to contents

User's Guide

You can start the game right here. If you wonder what a specific control does you can hover over it and see a one or two word explanation pop up. However, you may prefer to read the detailed information below to know what this software does and get an idea of how it works.

Game Boards and Controls

The Table with the controls, the 3D game board, and three Cross sections by default measures about 1631 by 1039 pixels. This is quite large (certainly unrealistic to be used on a smartphone) but it fits on most modern lap or desktop screens. You may need to change the resolution setting on your screen to accommodate the whole table. You can also shrink the size of the table in the line labeled Scale: click on "<" or ">". See below for more information.

The default game table, meant for playing 3D Reversi, consists of three columns. The first column contains the game controls. The second consists of three cross sections, each of which is perpendicular to one of the three axes. The third column contains the three-dimensional board. You can also toggle the display to play in just two dimensions (by clicking on the button in the second row of the control column). In that case the middle column (with the cross sections) disappears and the game board turns two-dimensional.

↑ Back to contents

Playing the Game

Players may be human or one of ten AI players. To play a game select the participants in the lines labeled Red: and Green:, and then click on the Play button in the fifth row of the control column (originally labeled Play). Pieces that are already marked are shown as red or green circles in the 2D displays, and as red or green balls in the 3D display. Also present by default are smaller red or green circles or Balls whose colors indicate whose turn it is, and where that player can legally place a marker.

↑ Back to contents

The 3D Game Board

The 3D game board is moving in space initially to suggest that this is an interactive 3D display, and you can manipulate the game board to help you visualize the 3D game state. Specifically, you can:

  1. Left-click anywhere in the display to stop its movement. You can also toggle the movement by typing w or W anywhere in the game table.
  2. Left-drag the display to rotate the 3D board and view it from any angle.
  3. Middle-drag to zoom in or out.
  4. Right-drag to move the board.
  5. Cycle the grid from blank to parallel to the axes (the default) to showing all 26 directions, by using the keyboard command 'a'.
  6. Turn the board full-screen with the keyboard command 'f' or 'F'. Repeat, or use the Escape key or the space bar to exit full-screen.
  7. Type a period or a question mark to see a complete list of available keyboard commands. Repeat to remove that list.

↑ Back to contents

The 2D cross-sections

You can also place markers on the 2D cross sections. There is one cross section for each axis. You can toggle a display of the axes in the 3D board by typing 'A'. The radio buttons underneath each 2D board let you choose which of the possible cross sections is being displayed.

↑ Back to contents

The Control Column

This section contains a description of the available controls, listed from top to bottom.

↑ Back to contents

Keyboard Commands

The following keyboard commands are available:

↑ Back to contents

Parallel Processing

Modern computers usually have a number of cores, or CPUs, and can run several threads simultaneously. This is known as parallel processing, which JS handles by passing messages between the main thread and each of the individual sub threads, which in JS are referred to as workers. The issues involved in parallel processing are complex. The default number of workers in this software is the maximum number that your system can support. If your system does not provide this information, then the number of workers (W) is set to 4. However, you can set the value in the text field equal to any positive integer. The system will create as many workers as you specify, and then use them all if it can.

My own system provides 32 threads. When running a tournament or an Evolution the system frequently runs at a CPU utilization of 100 percent. However, the savings as far as the time required for the computation of a move, and the number of nodes visited, is not nearly as dramatic.

To illustrate this I had the system compute the first ply on the 6x6x6 board at depth 8, with the number of workers ranging from 1 to 32. JS does not let you measure CPU time accurately, and CPU time is of limited utility when running processes simultaneously. The times shown here are wall-clock time measured in milliseconds. However, other than routine system tasks, there were no other processes running on the system at that time. This chart shows wall-clock time plotted against the number of workers, on a log-log scale:

The red line shows what one would naively expect. Thus when using W workers, the CPU time should be T/W where T is the time taken by one worker. The fat looking dots represent the actual wall clock time taken by three separate runs. The fact that those three times are very similar for each number of workers indicates that the shape of the curve formed by the dots is not random. Thus increasing the number of workers in some circumstances actually increases the time used for the calculation. The reason for this is that the evaluation of some positions takes longer than others, and if the number of computer intensive positions is concentrated on a small number of workers the time required will increase. Of course, the precise values of the individual worker times depend on the current position.

↑ Back to contents

The AI algorithm

A rudimentary understanding of how the computer plays is useful for understanding how to use the controls. Here is an extremely terse introduction: The moves available to the computer form a tree rooted at the current board position. The computer examines that tree to a certain depth. It uses a formula (the static evaluation) to assign a value to each relevant leaf of the tree. It then determines which best static value the player can obtain with perfect play, and makes the required move.

There are many references to time on this page. A JavaScript code running in a browser has no facility to measure the amount of time used by the CPU, and in any case, the concept of CPU time becomes ambiguous when using parallel processes. All times in these notes are elapsed wall-clock time, but care was taken to ensure that they are measured only when the computer was essentially doing nothing but running the Reversi software. As a result, those stated times are reasonably comparable and reproducible on the particular machine they were obtained.

The following Table illustrates the performance of the computer algorithms on my particular Windows 11 machine. The software offers two engines, one written in JavaScript (JS), and one written in C++. As discussed above, the JS engine performs essentially just as well as the C++ engine, which is a significant difference between the Mill and the JS codes. Note that, while the JS version works with essentially any browser, the C++ engine may not work on your particular computer. It requires a compiled version of the C++ code that is part of the package.

The Table shows the time and the number of nodes visited in the Game Tree, for the computation of the first move on the 6x6x6 board, at depths running from 2 to 14 plies (i.e., half moves, move by just one player), employing 32 workers, and running on Google Chrome. There are two blocks in the Table, the first one corresponding to the C++ engine, the second corresponding to the JS engine. The Table shows data for a computation of the first move. The row headed Nodes gives the number of nodes of the tree visited by the code for this particular depth. This number is only a little larger than the number of leaves where the static evaluation is performed. The next row gives the Time measured in milliseconds (ms). The third row of each block, Nodes/Time, gives the number of nodes that were visited each millisecond. The row labeled Time Factor gives the ratio of the time for the current depth and the time for the preceding depth. It is a measure of the branching factor, i.e., the average number of nodes attached to a single node two levels higher in the tree.

Metric   Engine   Depth 2   Depth 4   Depth 6   Depth 8   Depth 10   Depth 12   Depth 14

Nodes

  C++

  34

  2,608

  77,397

  2,107,038

  43,071,461

  961,661,893

  24,316,471,858
Time (ms)   C++   1   6   92   2,680   55,060   1,254,422   21,034,466
Nodes/Time   C++   34.0   434.7   841.3   786.2   782.3   766.6   1,156.0
Time Factor   C++   -   6.0   15.3   29.1   20.5   22.8   16.8

Nodes

  JS

  34

  2,608

  77,370

  2,104,391

  42,871,518

  959,278,928

  -
Time (ms)   JS   4   13   113   2,774   58,083   1,379,941   -
Nodes/Time   JS   8.5   200.6   684.7   758.6   738.1   695.2   -
Time Factor   JS   -   3.3   8.7   24.5   20.9   23.8   -

Time (JS/C++)

  Ratio

  4.00

  2.17

  1.23

  1.04

  1.05

  1.10

  -

It is evident that JS and C++ perform similarly. It seems reasonable for a human to play against an AI at a depth of 8 or 10 (looking ahead 4 or 5 full moves). This will make the computer move in a few seconds or minutes. Human players of course can take any amount of time they wish.

The following Table shows similar data for computing the first move on the 2D 8x8 Board, again with 32 workers. This is the classic version of Reversi. All possible first moves are equivalent by symmetry. Therefore, for these particular data, the Symmetry check was turned off. Clearly the branching factor is smaller for a 2D Board, than in 3D, and as a consequence play can take place at a larger search depth. Depth 10 and 12 are reasonable AI search depths, and with some patience you might even play against an AI thinking at depth 14. It would be looking seven full moves ahead, which is likely to make the game challenging even for expert Reversi players. Remarkably, the JS Engine actually performs better than the C++ engine for most values of the search depth.

Metric   Engine   Depth 2   Depth 4   Depth 6   Depth 8   Depth 10   Depth 12   Depth 14   Depth 16   Depth 18

Nodes

  C++

  17

  203

  1,839

  19,935

  224,686

  2,484,667

  27,714,174

  306,469,888

  3,871,006,168
Time (ms)   C++   1   2   13   91   957   13,285   150,430   1,838,486   21,775,397
Nodes/Time   C++   17.0   101.5   141.5   219.1   234.8   187.0   184.2   166.7   177.8
Time Factor   C++   -   2.0   6.5   7.0   10.5   13.9   11.3   12.2   11.8

Nodes

  JS

  17

  203

  1,839

  19,935

  224,686

  2,484,667

  27,714,174

  306,469,888

  3,871,006,168
Time (ms)   JS   1   5   9   79   934   11,602   140,105   1,438,403   34,851,094
Nodes/Time   JS   17.0   40.6   204.3   252.3   240.6   214.2   197.8   213.1   111.1
Time Factor   JS   -   5.0   1.8   8.8   11.8   12.4   12.1   10.3   24.2

Time Ratio

  JS/C++

  1.00

  2.50

  0.69

  0.87

  0.98

  0.87

  0.93

  0.78

  1.60

↑ Back to contents

AI Players

The following Table lists the built-in AI players and their parameters explained above. They are ordered by decreasing performance in a specific tournament on the 6x6x6 board at depth 4, with 32 workers running on Google Chrome, playing 100 games for each pairing, for a total of 9000 games. So Arwen is the top player in that tournament, and Jolly places last, by definition. Jolly's parameters values represent my first guess at reasonable values, all other players are descendants of Jolly, in one way or another, by the built-in evolution process. Multiplying all weights with a constant positive factor will not alter the game play of the AI, therefore the largest weight is normalized to be 1000. All weights are integer. Unsurprisingly, placing a marker in a corner, almost whenever you can, receives the highest priority.

Player   Mob   Dif   Cor   C-Sq   X-Sq   Edg   IEd   Fac   IFa

Arwen

  13

  7

  1,000

  -1

  -9

  97

  -2

  4

  -1
Bilbo   13   6   1,000   -1   -8   94   -3   4   -1
Celebrian   14   6   1,000   -1   -8   91   -3   4   -1
Dwalin   13   7   1,000   -1   -9   105   -2   4   -1
Eowyn   84   17   1,000   -4   -26   72   -10   19   -4
Frodo   14   9   1,000   -1   -7   94   -3   5   -1
Galadriel   141   10   1,000   -8   -70   89   -20   14   -4
Hamfast   15   22   1,000   -9   -19   132   -2   2   -2
Indis   18   23   1,000   -8   -20   76   -6   5   -2
Jolly   20   40   1,000   -10   -20   100   -5   10   -2

↑ Back to contents

AI Tournament Rankings

The following Table shows the outcomes of tournaments among all 10 AI players, on various boards and at various depths. The players are indicated by the first letter of their name, and also by a specific background color, to help recognize patterns. As mentioned before, the names reflect the performance of the players at search depth 4 on the 6x6x6 3D board, as indicated in the last row of the Table. There is a remarkable diversity among the rankings in the various board and depth combinations. As many as half the players (A, C, E, G, and H) are the champion in at least one combination. Eowyn is the most versatile player, earning seven gold medals. Even Jolly, whose parameters are based essentially on guess work, places second in two disciplines, on the 4x4x4 3D board at depths 2 and 6. On the other hand, Jolly places dead last in 5 of the tournaments.

Board Depth Rank 1 Rank 2 Rank 3 Rank 4 Rank 5 Rank 6 Rank 7 Rank 8 Rank 9 Rank 10 Time (s) Red Wins Green Wins Draws
6x6 2 G E I B C D F A J H 7,939 1,779 6,392 829
6x6 4 E G F H J I A C B D 67,399 6,961 1,783 256
6x6 6 C B G E I J F A D H 521,201 3,925 5,043 32
6x6 8 E G C B D A F J I H 3,383 3,041 5,559 400
8x8 2 A G E B C D F I H J 75,390 4,183 4,447 370
8x8 4 E G C F D B A I H J 1,405,360 4,044 4,753 203
8x8 6 G E C B A D I H F J 23,074,428 3,779 4,923 298
8x8 8 E G B D C F H J A I 272,907 4,198 4,510 292
4x4x4 2 E J H C I F A D B G 16,055 1,792 7,126 82
4x4x4 4 H I J F C A D G E B 450,601 7,215 1,665 120
4x4x4 6 E J H F I C B D A G 9,329,508 4,393 4,383 224
6x6x6 2 E G F C A B I D H J 1,600,027 4,754 4,129 117
6x6x6 4 A B C D E F G H I J 78,061,633 4,312 4,578 110

↑ Back to contents

Recommendations

For an enjoyable 3D game against the computer I recommend using the 6x6x6 board and a search depth of 6 or 8, against Arwen, Bilbo, Eowyn, or Galadriel. The 8x8x8 game requires too many moves and the 4x4x4 board is too atypical, you can get a corner on the very first move. (Google Gemini likens the 4x4x4 play to a "knife fight in a phone booth".) For an enjoyable 2D game I recommend the classic 8x8 board, at depth 8 against Eowyn, or depth 10 against Galadriel. (At depth 10, in a 32 game match between Galadriel and Eowyn, Galadriel beat Eowyn every time.) You may have a hard time against Galadriel at that depth, I can't beat her.

↑ Back to contents