eugene-og / threes-company

Automatically exported from code.google.com/p/threes-company
0 stars 0 forks source link

Forces not being applied evenly #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If a force blob is near another blob and activates its force, it moves much
more than the other blob. I think they should both move the same amount.

I tested this with size 5 blobs.

Original issue reported on code.google.com by dbenamy on 14 Dec 2007 at 4:29

GoogleCodeExporter commented 9 years ago
I went into LocalGameState.applyForces and added this:
if (f.x > 0 || f.y > 0) {
    System.err.println("In applyForces():");
    System.err.println("Applying force " + f.x * 1000 + ", " + f.y * 1000 + " to " + obj1);
    System.err.println("Applying force " + f.inverse().x * 1000 + ", " + f.inverse().y *
1000 + " to " + obj2);                  
}

A snippet of the output of 2 side 5 blobs with one of them pushing is:
In applyForces():
Applying force 1.7606238725647678, 0.13423125811484507 to Game object of type
PushBlob owned by username2 with position (3.7918767082597458, 
4.984132527265689) and
radius 1.5
Applying force -17.60623872564768, -1.3423125811484509 to Game object of type
DeathRayBlob owned by username2 with position (8.710902396020124, 
5.359162661217838)
and radius 1.5
In applyForces():
Applying force 1.7575430672913945, 0.13399637525639044 to Game object of type
PushBlob owned by username2 with position (3.784065405738451, 
4.983536987820105) and
radius 1.5
Applying force -17.575430672913946, -1.3399637525639043 to Game object of type
DeathRayBlob owned by username2 with position (8.711683526272253, 
5.359222215162396)
and radius 1.5
In applyForces():
Applying force 1.7544783877073236, 0.13376272183234036 to Game object of type
PushBlob owned by username2 with position (3.776267724015307, 
4.982942486834183) and
radius 1.5
Applying force -17.54478387707324, -1.3376272183234037 to Game object of type
DeathRayBlob owned by username2 with position (8.712463294444568, 
5.359281665260989)
and radius 1.5
In applyForces():
Applying force 1.7514296935766904, 0.13353028715101012 to Game object of type
PushBlob owned by username2 with position (3.768483592043855, 4.98234901889129) 
and
radius 1.5
Applying force -17.514296935766904, -1.3353028715101012 to Game object of type
DeathRayBlob owned by username2 with position (8.713241707641712, 
5.359341012055278)
and radius 1.5

These forces look pretty different to me. I'm not missing something am I? This 
is the
problem? If so, Force.inverse() is probably broken.

Original comment by dbenamy on 15 Dec 2007 at 8:08

GoogleCodeExporter commented 9 years ago
Running the force test case produces:
junit.framework.AssertionFailedError: Coordinates should be equal (expected 
(-10.0,
10.0), got (-100.0, 100.0))
    at junit.framework.Assert.fail(Assert.java:47)
    at edu.columbia.threescompany.tests.BaseTestCase.assertEquals(BaseTestCase.java:47)
    at edu.columbia.threescompany.common.tests.ForceTest.testInverse(ForceTest.java:9)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestR
eference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)

They're off by a factor of 10 just like the debug output. I don't see why 
though.

Original comment by dbenamy on 15 Dec 2007 at 8:15

GoogleCodeExporter commented 9 years ago
Got it. The fix to issue 47 was wrong. I'm undoing that and then I'll look for a
better way to implement it.

Original comment by dbenamy on 15 Dec 2007 at 8:24