So, I'm thinking of writing code to play a board game, including the game
logic and the ability for people and computers to play the game. I can
imagine some pretty simple ways to do this with a typical app on a single
machine, but I would really like to make the game work through a browser
(probably locally hosted, but still a web app). I was wondering if any of
you had some advice as to how to go about doing this.
Here's what I've come up with so far. I'm pretty familiar with django, so I
thought I would use that framework. The game logic would reside in the
django app, server side, using the database to store the game state. Human
players would interact with the game through the views of the django app.
Computer players would also be servers somewhere, not necessarily django
servers, that would get the game state from the game server and respond in
similar ways to the human, over a socket. All the game server really cares
about is that there are players playing the game, not that they are humans
or computers, so I could plug in any AI against any other AI or human, and
play the game (I'm really in to probabilistic reasoning and AI, so this is
just a fun side project programming AIs for board games I like playing).
So far so good; this isn't all that different from bzrflag in CS 470.
Except board games aren't real time, they are turn based, and you need to
wait for each other player to go before you take your turn, and they could
take an indeterminate amount of time. How does the server notify players
when it is their turn, with the updated state? That seems simple enough for
the computer players, as the view method that processes one player's turn
can open a socket and communicate with the computer player. But how do you
do that with a human who's using a browser? I seem to remember a 598
project a year or two ago that showed a web framework that could receive
push notifications like this is a browser, but I don't remember much about
So, that's what I've been thinking for how to write this game. Any advice?
The game I'm planning on starting with, by the way, is Dominion. Then if
that works, maybe I'll do Labyrinth, then some other games. Then you can
have fun AI competitions =).