Go is a timeless board game originating in China more than two millenia ago. It has relatively simple rules, and yet the strategy is very deep and rich. It is one of the few classic board games where the best humans still have an edge against computers. Read more about Go on wikipedia.
GoSuji is a straightforward implemenation of the game. It has real-time moves, automatically saved game progress, a nifty behind-the-scenes board analyzer that makes scoring the game very simple, and in-game chat. Users can find their active and finished games on the profile page. Open games to join can be found on the home page of the site, which also has the link for creating new games.
GoSuji was built using modern web development tools:
- Ruby on Rails
- The large majority of all application logic. Everything except for websockets is handled by Rails
- POROs are utilized to process moves and scoring actions (/lib directory). This helps maintain separation of concerns and keeps the models skinnier.
- Node.js & websockets
- A separate Node.js app is used to handle the realtime aspects of the site
- Receives data from Rails (via Redis) and sends this data to the necessary clients via websockets
- Uses the SockJS websocket library, and a wrapper I created that adds socket.io style named events and rooms on top of SockJS.
- Redis
- Provides pub-sub messaging layer that allows Rails to send data to the Node.js app
- Serves as a quick access data-store that holds temporary data during the game scoring phase
- Many of the other usual suspects
- jQuery, vanilla javascript, CSS, HTML
- Rspec, Capybara + Poltergeist for testing
The basic set of features is fully implemented and working beautifully (see first section for a brief description). However, I have many exciting ideas to make GoSuji even more awesome. In the works:
- User-created custom rooms where people can hang out, chat, and create games to play against others
- Timed games, with a wide range of settings (from blitz to leisurely turn based games)
- Game review, where one can navigate the moves of a finished game and try alternate sequences
- Exporting of games to SGF (smart game format)
- Self-balancing ranking system that aligns with the widely used kyu and dan ranks
- API for allowing user-created bots to play on the site
- Custom board shapes! This is the feature I am most excited about. There are a lot of possibilities with this idea. I will probably start with some simpler pre-set custom shapes, and then later build an interface that lets users create and share their own custom boards
-
Install the dependencies (older versions may work for some of these)
-
Ruby 1.9.3 or higher
-
Rails 4.0.0 or higher
-
Node.js 0.10.0 or higher
-
npm 1.2.0 or higher
-
Redis 2.4 or higher
-
PostgreSQL or SQLite
-
Setup the Rails app
-
Clone the repository:
git clone https://github.com/dwaltrip/gosuji.git
-
Install gems:
bundle install
-
Setup environment variables. The figaro gem is used to manage these. 1. Change the name of
config/application-(example).yml
toconfig/application.yml
. 1. If you aren't using the default port for Redis or if you modify the port used by the Node.js app, you will need to edit thedevelopment:
section ofapplication.yml
to reflect this. -
Change the name of
config/database-(example).yml
toconfig/database.yml
. To use PostgreSQL instead of SQLite, see this Railscast. -
Run the database migrations:
bundle exec rake db:migrate
. -
Setup the Node app
-
Clone the repository:
git clone https://github.com/dwaltrip/gosuji-node-server.git
-
Install packages:
npm install
-
Change the name of
development-config-(example).js
todevelopment-config.js
. Edit this file if you are not using the default port for redis. -
Run the tests and verify that they pass (Optional)
-
The gameplay integration tests use Poltergiest, which depends on PhantomJS. Follow these instructions to install it. Alternatively, you can skip the integrations tests.
-
Migrate the test database:
bundle exec rake db:migrate RAILS_ENV=test
-
If including the integration tests, start up Node and Redis (see section 5)
-
Run the tests:
bundle exec rspec
. To skip the integration tests, add this option to the rspec command:--tag ~integration
. -
Run GoSuji!
-
Start the Redis server:
redis-server
(my dev machine starts a background Redis process on start up, so I skip this step) -
Start the Rails server:
rails server
-
Start the Node.js server:
node server.js
-
Open your browser and visit
localhost:3000
. Go is a two player game, so you will have to open a second browser to play against yourself :)