Multiplayer online card game

Hey Corona community!

I’m trying to develop a multiplayer card game (much like urban rivals). Im trying to think which could be the best approach to start coding both the server and the client side.

I have thought of doing a simple matchmaking system. But once the game is found would it be better to stablish a P2P connection between the two players or to handle all the game/communication logic via push notifications(in some services the drawback of this functionallity could be the response time)? If the P2P option should be the chosen one, how could it be implemented in a corona/lua environment (lua sockets maybe)? Each of the player will have a 60 seconds or so to take his decissions. If the time is over the player who hasn’t made his choices will automatically lose the game. How to handle this timming issue in both approaches??

Thank you your time guys!
[import]uid: 193170 topic_id: 33382 reply_id: 333382[/import]

You have a couple of options on the P2P part for a live (non-time doesn’t matter turn based) game.

  1. Roll your own. You will need a server hosting solution where you can write a program that runs to pass packets around. This would be socket based. The upside to this is the server can enforce the rules of the game to cut down on cheating. The draw back is your j-random webhost won’t let you run your own servers, so your hosting costs are going to go up. Then you have to deal with your own scalability. If you’re servers work like they should and your players have decent network connectivity, then you will likely see under 1 second message passing.

  2. Use a service like PubNub. There is a project in the SampleCode/Networking folder for doing multi-player called MultiPlayerPubNub that can get you started. They are primarily a data passer but strive for sub-1 second times on delivery. Any game logic has to be maintained by your client however.

  3. MYDevelopers (the folks behind Glider, and the Corona Remote… find them in the forums) was working on some P2P code that worked on local area networks as well as on the Internet. I don’t know much about where they are with that project, but it’s home-grown Corona bits.
    [import]uid: 199310 topic_id: 33382 reply_id: 132690[/import]

Hey Rob,

Thank you very much for the fast response. I have been thinkig about this a while ago and I have consiodereded multiple choices, but still not sure of which can be the appropiate one.

  1. Rolling my own server is the last option I’m considering since this is my first approach to online gaming, and the scalability is going to be a real issue.

  2. I have considered PubNub as a P2P solution, but I need to store information in the cloud to be able to do the matchmaking (and to create statistics, leader boards, etc.), so I don’t want my client to handle all the game logic.

  3. The solution of MY Developers, called Corona AutoLAN, was a great option but it seems that the project has gone dead. Their forums are filled with spam and the matchmaking server is down, so their solution only works for a local network.

I have also tryed MOAI Cloud and Game Minion, as the server side solution, but I think that I really need to stablish a peer to peer connection once the game has been found, in order to deal with the turn system. I will consider to mantain both the server (for Data management, matchmaking, and any other service that I see fit like authentication) and maybe consider PubNub to overcome that P2P connection that I mention. Do you know another service, similar to MOAI Cloud or Game Minion, that I might consider?

Thank you. [import]uid: 193170 topic_id: 33382 reply_id: 132739[/import]

You have a couple of options on the P2P part for a live (non-time doesn’t matter turn based) game.

  1. Roll your own. You will need a server hosting solution where you can write a program that runs to pass packets around. This would be socket based. The upside to this is the server can enforce the rules of the game to cut down on cheating. The draw back is your j-random webhost won’t let you run your own servers, so your hosting costs are going to go up. Then you have to deal with your own scalability. If you’re servers work like they should and your players have decent network connectivity, then you will likely see under 1 second message passing.

  2. Use a service like PubNub. There is a project in the SampleCode/Networking folder for doing multi-player called MultiPlayerPubNub that can get you started. They are primarily a data passer but strive for sub-1 second times on delivery. Any game logic has to be maintained by your client however.

  3. MYDevelopers (the folks behind Glider, and the Corona Remote… find them in the forums) was working on some P2P code that worked on local area networks as well as on the Internet. I don’t know much about where they are with that project, but it’s home-grown Corona bits.
    [import]uid: 199310 topic_id: 33382 reply_id: 132690[/import]

Hey Rob,

Thank you very much for the fast response. I have been thinkig about this a while ago and I have consiodereded multiple choices, but still not sure of which can be the appropiate one.

  1. Rolling my own server is the last option I’m considering since this is my first approach to online gaming, and the scalability is going to be a real issue.

  2. I have considered PubNub as a P2P solution, but I need to store information in the cloud to be able to do the matchmaking (and to create statistics, leader boards, etc.), so I don’t want my client to handle all the game logic.

  3. The solution of MY Developers, called Corona AutoLAN, was a great option but it seems that the project has gone dead. Their forums are filled with spam and the matchmaking server is down, so their solution only works for a local network.

I have also tryed MOAI Cloud and Game Minion, as the server side solution, but I think that I really need to stablish a peer to peer connection once the game has been found, in order to deal with the turn system. I will consider to mantain both the server (for Data management, matchmaking, and any other service that I see fit like authentication) and maybe consider PubNub to overcome that P2P connection that I mention. Do you know another service, similar to MOAI Cloud or Game Minion, that I might consider?

Thank you. [import]uid: 193170 topic_id: 33382 reply_id: 132739[/import]

Unfortunately I don’t know of any other servers right now. I think blending PubNub and GameMinion might be harder than it seems, but then I don’t have any real experience with PubNub.

[import]uid: 199310 topic_id: 33382 reply_id: 132996[/import]

trueSensie,

I built a trick taking card game called “Schmyr”,with Corona that uses PubNub.

The card game was my first published app in the App Store. It’s a free download, you might want to grab it and see if you can get someone else to get it and see how my lobby and MP work.

My game plays quite well, but the biggest problem with MP is that unless the game gains major attention or traction, there are simply not enough players to support MP.

Users are very impatient. If they join the lobby and no one is there, they leave in seconds. It is very difficult to join other players when there is no one in the lobby and everyone leaves almost instantly.

BTW, my lobby doesn’t match players, users can select the table they would like to join. This sounds great unless you’re the only player in the lobby. :frowning:

After experimenting with PubNub and AutoLan, I decided on go with PubNub. I have no experience with Game Minion unfortunately.

Both AutoLan and PubNub each have their plus’s and each has drawbacks.

The biggest drawback both seem to have is “unreliability”. I’m thinking this is really some type of problem with socket connections and IOS. They seem to drop, or maybe appear to drop or maybe they actually drop, who really knows.

AutoLan is free and is almost real time, by far the fastest, but I experienced dropped connections that I couldn’t handle. This was with an early version of AutoLan, some of the connection dropping problems may have been worked around. I was very newb at the time also, but never got the consistency I was after.

PubNub costs $$ if your game actually gets played and unfortunately there is NO guarantee that the messages actually get delivered or received by other players so your code has to be much more robust than you’d expect because you always have to code in verification functions for EVERY message sent that is game changing to verify the message was received by EVERYONE, which in my case could be 4 player. This takes time and unfortunately slows game play.

PubNub does seem to “recover” from a dropped connection or dropped message quite well though and is the most consistent connection between players I found. It is not uncommon for a message to take 5 seconds before it is received, sometimes longer so this must be considered.

Having spent most quite a bit of time developing with PubNub, it is amazing what can be transferred in a message. PubNub is capable of supoorting a quite complex lobby system.

A combination of PubNub and your own server for Player data is a great combination and I suggest it.

You can upload the player’s data and then download them using network.request. You can then send any of this data to other player’s with messages thru PubNub. The only real limits are your imagination and the 1.7 kb message size of PubNub, I think that’s the message limit anyways.

Developing a MP game is no easy task, besides the unreliability, using multiple simulators and updating all files can be taxing. Developing a single player game is SO much easier than dealing with MP, IMO, just a heads up.

Good Luck,

Nail

[import]uid: 106779 topic_id: 33382 reply_id: 133011[/import]

Er… sorry for hijacking this thread…
But @RobMiracle you are Corona Staff now? :open_mouth:
Regarding truesensei’s query,
[text]I have thought of doing a simple matchmaking system. But once the game is found would it be better to establish a P2P connection between the two players
[/text]
Based on my own experience, I would advice you NOT TO GO FOR THIS APPROACH!

We created this Multiplayer Game Draw N Guess(for AppStore and Play Store) and initially went with this approach(using Autolan’s internet feature)… It was a spectacular failure… It may have been that the algorithm was faulty, but some suggested that sometimes routers reject this kind of P2P connection… well whatever the reason the game bombed…

