Question

My friend challenged me to make a version of the popular game "Battleships" that we could play against each other. If you don't know the game, it's not really important because the hard part for me would be not to make the game but to figure out how we can play it against each other both from our computers. I have previously made the same game, only for one player (I'm using Python) so what I want to find out now is:

  • What is the easiest way? (I was thinking about Hamachi).
  • Where and with what should I start with?

Thanks in advance :)

Était-ce utile?

La solution

I would suggest starting out by making a non-networked version of the game that supports 2 players in the same program instance/window. This way you'll be able to re-model/design your code to support 2 players in the first place.

If that's working, you have to choose a networking library to use (or raw TCP/sockets), think about the problem a little bit, and refactor/split the program in such way that you can separate the 2 players into 2 separate programs communicating with each other over network.

For networking, RPC (Remote Procedure Call) is probably the easiest to use choice for you; for options, check out: What is the current choice for doing RPC in Python?. Or you might just want to go with something very primitive such as socket, or a bit less primitive such as ZeroMQ.

You might also be interested in this: http://pygnetic.readthedocs.org/en/latest/:

pygnetic is a library designed to help in the development of network games and applications in Pygame

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top