Amazing game! Congratulations

On Mon, Apr 28, 2025 at 5:18 AM Craig Mitchell <[email protected]>
wrote:

> If interested, my situation is a car racing game.  The graphics code is in
> the client module, and the logic code is in the shared module.  The player
> plays in the browser, and once finished, their input controls are sent to
> the server, that then replays the race in the logic code to make sure they
> didn't cheat.
>
> Thus, the logic code is run in JavaScript in the browser, and in Java on
> the server.
>
> In addition to that, players also race against replays of other players.
> Those replays are generated in the browser, again using the logic code from
> the recorded player inputs.
>
> JavaScript has been rock solid, across all browsers and platforms (PC /
> Mac / Android / iPhone / Smart TVs, Tesla browser / ...)  The logic code
> always outputs the same results.
>
> Java not so much.
>
> There is a pattern however:
> - The failures always occur with races that have computer opponents (which
> is about 30% of the races).
> - The failures always consistently fail with the same results.  Ie: If I
> run a test with mvn test, I'll always get one result.  If I run the same
> test with IntelliJ, I'll always get the same different result.
>
> I'm trawling through the computer opponent logic code to see if I can see
> anything suspicious.
>
> I have avoided obvious things like:
> - Not using Math.sin, Math.cos, Math.atan, etc. as those return different
> results based on the platform.
> - Not using floats, as they are not suported by JavaScript.
>
> As Colin suggested, I'm also implementing the tests with GWTTestCase, to
> see if they pass or not.
>
> The game if you're curious: https://drift.team/
>
> Cheers.
>
> On Monday, 28 April 2025 at 5:01:33 pm UTC+10 RobW wrote:
>
>> If your solution relies on absolute accuracy across different languages
>> and machines but you're using floating point I'd say you are setting
>> yourself up for some major heartache and issues. Even with IEEE 754, and
>> supposedly strict rules on rounding I wouldn't trust the fidelity across
>> machines. Do you really need to do the math both on the server in Java and
>> in the browser? Pick one and use that maybe. Or, if you need complete
>> fidelity, use something other than floating point - integer arithmetic or
>> maybe BigDecimal on the server.
>>
>> On Sunday, 27 April 2025 at 13:39:06 UTC+1 Thomas Broyer wrote:
>>
>>> On Sunday, April 27, 2025 at 2:06:11 AM UTC+2 [email protected]
>>> wrote:
>>>
>>> I asked AI about my problem, and it told me it was due to Java not
>>> following the IEEE 754 standard and I have to expect inconsistant results.
>>> However, I don't know if that's correct.  There are people saying Java does
>>> follow IEEE 754 and others that say it doesn't.
>>>
>>>
>>> It does:
>>> https://docs.oracle.com/javase/specs/jls/se24/html/jls-4.html#jls-4.2.3
>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "GWT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/google-web-toolkit/bfcc50a6-a012-4bc9-a5b1-10430e63ea13n%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit/bfcc50a6-a012-4bc9-a5b1-10430e63ea13n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/CA%2BkiFsfM1gaG1cWahAqgOYRuJuXUy8sKbnMcvp0xOpsdNn%3Dbtg%40mail.gmail.com.

Reply via email to