generic-github-user / Caesium

General-purpose AI library with NEAT-style genetic algorithm.
https://generic-github-user.github.io/Caesium/src/versions/javascript/projects/network-visualization/
MIT License
1 stars 1 forks source link

Chance of duplicate UUID being issued? #99

Closed generic-github-user closed 5 years ago

generic-github-user commented 5 years ago

Determining the chance of the same UUID being randomly generated for more than one network - see this comment for more information.

generic-github-user commented 5 years ago

Each UUID is formed by 8 hexadecimal strings, each 4 characters long.

function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
            .toString(16)
            .substring(1);
}

Therefore, there are 32 hexadecimal characters in the UUID, each with 16 possible values. There are 16^32 possible UUID combinations - or 340‚282‚366‚920‚938‚463‚463‚374‚607‚431‚768‚211‚456, about 10 quadrillion times the number of sand grains on the Earth. This makes the chance of any two UUIDs being the same 1 in 340‚282‚366‚920‚938‚463‚463‚374‚607‚431‚768‚211‚456. It's pretty unlikely.