Reversi
Introduction
Welcome to my website's equivalent of the stocking filler - an implementation of
Reversi (aka Othello) done in JavaScript/HTML. I've even taken the trouble
to make it work in both IE/Win and Firefox (and maybe some others; who knows?).
The three most odious words in the English language are "cross-browser compatability."
How to play
Anyway, if you haven't played the game before, the rules are simple enough.
There are two players - Black and White. They take turns to move, with White
moving first. On each move you must put down one counter and capture at least
one of your opponent's counters. You do this by surrounding a contiguous line
of his counters (horizontally, vertically or diagonally) with your new counter at
one end and one of your old counters at the other end. The captured counters
change to your colour. You can capture in several directions at once.
If you have no legal moves then you forfeit your move. The one with the most
counters at the end wins.
You can choose any arrangement of human/computer versus human/computer. You
can even change players midway through the game.
Click here to play.
How it works
The computer's algorithm is a straightforward minimax search. Until the last
eight moves it uses weightings to favour key squares, then it switches to favouring
simple numerical advantage. (When it reaches the last eight moves it extends
its search depth so you might sometimes get a "this script is taking too long" message
from your browser; please let the script continue!) I stuffed the evaluation
function with weightings picked from the air, but actually it seems to be a reasonably
strong player. If you're not careful it could give you a pretty tough game.
The JavaScript files: