Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Feedback Fixed point number library for C#.

Discussion in 'Works In Progress - Archive' started by StormMuller, Mar 23, 2019.

  1. StormMuller

    StormMuller

    Joined:
    Jun 2, 2015
    Posts:
    17
    So I wanted to make an RTS and ran into the whole "deterministic lockstep" concept. Yossarian King has 2 great talks on the subject when creating Homeworld: Deserts of Kharak (Links in comments). Thing is I couldn't find any good fixed point libraries for C# so I decided to create one. Here's the github page. I'm posting it here for other's to use, learn from and possibly contribute to(because I know there are people way smarter than me at this).
     
  2. StormMuller

    StormMuller

    Joined:
    Jun 2, 2015
    Posts:
    17
  3. Deleted User

    Deleted User

    Guest

    This is arguably pretty darn cool!
     
    StormMuller likes this.
  4. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    80
    This is great. Thanks for sharing.

    I wonder if it's possible to create a fixed point math library that is Burst-friendly for extra fast processing. Perhaps fixed-point vector types too? What do you think?
     
    StormMuller likes this.
  5. StormMuller

    StormMuller

    Joined:
    Jun 2, 2015
    Posts:
    17
    I'll be honest, the new DOTS system is quite intimidating to me. So I haven't really used it yet. I saw that Unity's new multiplayer system, does support Lockstep out of the box.

    I'd be happy to work on the library again. I think fixed-point vector types could be quite easy to add.

    Any idea what I'd need to do to make the library burst-friendly?
     
  6. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    80
    Ah yes... your goal was for lockstep, deterministic multiplayer - which Unity now appears to provide.

    I'm actually interested in fixed point math for deterministic, procedural generation - so that the same level/map/data gets generated on all platforms and processors from an initial seed.

    While I'm not entirely sure, it feels like it should be possible since the internal storage types for your classes are supported by Burst...

    But whether all your functions can be written in Burst friendly code, I don't know...

    EDIT:

    From this page: https://wiki.arcengames.com/index.p...y_Access_Starts!#So_Long.2C_Fixed-Int_Math.21

    They mentioned that moving away from Fixed Point Math, let them use SIMD optimised code in places - "This greatly improves the precision/accuracy, and in several cases also lets us use SIMD for actually better performance, too." Since this is what Burst is, it implies that maybe it can't all be made Burst friendly...
     
    TakuanDaikon likes this.
  7. spirachi77

    spirachi77

    Joined:
    Sep 26, 2017
    Posts:
    17
    I would love to use this! How so I implement this int unity 2019.3.15? And does it overwrite floats with fixed point values?