Box2D Forums

It is currently Thu May 23, 2013 7:04 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Is Box2D Deterministic?
PostPosted: Sun May 13, 2012 4:18 pm 
Offline

Joined: Sun May 13, 2012 4:08 pm
Posts: 5
I was wondering if the Java port of Box2D (or just Box2D in general) is deterministic, meaning that if I start the exact same simulation on two separate computers and have them run the exact same number of steps, will the result be identical for any number of steps?

From what I've read it is, but I just wanted to make sure and see if anyone had any experience running such a system involving simultaneous identical simulations or could offer insight into potential issues.


For those who are interested I'm working on a multi-user simulation environment, and I figured it would be easier on the network to have each computer run their own simulation and just get updated from a server, instead of running the simulation on the server, then sending the entire state of the world to every client.

Thanks!


Top
 Profile  
 
PostPosted: Mon May 14, 2012 5:18 am 
Offline

Joined: Mon May 14, 2012 4:33 am
Posts: 1
I think the best way to check it is TestBed. And as far as saw it is.


Top
 Profile  
 
PostPosted: Wed May 16, 2012 2:19 am 
Offline

Joined: Mon Jun 08, 2009 12:21 pm
Posts: 353
WIth java, usually. At least the floating point calculations tend to be more deterministic than box2d.

If you want strict determinism, checkout the 2.1.2.2 branch and add the
Code:
strictfp
keyword to each class. Then it will be completely deterministic.


Top
 Profile  
 
PostPosted: Wed May 23, 2012 9:13 pm 
Offline

Joined: Sun May 13, 2012 4:08 pm
Posts: 5
Thanks for the tip with strictfp. However would the Box2d classes also need to implement it as well? For my own game logic I can see how this would work, but when I tell the Box2d world class to take a step, would this still guarantee identical results? Or is it because the Box2d world is an instance of an object within a class that uses strictfp, it must also follow the rules?

Sorry if this seems obvious, but I checked the wiki page about it and it said that all calculations within said class are affected, but not weather calculations within other classes instantiated by this class are.

And sorry for the late reply, I got sidetracked away from this project for a bit :D

Thanks again!


Top
 Profile  
 
PostPosted: Wed May 23, 2012 9:23 pm 
Offline

Joined: Mon Jun 08, 2009 12:21 pm
Posts: 353
by each class I meant every single jbox2d class haha. You'll have to grab a svn copy, use the 2.1.2.1 branch


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group