A couple of months later, i found @overtorment’s pretty neat library NoobHub. This was similar to Pubnub in its functioning. The server side is written in Node JS and is VERY SIMPLE with no overhead; anyone can easily understand the server code in a couple of readings.

We updated our game to use NoobHub and since then the game’s been working pretty awesome. Absolutely no connection issues…
So I would strongly recommend this for real-time multiplayer games!

Goof Luck! [import]uid: 64174 topic_id: 33382 reply_id: 133019[/import]

Unfortunately I don’t know of any other servers right now. I think blending PubNub and GameMinion might be harder than it seems, but then I don’t have any real experience with PubNub.

[import]uid: 199310 topic_id: 33382 reply_id: 132996[/import]

trueSensie,

I built a trick taking card game called “Schmyr”,with Corona that uses PubNub.

The card game was my first published app in the App Store. It’s a free download, you might want to grab it and see if you can get someone else to get it and see how my lobby and MP work.

My game plays quite well, but the biggest problem with MP is that unless the game gains major attention or traction, there are simply not enough players to support MP.

Users are very impatient. If they join the lobby and no one is there, they leave in seconds. It is very difficult to join other players when there is no one in the lobby and everyone leaves almost instantly.

BTW, my lobby doesn’t match players, users can select the table they would like to join. This sounds great unless you’re the only player in the lobby. :frowning:

After experimenting with PubNub and AutoLan, I decided on go with PubNub. I have no experience with Game Minion unfortunately.

Both AutoLan and PubNub each have their plus’s and each has drawbacks.

The biggest drawback both seem to have is “unreliability”. I’m thinking this is really some type of problem with socket connections and IOS. They seem to drop, or maybe appear to drop or maybe they actually drop, who really knows.

AutoLan is free and is almost real time, by far the fastest, but I experienced dropped connections that I couldn’t handle. This was with an early version of AutoLan, some of the connection dropping problems may have been worked around. I was very newb at the time also, but never got the consistency I was after.

PubNub costs $$ if your game actually gets played and unfortunately there is NO guarantee that the messages actually get delivered or received by other players so your code has to be much more robust than you’d expect because you always have to code in verification functions for EVERY message sent that is game changing to verify the message was received by EVERYONE, which in my case could be 4 player. This takes time and unfortunately slows game play.

PubNub does seem to “recover” from a dropped connection or dropped message quite well though and is the most consistent connection between players I found. It is not uncommon for a message to take 5 seconds before it is received, sometimes longer so this must be considered.

Having spent most quite a bit of time developing with PubNub, it is amazing what can be transferred in a message. PubNub is capable of supoorting a quite complex lobby system.

A combination of PubNub and your own server for Player data is a great combination and I suggest it.

You can upload the player’s data and then download them using network.request. You can then send any of this data to other player’s with messages thru PubNub. The only real limits are your imagination and the 1.7 kb message size of PubNub, I think that’s the message limit anyways.

Developing a MP game is no easy task, besides the unreliability, using multiple simulators and updating all files can be taxing. Developing a single player game is SO much easier than dealing with MP, IMO, just a heads up.

Good Luck,

Nail

[import]uid: 106779 topic_id: 33382 reply_id: 133011[/import]

Er… sorry for hijacking this thread…
But @RobMiracle you are Corona Staff now? :open_mouth:
Regarding truesensei’s query,
[text]I have thought of doing a simple matchmaking system. But once the game is found would it be better to establish a P2P connection between the two players
[/text]
Based on my own experience, I would advice you NOT TO GO FOR THIS APPROACH!

We created this Multiplayer Game Draw N Guess(for AppStore and Play Store) and initially went with this approach(using Autolan’s internet feature)… It was a spectacular failure… It may have been that the algorithm was faulty, but some suggested that sometimes routers reject this kind of P2P connection… well whatever the reason the game bombed…

A couple of months later, i found @overtorment’s pretty neat library NoobHub. This was similar to Pubnub in its functioning. The server side is written in Node JS and is VERY SIMPLE with no overhead; anyone can easily understand the server code in a couple of readings.

We updated our game to use NoobHub and since then the game’s been working pretty awesome. Absolutely no connection issues…
So I would strongly recommend this for real-time multiplayer games!

Goof Luck! [import]uid: 64174 topic_id: 33382 reply_id: 133019[/import]