On Fri, Sep 30, 2011 at 8:44 AM, Matthew Gardner <mjg82@byu....> wrote:
> 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 =).
> BYU Unix Users Group
> http://uug.byu.edu/ >
> The opinions expressed in this message are the responsibility of their
> author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
> List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list >
Another way to do this would be to have each game participant running both a
client and a server. One person, probably the one that starts the game, is
the authority and other players connect and register themselves with the
game. Whenever one player finishes a move you can either have that player
broadcast to all registered players what that move was, or route everything
through the authority and have the authority broadcast.
This removes the need for any kind of polling and allows each player to run
in a restful state, and writing a simple message listener is pretty easy.
This is a pretty common P2P setup used in games and it has pluses and
minuses, but i figured i'd put it out as an option.