skip to navigation
skip to content

Not Logged In

Reversi 1.0

A version of the Reversi board game intended for casual play.

Latest Version: 1.2

An implementation of the popular Reversi board game, for use by one or two players. Some simple AI is included to provide a computer opponent, and if you are feeling lazy you can watch while two AI opponents slug it out.

The controls for the game are minimal, and hopefully self-explanatory, but here is a list:

Preparation Controls:

Language:
A selection box appears to enable the player to choose their preferred language. At time of writing the only options supported are English and Chinese, but if there is someone 'out there' interested in helping with other translations I will be happy to hear from them. If no language is selected the game will default to English.
Your name:
You can type anything you like here, it just helps to distinguish the players.
Mode:

Four modes are supported:

  1. Normal (human versus computer opponent).
  1. Person versus Person, in 'hot-seat' mode.
  1. Computer versus computer, what I like to call TV mode.
  1. Benchmarking mode, all graphics turned off. In this mode additional information is requested for the number of games to play.

The default mode is 'Normal'.

Token:
The game asks the first player to choose a token, Black or White. Click your choice or type 'b' or 'w', depending on UI (see below).

Game Play Controls:

Who starts is chosen at random.

Choose Tile:
Depending on UI this is achieved by either clicking on the appropriate tile, or typing in the tile coordinates as a space-separated pair of numbers, e.g., 5 6
Hints:
A hint mode is provided for each (human) player that can be toggled by either typing 'h' or clicking the appropriate button, depending on the UI you are using.
Quit:
Typing 'q', hitting 'Esc' and/or clicking the 'Close Window' icon (the details depend on the UI) causes the current game to be aborted.
Play Again:

You can elect to play again as many times as you want. The more games you play, your game statistics will be accumulated and displayed on the scoreboard.

At the time of writing, there is no mechanism for storing game statistics between sessions, so if you want to save your high-scores you will have to resort to a screen-shot!

Choice of UI: Console vs. Tkinter/ttk:

The game has been shipped 'hard-wired' for the tkinter/ttk interface. For most purposes this is (I believe) a nice and easy interface to use. However, particularly if you want to do a lot of bench-testing of different AI, you may wish to use the console interface instead. This is very easy do in the source code, just un-comment the console interface and comment the tkinter interface in the heading of the ui module.

An older version of the game also had a pygame interface, but this has been removed in the shipped version. There are several reasons for this:

  • At the time of writing, installing pygame for Python 3 is still something of a black art. It was felt that the difficulty of installing pygame outweighs any advantages of using it for a simple board game for end users.

  • Removing the pygame interface makes the packaging simpler (OK, so I'm lazy).

  • For a board game, the sophisticated handling of sprites (pygame's great strength) is not required. Tkinter/ttk offers instead a very good set of themed widgets with excellent hooks for callouts, making the ui very easy to write, and much nicer to use, than is possible with the graphics of pygame.

  • At the time of writing, pygame does not support unicode. This means that i18n with languages like, for example, Chinese, is not possible in a pygame interface using the Python i18n package. You just end up with a load of rectangular boxes on the screen. i18n with pygame is still possible, but it would require a lot of code, and the use of a lot of graphic images instead of text. As noted above, I am lazy.

    Why, in this day and age, is software being written that does not support unicode (expecially when that is one of the strengths of the language it is written in)?

Some history:

This implementation of Reversi is very loosely based on the Reversi game described in the book Invent Your Own Computer Games With Python by 'Al Sweigart <http://inventwithpython.com/>'_. While some of the algorithms may still be recognisable, this code has been designed from scratch from an object model rather than using the functional programming flow diagram approach.

Originally implemented with a console UI, the code was adapted to work with both pygame and tkinter/ttk graphics. However, due to lack of support in pygame for unicode, the pygame interface was dropped to enable i18n (see above for the polemic).

I have had a lot of fun designing some more intelligent AI for the more demanding player, although I expect this still falls well below tournament standard. Nevertheless, the result is more pleasing to my eye, and hopefully more bug-free and maintainable. The AI is designed to be pluggable, so it should be relatively easy to create new algorithms and implement them in future versions.

As you might have guessed from the citation above, my original motive for writing this was to learn Python. However, as I went along the project became a vehicle for learning a lot of other associated Pythonic stuff.

This little game introduced me to Pygame and NumPy, and then tkinter/ttk. In the later stages I found out how to use the i18n module for internationalization.

This project has been an opportunity for me to (re-)learn Eclipse, and an introduction to NetBeans. I have also looked at some other IDEs aimed specifically at Python, but I have not (yet) found one that will stay alive long enough to type 'Hello World!'.

I have also found out a lot I never wanted to know about CVS, and a lot I am very grateful to have discovered about Mercurial.

Finally, I am using this little piece of code to find out more about distributing Python software. If you are reading this, you will know I have succeeded :).

Author:

Bob Bowles <bobjohnbowles@gmail.com>

 
File Type Py Version Uploaded on Size
Reversi-1.0.tar.gz (md5) Source 2012-08-08 47KB
  • Downloads (All Versions):
  • 14 downloads in the last day
  • 64 downloads in the last week
  • 314 downloads in the last month