Chipmunk and networking

Official forum for the Chipmunk2D Physics Library.

Chipmunk and networking

Postby savior » Sun May 11, 2008 5:25 pm

Hi, I'm planning a 2D top down vehicle shooter, and I'd like to include multiplayer support, using networking, over LAN (low latency, less worrying about bandwidth).

My question is if it's possible to use chipmunk as the physics library for this project, and I'm asking because from what I've seen, sometimes, the simulation is not always the same on my computer, when running the demos. Could this cause any problems with the game, like, one person sees one thing, and another sees another, just because of chipmunk?

Any troubles that may arrise from this unequal simulation? How should I handle this?
savior
 
Posts: 8
Joined: Tue Jan 01, 2008 5:24 pm

Re: Chipmunk and networking

Postby slembcke » Mon May 12, 2008 1:02 am

You are correct, given a different processor or compiler, the physics won't run exactly the same due to floating point errors. When writing your networking code you are going to have to keep that in mind.

I've never really written a complicated networking game, so I don't really have any experience to draw on. If I was implementing such a thing, I'd be continually sending out snapshots of the objects. If there's only a few objects, you could probably just send out a full snapshot on every packet. If you have a lot of objects, send out a few of the objects at a time.

On the other hand if you are assuming low latency, maybe only run the physics server side. The clients then just display objects using the last know positions and dead reckoning. Would certainly make writing the client code easier.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Chipmunk and networking

Postby savior » Tue May 13, 2008 4:56 pm

Thank you very much for your help, that gave me some nice new ideas to have in mind.

To clarify, I don't plan to use multiple compilers, since I'm using only Delphi, so you can assume that all the versions running will be exactly the same. But the processors, no way.

Onto the new questions :mrgreen:

Does anyone knows how can I handle this floating point errors on the application?

If I send snapshots of objects, what would they contain? Forces? Heading? Can I set it directly in chipmunk, or should I do something like this:
Given the client's current position
And the desired position received from the server, do:
Calculate force so that current position becomes desired position. Apply.

Something like this?

I could also only send the snapshots that are "in range" of the client (like, distance less than 30 units), an easy optimization to reduce the snapshots.

I'm also considering doing the physics server side, I'm not sure however about the responsiveness client-side, that's something I should experiment to see it working. However, I'm not sure about the dead reckoning (heh, never did something like this, either).

Thank you for your help, and pleased to hear any other idea on this subject.
savior
 
Posts: 8
Joined: Tue Jan 01, 2008 5:24 pm

Re: Chipmunk and networking

Postby savior » Tue May 13, 2008 9:11 pm

I also have another question:

Is chipmunk deterministic, or non-deterministic?

From what I've googled, deterministic physics engines should be ideal for networked games.
savior
 
Posts: 8
Joined: Tue Jan 01, 2008 5:24 pm

Re: Chipmunk and networking

Postby slembcke » Tue May 13, 2008 10:53 pm

Chipmunk is deterministic, but not in a simple way. As long as collisions are processed in the same order, the simulation will be deterministic. Collisions are considered in the order that they are reported by iterating a hash. The hashing order is determined by shapeIDs (created specifically to deal with the determinism issue). Again, a different processor or compiler will also generate different floating point code that will produces slightly different simulations after many complex interactions.

The documentation for cpResetShapeIdCounter() is a bit vague, but you should start there. What's not clear in the documentation is that the shapeID counter is global, so you can't really be adding shapes to more than one space at a time.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Chipmunk and networking

Postby savior » Wed May 14, 2008 10:22 am

Ok, thank you.

I'll try to make a client/server simulation, and see if it works. Otherwise, I'll go for the server only simulation.
savior
 
Posts: 8
Joined: Tue Jan 01, 2008 5:24 pm

Re: Chipmunk and networking

Postby slembcke » Wed May 14, 2008 12:05 pm

I had bookmarked a couple of good articles on the Quake 3 and Unreal networking models a while back. I'll see if I can dig up the links when I get home.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Chipmunk and networking

Postby savior » Wed May 14, 2008 8:24 pm

Ok, thanks.

Meanwhile, I've been googling, and I've found this very interesting topic on the subject:
http://www.box2d.org/forum/viewtopic.ph ... &sk=t&sd=a

It's a good read, plus, follow the links there.
savior
 
Posts: 8
Joined: Tue Jan 01, 2008 5:24 pm

Re: Chipmunk and networking

Postby supertommy » Mon May 19, 2008 9:00 am

slembcke wrote:I had bookmarked a couple of good articles on the Quake 3 and Unreal networking models a while back. I'll see if I can dig up the links when I get home.


Maybe you mean the ones linked to in the sticky post in the networking section on the idevgames forum?

http://www.idevgames.com/forum/showthread.php?t=13402

Those three pages are definitely very interesting.
supertommy
 
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm

Re: Chipmunk and networking

Postby slembcke » Mon May 19, 2008 5:38 pm

Why yes in fact. I got them out of the iDevGames irc at some point. I had forgotten that they were on the forums.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron