From: Eric K Idema Date: 2008-04-01T22:46:02+09:00 Subject: Re: Web-based games? On 20:28 Tue 01 Apr , Mathijs Claassen wrote: > Hal Fulton wrote: > > Who's interested in developing a few web-based games? > > Who isn't?:) > > Take a look at vying.org. It hosts several classic and modern (board) > games. The API has recently been open sourced. Thanks for mentioning Vying Games (vying.org), Mathijs! I was planning on making an ANN email later when the library reached version 1.0, but I suppose there's no time like the present. Anyway, Vying Games is a rails based site that supports multi-player, turn-based strategy games. The rails code is closed source, but the library it's built on is open source. The code is over here: http://vying.org/dev/public There are 17 games on the production server and something like 23 in the library (some in various stages of incompleteness). There's some basic AI, and bots for most of the games. From a development standpoint, I think the library gives a very nice, simple interface for adding games in fairly few lines of code. Games that use a lot of the existing data structures can be coded up in as little as 100 lines of Ruby. Here's a quick sample of what the code looks like in irb: >> g = Game.new Othello => # >> puts g board: abcdefgh 1 1 2 2 3 3 4 wb 4 5 bw 5 6 6 7 7 8 8 abcdefgh turn: [:black, :white] => nil >> g.players => [:black, :white] >> g.has_moves => [:black] >> g.moves => ["d3", "f5", "e6", "c4"] >> g << "d3" => # >> puts g board: abcdefgh 1 1 2 2 3 b 3 4 bb 4 5 bw 5 6 6 7 7 8 8 abcdefgh turn: [:white, :black] => nil >> puts g.history.first board: abcdefgh 1 1 2 2 3 3 4 wb 4 5 bw 5 6 6 7 7 8 8 abcdefgh turn: [:black, :white] => nil >> g.final? => false >> g << g.moves.first until g.final? => nil >> puts g board: abcdefgh 1bbbbbbbb1 2bbwwbwbb2 3bwbbbbwb3 4bbbbwwbb4 5bwbwwbbb5 6bbwbwbwb6 7bwbbbwbb7 8wwwwbbbb8 abcdefgh turn: [:white, :black] => nil >> g.score( :black ) => 45 >> g.score( :white ) => 19 >> g.winner?( :black ) => true There's a lot more to it than that, but that's the heart of the library. There's no GUI right now (other than the closed source server), but I plan on adding an api to interact with the server. At that point it should be pretty easy to write bots to play online (or other applications). If anyone's interested in contributing, send me an email. I'll give commit access to the svn repository to anyone willing to send me even a tiny patch. Eric -- eki@vying.org