Box2D Forums

It is currently Fri May 24, 2013 2:17 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Jul 10, 2011 4:03 pm 
Offline

Joined: Sun Jul 10, 2011 3:41 pm
Posts: 1
Hey!

I've read much about the attempt at determinism in Jbox2d, and have found a simple workaround that ALMOST works.

I am working with Processing and Fisica (a jbox2d wrapper), so that adds another degree of separation -- (I'm also not all that versed in changing/compiling Java code, so the potential of adding strictfp to all the classes, and then recompiling both Jbox2d and Fisica is a little daunting).

This is my first version where each run is different [non-deterministic] (click to reset bricks)
Check : http://leifparker.com/_storage/explosive_test/

If you click the applet, it will erase the geometry and set it up exactly as previous, and the result will be entirely different. BUT -- If you reload the webpage, you'll notice that the first iteration is always the same. Thus my idea of just creating a new instance of the World variable -- and it does work!

Clicking will clear all the bricks, and start from scratch with a new World. [deterministic]
Check : http://leifparker.com/_storage/explosive_test_v2/

New problem : I quickly run out of memory. It seems that some part of the World constructor assigns a reference that doesn't get de-referenced when I instantiate a new World. Java's garbage collector isn't cleaning up the old World instance properly.

What can I do? Any ideas?

Thanks in advance,
L


Top
 Profile  
 
PostPosted: Sun Jul 10, 2011 7:30 pm 
Offline

Joined: Mon May 11, 2009 9:57 am
Posts: 17
I had this same problem a while ago. The source of the problem turned out to be in DynamicTree.java

There is an instance of Random there that's getting initiated without a seed. I changed it to this:

private final Random rand = new Random(0);

And that fixed all my problems. Just SVN the source and make your own build with that change. There may be a way to get at it through your own code, and thus skipping the hassle of making your own build, but I'm not sure.

Let me know if that helps out.

-Ben


Top
 Profile  
 
PostPosted: Mon Jul 11, 2011 3:02 pm 
Offline

Joined: Mon Jun 08, 2009 12:21 pm
Posts: 353
update to 2.1.2! that version should be much more deterministic


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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