AS and determinism

Started by
0 comments, last by WitchLord 8 years ago

Hi,

we've planned to use AngelScript for various scripts in our game logic. Since we have a multiplayer mode that is running the game logic deterministic on each client, it's crucial to run those scripts deterministic as well. Therefore, we need to remove the floats inside AS, since floats are non-deterministic and would cause asynchronism.

Is there any define or approach that allows us to disable floats from being part of the script interpreter?

Regards,

Clausomat

Advertisement

There is currently no pre-existing option to disable floats in the script language, but you can easily do that with a minor customization to the library by finding and disabling the tokens that represents the floats.

The file as_tokendef.h holds the definitions of the tokens that the script language understands. You'll want to disable the tokens ttFloatConstant, ttDoubleConstant, ttFloat, and ttDouble. Doing that and then compiling the library you'll easily find where they are referred from and can disable the code that uses those too.

Another option, that might be even simpler, is to change the method asCBuilder::CreateDataTypeFromNode to give an error if the script attempts to declare any variables of the types float or double. That combined with the fact that you'll not register any application interface that accepts floats will effectively disable the use of floats in the scripts without a lot of changes in the library code.

I may even consider adding the latter as a dynamic option through an engine property.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement