Home » Community » Forums » Multiplayer and Network Programming » How to "network" a single-player game effiently?
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 How to "network" a single-player game effiently?
Post New Topic  Post Reply 
These days,I have tried making a sing-player game to be a network game.
Previously,I proposed a cluster-computing structure for network game and I have finished a FPS game based on this structure.However,I am not satisfied with such a application and I need games of more types to verify the feasibility of this cluster-computing structure.
Now,I have aquired a source code of sing-player kart-game from internet and compiled it to a windows-version.This game is funny but not enough so that I hope to design a network version for it.The problem is that the primitive engine of this kart game is low-effient and the frames per second reduce rapidly when more than 8-karts appear on the screen.So I wanna design its server to be a cluster-computing structure.And I let ervery sub-server has a copy of the actual Track and part of karts involved.
So Is this idea of a high practicality?

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

That doesn't even make sense to have to use a cluster server for an 8 player game. Also what did you expect each server to compute? Cluster servers are used along with spatial partitioning normally to separate the load for certain areas. The server is only computing collisions and such it's not rendering anything. A server could probably support many more players. It sounds like the client is flawed.

 User Rating: 1287   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I means i need some clustering computing technology if the karts' number become large(more than 20 in on track),and it is not a easy problem just like 8-player game.And the previous 3d render(based on openGL) of this game is low-effient so i need a high-effient Render replaced.
Furthermore,the physics simulation is't good enough to make the kart's movement and collsion adequately close to reality.Naturally,I want a high-performance physics engine to replace the previous version.I choose Bullet(a open-source library of high performance) to do physics calculation instead because I have some experience programming a FPS game base on it.However,my FPS programming experience tells that simulation within large number of Objects will eat up a big cpu-time.So I have this idea above(divide the server's job to serveral parts for subservers).
Now,I have finished a p2p structure-version of the kart game.But it can just hold 6 karts running on it with acceptable FPS(Frames per second).

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

If you look at a game like Flatout, you will see it do about 20 cars at very high precision, both in rendering and simulation (the physics is very high detail, the destruction model is fine-grained, etc). Thus, you're probably doing something wrong. Now, can you find and fix everything you are doing wrong? If you could do all of that, then you'd be a star game programmer!

The trick for you is to figure out what you actually want to accomplish. It sounds to me as if you want to prove some clustering simulation technology. Draw out a goal, saying "cluster technology proven to do X." Now, try to break that goal down -- how do you get to that point? Why can't you say it's proven right now? Then design SMALL test cases that will show the steps from here, to your goal. Combine more and more of the small test cases, without worrying too much about making a nice game, and you will achieve your goal.

If your goal is, instead, to make a fun driving game that supports 20 cars, then chuck your cluster, build a new simulation using best practices, and serve it from a single server.


 User Rating: 1944   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Thank you for your intellectual advice although it sounds to me a little frustration.
To persue some fresh technology or to make a funny game is always a problem to me .Maybe my goal is always fuzzy.Adding some new technology and generating some fresh results may bring me a great happiness before.But this didn't last so long.


 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Currently,I find there may be a problem for the P2P structure of the Kart game.
For my Kart game,if there are 6 players(karts) in 1 track,every player control its own kart on his own machine and the rest 5 karts's running data are got from other players's machines.I just implement such a structure by using udp broadcast and every machine broadcast its own controlled Kart's running data.Consequently, if 2 kart are running closely to each other and the UDP packet arrives with a bigger delay,the 2 machine will have different game result:machine A believes Kart A is the 1st, machine B believes Kart B is the 1st.
In my LAN environment,this bigger delay may happens in a little probability but if this game runs on Internet,the problem may become more serious.If a C/S structure has been used for this game,such problem can be easily avoided.However,Is there good trick to solve this problem under Peer to Peer network structure?

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The Forum FAQ actually points at answers to this question.
For example, look for the pointers to Source or Counter-Strike networking.
In general, you want a server as arbiter of what "really" happens, and you then use various tricks to hide the discrepancies on the client side.

 User Rating: 1944   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Well.You means I shoud use a server to gether the running data of every kart ,gives the game's result and send the final result to every Peer?
I have ever considered such a arbiter.But It will result difference between What I have seen in 1 machine and What has really happened.
Quote:
For example, look for the pointers to Source or Counter-Strike networking

Can I get such a source?I know the Counter-Strike is a commercial game.


 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

You may want to take a close look at what it is you're sending from one user to the next. For instance, a player object may have many properties. Each player may have to send that data out to 20 other players which is highly inefficient. Instead, only send the linear and angular velocities of each object and have each client calculate the movement. Every few frames, you can send actual coordinate and angular data to be sure things stay in sync. How often these are sent could depend on network latency. The more latency, the more each client has to depend on its own calculations. You may still have "lag" under a high network load but should be pretty smooth with 20 or so players. Look into "dead reckoning".

 User Rating: 1177   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Quote:
Original post by michaelth
Can I get such a source?I know the Counter-Strike is a commercial game.

Try the Quake3 source code, it is freely available :)



 User Rating: 1141   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by coderx75
You may want to take a close look at what it is you're sending from one user to the next. For instance, a player object may have many properties. Each player may have to send that data out to 20 other players which is highly inefficient. Instead, only send the linear and angular velocities of each object and have each client calculate the movement. Every few frames, you can send actual coordinate and angular data to be sure things stay in sync. How often these are sent could depend on network latency. The more latency, the more each client has to depend on its own calculations. You may still have "lag" under a high network load but should be pretty smooth with 20 or so players. Look into "dead reckoning".

Yes,nice idea.I will try it.Actually,to make the every peer's data synchronous,I send the coordinate and velocity data very frame.



 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
But It will result difference between What I have seen in 1 machine and What has really happened.


That's latency for you. Better learn to deal with it.

When I said Source, I meant the Source game engine from Valve. There are articles about how it does networking around. Btw: did you check the references in the Forum FAQ?


 User Rating: 1944   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Thanks.I am reading the "Unreal Networking Architecture" now.Maybe I will find some good trick to solve my problem perfectly.But Why Can't I open the link"QuakeIII"?

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The Quake 3 link in the FAQ is broken and has been for some time (in retrospect I probably should have reported that to someone when I first noticed, but I got enough out of the other two links that I wasn't too concerned about it).

 User Rating: 1033   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

There's a blog entry of Shawn Hargreaves you should probably read called Network Compression: Just say no!

He was the lead programmer on the MotoGP games. Anyway the point that he's seeming to make in the article is that it can be ok in certain situations for there to be some inaccuracy in your simulations between clients.

That means that during the race the exact position will differ between peers due to latency. However this will be corrected with each subsequent update and smoothing can be used to hide the inaccuracy. What is NOT acceptable however is to have inaccruacy with regard to winning or losing. Therefore he gives an example of having the players position be peer-to-peer but having a single authorative machine that determines the true position and winner of the game.

Hope that helps someone.

Andy

 User Rating: 1195   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I think Shawn doesn't go far enough in his analysis, though. You can view game networking as a form of interaction, and interaction in turn is a form of communication. You can never get two communicating parties to be 100% in agreement, because they by definition have different reference frames (or they wouldn't be two separate parties). However, you can achieve a "good enough" common understanding.

Now, for networked gaming, as long as the players have a common understanding of what happened, then all is good. However, if, on one machine, a car crashes and burns in a cloud of smoke, and on the other machine, it doesn't, then players comparing notes (or using voice communication during the game) will not agree on the communication, and you have removed something important.

So, I agree that you should send only the amount of data you need to send to deliver a common understanding of what happens. Context will determine how much that is. However, once you send that data, actually spending a few CPU cycles on making that data take up fewer bytes on the wire is well worth the time. For home networking, it means there's less chance of uplink overload. For hosted games (like MMOs), network usage translates directly to dollars.


 User Rating: 1944   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Quote:
Therefore he gives an example of having the players position be peer-to-peer but having a single authorative machine that determines the true position and winner of the game.

well,you means I need a arbiter to give the game result,which is fair to every peer.That is just something "hplus0603" has proposed before.I has consider this method before and it naturally has some rationality for its equity.But This trick need extra transmission data because every peer need to send running data to it.And Is it increase the network latency?Or use some optimzing technoligies to reduce it.
I always think the Predict/Correct trick is something for cheating Player's eyes.All what this trick done is just to give a more smooth animation.Can Game result(1st or 2rd) be based on the Data which is got by interpolation?Of course not,it finally should be based on your "Postion"and Other peer's "Postion" got from NetWork Packets arrived.

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Maybe the most important charecteristic of the "arbiter" is that "the sharing of "packtet delay"'s random".This precise word is just what I find in Shawn's Blog

 User Rating: 1019   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: