Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (784)
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 2314 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

Senior Devvie

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


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 Devvie

Friendly fire isn't friendly!

« Reply #1 - Posted 2003-10-28 06: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 Devvie

« Reply #2 - Posted 2003-10-28 07: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 07: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!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

theagentd (75 views)
2017-02-18 13:42:33

theagentd (80 views)
2017-02-18 13:35:16

h.pernpeintner (1246 views)
2017-01-24 22:39:11

h.pernpeintner (1234 views)
2017-01-24 22:38:32

Galdo (1785 views)
2017-01-12 13:44:09

Archive (1900 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2436 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2287 views)
2016-12-15 21:50:57

Lunch (2366 views)
2016-12-06 16:01:40

ral0r2 (2154 views)
2016-11-23 16:08:26
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!