Reversi is a simple game: in your turn, you must put new pieces in the board but you can only put them in places that would corner (or trap) your opponents pieces between the new piece and one or more of your the existing ones. . When you place a piece, every trapped piece of your opponent flips to your color. The player with most pieces in the end wins.
This is an experiment on javascript and html5: the board and pieces are drawn with
svg (with the amazing Raphäel JS library).
The javascript code tries to use pragmatic idioms as well as merging
techniques of the object-oriented
and the functional paradigms in ways that would make a purist of either shriek.
It's not intended as an example of good javascript (not even
of good programming) but as a little note to myself of things I've learned
about javascript which made me love it like I love python, and hopefully
it will make you say "hey, that dude sucks at JS, I'm gonna learn it and code that game
much better!". You can view the source code of this very page
(the script is called game.js) to fathom the sacrilege of the code, or you can
check out the git repository
if you're into that sort of thing.