[Tutor] how to build a multiplayer game?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Tutor] how to build a multiplayer game?

surya k
I have written the basic part of the game. Now I want to make it a multiplayer one. (Its not a web app, a OS application)

So, I just wanted to know how do it.

Which topics I should refer? Network Programming or Web Programming or Internet Client Programming. 

(There were the topics mentioned in Core Python Programming book).


Can anyone tell me how do we achieve such a application (I mean without having a web server). I am not really ready to setup a Apache HTTP server..... and all.

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

Dave Angel-3
On 04/11/2012 06:02 AM, Surya K wrote:
>
> I have written the basic part of the game. Now I want to make it a multiplayer one. (Its not a web app, a OS application)
> So, I just wanted to know how do it.
> Which topics I should refer? Network Programming or Web Programming or Internet Client Programming.
> (There were the topics mentioned in Core Python Programming book).
>
> Can anyone tell me how do we achieve such a application (I mean without having a web server). I am not really ready to setup a Apache HTTP server..... and all.    
>

You want to make two instances of the app talk to each other.  If
they're on the same machine (unlikely for a real game, but might be used
for testing), or if they're on the same local network, then the features
you need are available in the stdlib.  If you're going out on the web,
you need a host out there which will cooperate with the two apps (players).

Same local network:  Generally when both machines share a router or a
wifi connection, and would get to the web through the same ISP
connection.  If you figure out what their IP addresses are, they can
talk directly, using sockets.

Out on the web:  You need a server that's on the web that each machine
can reach.  It doesn't have to be your own, and I can't recommend any
particular one, but I'd bet google appserver would work.  For that
matter, email would work, if you don't mind a pretty long delay between
turns.

For any more specific advice, somebody else had better pop in.

--

DaveA



_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

surya k


> Date: Wed, 11 Apr 2012 06:42:40 -0400

> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Subject: Re: [Tutor] how to build a multiplayer game?
>
> On 04/11/2012 06:02 AM, Surya K wrote:
> >
> > I have written the basic part of the game. Now I want to make it a multiplayer one. (Its not a web app, a OS application)
> > So, I just wanted to know how do it.
> > Which topics I should refer? Network Programming or Web Programming or Internet Client Programming.
> > (There were the topics mentioned in Core Python Programming book).
> >
> > Can anyone tell me how do we achieve such a application (I mean without having a web server). I am not really ready to setup a Apache HTTP server..... and all.
> >
>
> You want to make two instances of the app talk to each other. If
> they're on the same machine (unlikely for a real game, but might be used
> for testing), or if they're on the same local network, then the features
> you need are available in the stdlib. If you're going out on the web,
> you need a host out there which will cooperate with the two apps (players).
>
> Same local network: Generally when both machines share a router or a
> wifi connection, and would get to the web through the same ISP
> connection. If you figure out what their IP addresses are, they can
> talk directly, using sockets.
Well, can we make the program so that user enters his IP, DNS addresses before starting?

Don't you think DNS is required as IP addr may be same for some people in this world.. after all, we only have limited number of combinations. (xx.xx.xx.xx .. )

* I even got a wild idea, can't we use a IRC channel, create a group and we make sure that each user of the game will be a member of the group??
approx, how much delay would be there??


> Out on the web: You need a server that's on the web that each machine
> can reach. It doesn't have to be your own, and I can't recommend any
> particular one, but I'd bet google appserver would work. For that
> matter, email would work, if you don't mind a pretty long delay between
> turns.

Hmm, google app engine is a nice option but thing is I don't know how to use it.


> For any more specific advice, somebody else had better pop in.
>
> --
>
> DaveA
>
>
>



_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

Jerry Hill
On Wed, Apr 11, 2012 at 9:30 AM, Surya K <[hidden email]> wrote:
> Well, can we make the program so that user enters his IP, DNS addresses
> before starting?

