Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Deterministic float game state - strictfp?  (Read 1562 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

Senior Member





« Posted 2003-10-27 17:44:14 »

Hi,

Developing the networking for TT, I'd like to keep things simple and simply assure that all game state is altered in the exact same way on all clients. That is, only game state altering events will be sent over the network, and no correction of different states on different machines will be needed.

The downside to this approach, is that I need to compute game states updates exactly the same, even on different platforms, and then I wondered what to do about the floating point game state we need? The tedious solution is fixed point integer math, but is there any easy way out through the strictfp keyword? As I see it, the keyword assures that all IEEE floating point operations follow the same rules, but I'd like the be certain. Game state differences through floating point differences would probably be hard to detect, and I can't figure out a good way to test/prove it. And I wouldn't wan't to build game state on floating points and then months later discover I need to change it all to ints.

- elias

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #1 - Posted 2003-10-28 07:20:47 »

If float accuracy is your main concern, you seem to have extremely stable algortihms concerning framerate, latency and such. Are you sure this is really true?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline elias

Senior Member





« Reply #2 - Posted 2003-10-28 08:23:35 »

It is indeed accuracy that is the problem - but not in the way you might think: I don't care how accurate the floating point computations are, but I must be certain that the accuracy is the _same_ on all platforms the game is running on. According to the JVM specs, VM's are allowed to use the extended precision floating point operations available on the FPU units. That's normally a nice feature, because if you execute a complex floating point operation (for example a square root) on the FPU, you decrease rounding errors per step.

However, different FPUs can very possible have different internal precision in its calculations, and the same computation on different FPUs can give different results. And that's where I believe the strictfp keyword comes in - it disables any extra precision representations on FPUs making all computations the same on every CPU (because floats and doubles have the same number of bits on all platforms). I gain deterministic behaviour in the game simulation at the expense of accuracy.

- elias

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2003-10-28 08:45:34 »

Yes, I believe the point of strictfp is to ensure that the same math input produces the samee xact output on all Java VMs.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 08:55:21

Zero Volt (29 views)
2014-07-18 01:47:54

danieldean (24 views)
2014-07-18 01:41:23

MustardPeter (26 views)
2014-07-17 01:30:00

Cero (41 views)
2014-07-16 02:42:17

Riven (43 views)
2014-07-14 20:02:53

OpenGLShaders (31 views)
2014-07-14 18:23:47

Riven (30 views)
2014-07-14 13:51:35

quew8 (29 views)
2014-07-13 15:57:52

SHC (64 views)
2014-07-12 19:50:04
HotSpot Options
by dleskov
2014-07-08 05:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 02:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 02:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 13:13:37

HotSpot Options
by Roquen
2014-05-15 11:59:54

HotSpot Options
by Roquen
2014-05-06 17:03:10

Escape Analysis
by Roquen
2014-04-30 00:16:43

Experimental Toys
by Roquen
2014-04-28 15:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!