Random seed

Why does Unity.Mathematics.Random not have a seed by default?

It does!

var seed = 12345;
var random = new Unity.Mathematics.Random(seed);

Why do I have to set a seed I.e. 12345

Because it’s not the same randomizer as UnityEngine.Random but was modelled after shader libraries, to ease transition for developers. For the same reason the Mathematics classes are all lowercase, contrary to what you’d expect from C# naming conventions.

Mathematics was designed by unity. I’m not sure why they couldn’t just code a default seed.

A ‘default’ seed is a choice best left to the developer. Otherwise most of us would be using the same seed, and that can’t be. On the other hand initializing it with some form of “time” would make the behaviour of random non-deterministic by default, which is the opposite of its design goal.

You can make a helper method that does this for you, for example:

public static Unity.Mathematics.Random RandomWithTimeSeed() => new Unity.Mathematics.Random((int)System.DateTime.Now.Ticks);

Unity could do a lot more than that to force developers to make better games. And still, the 1000s low quality games per hour on the internet would not get any better.

The random seed is an implementation detail best left up to the developer. It’s a library for more advanced users anyway. I’m sure 99.99% of the time they have a particular method of seed generation already in mind, like I do when I’m using it.