You could, sure.  That's fine for testing purposes, but most people
don't know their own IP addresses.  Many people don't have a DNS entry
for their home PC.  Also, what about NAT?

> Don't you think DNS is required as IP addr may be same for some people in
> this world.. after all, we only have limited number of combinations.
> (xx.xx.xx.xx .. )

Again, not every computer has a DNS address.  If you are going to ask
a user to hand enter their IP address, it would make sense to accept
either a numeric IP address, or a DNS name.


> * I even got a wild idea, can't we use a IRC channel, create a group and we
> make sure that each user of the game will be a member of the group??

Sure, but now you have to write (or embed) an IRC client.  Do you need
to worry about someone joining your channel that isn't using your game
client?  Does that have potential security implications?

> approx, how much delay would be there??

That depends on the delay from each client to the IRC server.

> Hmm, google app engine is a nice option but thing is I don't know how to use
> it.

You're going to have to learn quite a bit about networking and
probably client / server architecture to write a networked game.

--
Jerry
_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

Chris Fuller-5
In reply to this post by surya k

I think you're on the right track with the IRC idea, but start with something
simpler.  You can find tutorials or working programs using the asynchat module
to make a really basic chat client.  Then you build a higher level protocol on
top of that.  It should take care of most of the low level networking for you.  
But when you're ready for that, look up nonblocking I/O and the select()
system call.

http://pypi.python.org/
http://code.activestate.com/recipes/langs/python/
http://docs.python.org/howto/sockets.html#non-blocking-sockets

Cheers
_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

Alan Gauld
In reply to this post by surya k
On 11/04/12 11:02, Surya K wrote:
> I have written the basic part of the game. Now I want to make it a
> multiplayer one. (Its not a web app, a OS application)
>
> So, I just wanted to know how do it.
>
> Which topics I should refer? Network Programming or Web Programming or
> Internet Client Programming.

That all depends on how you decide to build the game. And what kind of
interaction you need. The fastest most direct route is to use raw peer
to peer sockets and send string messages between the two computers.
But then you need to decide how to set up the connection, who is master
anmd who is slave per session etc. A lot less work if you adopt the web
model of an app server in the middle and both players connect to that.

For straight sockets you should find examples in Wes' book.
Or you can read the network programming topic in my tutorial.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] how to build a multiplayer game?

Alan Gauld
In reply to this post by surya k
On 11/04/12 14:30, Surya K wrote:

> Don't you think DNS is required as IP addr may be same for some people
> in this world.. after all, we only have limited number of combinations.

DNS only translates a names IP address into a numeric IP address. It
does not create any extra addresses - thats why we are running out of IP
numbers!

You may be thinking of NAT which translates a public IP address into
a local network address and thus allows many computers to share the same
set of private IP addrewsses - 198.162,x.y for example can be
used on any LAN and the LAN will be seen from the outside as another
public IP address.

But all of that would be handled by whatever network configuration you
and your users have set up. The only exception might be that to get
through a firewall you need to open up a particular port number.

> * I even got a wild idea, can't we use a IRC channel, create a group and
> we make sure that each user of the game will be a member of the group??
> approx, how much delay would be there??

Yes thats a possibility too. But then you will need an IRC server
somewhere. Setting up an IRC server is not much different from
setting up a web app server.

Delay on the internet is highly dependant on routing. If your packet
happens to go the wrong way it can wind up jumping around all manner of
very busy/slow networks before it reaches you, in which case it might
take a few seconds to reach you. OTOH it might rout via a direct link
betwen the two ISPs involved and the delay will be <=100ms...

Part of the challenge of network programming is deciding how to deal
with those two scenarios. It's perfectly possible for packets to arrive
out of sync (ie packet two arrives before packet 1 because they were
routed differently). Do you hold packet 2 and wait for the late packet
or request a resend as soon as packet 2 arrives? There are no right or
wrong answers, just different choices for a given scenario.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor