用于简单纸牌游戏的Python网络库

时间:2021-06-19 20:26:58

I'm trying to implement a fairly simple card game in Python so that two players can play together other the Internet. I have no problem with doing the GUI, but I don't know the first thing about how to do the networking part. A couple libraries I've found so far:

我正在尝试用Python实现一个相当简单的纸牌游戏,以便两个玩家可以在互联网上一起玩。我没有使用GUI的问题,但我不知道如何做网络部分的第一件事。到目前为止我找到的几个图书馆:

  • PyRO: seems nice and seems to fit the problem nicely by having shared Card objects in various states.

    PyRO:看起来不错,似乎通过在各种状态下共享Card对象来很好地解决问题。

  • Twisted with pyglet-twisted: this looks powerful but complicated; I've used Pyglet before though so maybe it wouldn't be too bad.

    用pyglet扭曲扭曲:这看起来很强大但很复杂;我之前使用过Pyglet,所以也许不会太糟糕。

Can anyone recommend the most appropriate one for my game (not necessarily on this list, I've probably missed lots of good ones)?

任何人都可以为我的游戏推荐最合适的一个(不一定在这个列表中,我可能错过了很多好的)

3 个解决方案

#1


8  

Both of those libraries are very good and would work perfectly for your card game.

这两个库都非常好,可以完美地用于您的纸牌游戏。

Pyro might be easier to learn and use, but Twisted will scale better if you ever want to move into a very large number of players.

Pyro可能更容易学习和使用,但如果你想进入大量的玩家,Twisted会更好地扩展。

Twisted can be daunting at first but there are some books to help you get over the hump.

起初扭曲可能令人生畏,但有一些书可以帮助你克服困难。

The are some other libraries to choose from but the two you found are mature and used widely within the Python community so you'll have a better chance of finding people to answer any questions.

还有一些其他库可供选择,但您发现的两个库已经成熟并在Python社区中广泛使用,因此您将有更好的机会找到人们回答任何问题。

My personal recommendation would be to use Pyro if you're just wanting to play around with networking but go with Twisted if you have grand plans for lots of players on the internet.

我个人的建议是使用Pyro,如果你只是想玩网络,但如果你有互联网上很多玩家的宏伟计划,请选择Twisted。

#2


5  

If you decide you don't want to use a 3rd party library, I'd recommend the asynchat module in the standard library. It's perfect for sending/receiving through a simple protocol.

如果您决定不想使用第三方库,我建议您在标准库中使用asynchat模块。它非常适合通过简单的协议发送/接收。

#3


3  

Twisted is the better of the two libraries but the time spent learning to use it but learning networking will take you similar amount of time (at least for me).

扭曲是两个图书馆中较好的一个,但学习使用它的时间,但学习网络将花费你相似的时间(至少对我来说)。

If I were you I'd rather learn networking it will be much more useful to you in the future. The concepts are the same for most languages so its more portable as well. If you are going to take this approach have a look at http://www.amk.ca/python/howto/sockets/ it will take you through everything.

如果我是你,我宁愿学习网络,这对你将来会更有用。对于大多数语言来说,概念是相同的,因此它也更便于使用。如果您打算采用这种方法,请查看http://www.amk.ca/python/howto/sockets/,它将引导您完成所有操作。

#1


8  

Both of those libraries are very good and would work perfectly for your card game.

这两个库都非常好,可以完美地用于您的纸牌游戏。

Pyro might be easier to learn and use, but Twisted will scale better if you ever want to move into a very large number of players.

Pyro可能更容易学习和使用,但如果你想进入大量的玩家,Twisted会更好地扩展。

Twisted can be daunting at first but there are some books to help you get over the hump.

起初扭曲可能令人生畏,但有一些书可以帮助你克服困难。

The are some other libraries to choose from but the two you found are mature and used widely within the Python community so you'll have a better chance of finding people to answer any questions.

还有一些其他库可供选择,但您发现的两个库已经成熟并在Python社区中广泛使用,因此您将有更好的机会找到人们回答任何问题。

My personal recommendation would be to use Pyro if you're just wanting to play around with networking but go with Twisted if you have grand plans for lots of players on the internet.

我个人的建议是使用Pyro,如果你只是想玩网络,但如果你有互联网上很多玩家的宏伟计划,请选择Twisted。

#2


5  

If you decide you don't want to use a 3rd party library, I'd recommend the asynchat module in the standard library. It's perfect for sending/receiving through a simple protocol.

如果您决定不想使用第三方库,我建议您在标准库中使用asynchat模块。它非常适合通过简单的协议发送/接收。

#3


3  

Twisted is the better of the two libraries but the time spent learning to use it but learning networking will take you similar amount of time (at least for me).

扭曲是两个图书馆中较好的一个,但学习使用它的时间,但学习网络将花费你相似的时间(至少对我来说)。

If I were you I'd rather learn networking it will be much more useful to you in the future. The concepts are the same for most languages so its more portable as well. If you are going to take this approach have a look at http://www.amk.ca/python/howto/sockets/ it will take you through everything.

如果我是你,我宁愿学习网络,这对你将来会更有用。对于大多数语言来说,概念是相同的,因此它也更便于使用。如果您打算采用这种方法,请查看http://www.amk.ca/python/howto/sockets/,它将引导您完成所有操作。