[Tutor] Online Rock Paper Sizzors

Alan Gauld alan.gauld at btinternet.com
Fri Jun 22 12:23:14 CEST 2007


> From: Amadeo Bellotti <amadeo.bellotti at gmail.com>
> no this isn't a home work assignment.

Ok, Just checking :-)

> Ive never done web programming before i am pretty skilled
> in python i dont want an application like on a web browser.

OK, That would have been the simplest form of online game but...

> i want a client that each person can download.

OK, I assume from this that you want a multi player
game - for rock,paper,scissors I assume multi = 2? - rather
than just an interactive game against the computer?

> honestly i have no clue where to start with a web app

OK, If we are going for a networked game between
multiple users you have a choice to run a server centrally
with all clients connecting to that or to run on a peer to per
basis with the two participating machines forming a direct
connection. The latter is easy to program for the game
but more complex to set up the initial configuration. A
central server makes the game slightly more comlex
but setup is easier.

I'd probably opt for the server approach but keep it really
simple initially. Only allow two connections and simply
relay the results. This can all be done using simple
sockets (see my network programming topic on my tutor).

The sequence will be something like:

server awaiting connections
client A connects, server gives back (empty) list of other clients
client B connects,
server notifies all clients of user list
client B challenges A (or vice versa)
server notifies A that he has been challenged
A accepts and server henceforth refuses any more connections
server asks players to select a weapon
clients send responses
server compares responses and sends notification to both cliernts of 
score
repeat for as many turns as desired then report final score
open up for more connections
client C connects
server notifies all clients of new user list
client A challenges C
repeat as above...

Hopefully that's enough to give you somne ideas and get started.
Once you get that working you can enhance it to support multiple
games at once etc. Keep high scores, league tables etc etc.
Also you can introduce security with logins etc.

But get the basic game structure working first.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list