Need help: combinator generating GUID
Posted: Wed Jul 04, 2018 7:11 pm
Goal: Create a [map-game-instance] unique ID (GUID)
Approach:
-Let there be a Timer T
-Arithmetic Combinator, output [self] sent to input (T+1 > T)
-Any new GUID desired to be created will set's value (I) [ID] = the value of T at the time of its creation
Current Solution:
'Initiliazer' Constant Combinator >> (I = 1) (
'Set?' Decider Combinator (If I=1, S)
'SetToT' Decider Combinator (If S=1,T)
'GUID' Arithmetic Combinator (I+T = I)
Connections
* Initiliazer-Output | Set?-Input
* Set?-Input | GUID-Output | GUID-Input
* SetToT-Input | Set?-Output
* SetToT-Output | GUID-Input
+
[to turn on] --> SetToT-Input | Timer-Output
(see screenshot attachment)
Problems:
-Strictly speaking this DOES work...
-A) When the GUID gets set to T, it actually get set to T * 3. I mean, in all liklihood this is still effectively a GUID, but I'm annoyed at that.
-B) A lesser worry is I'm fairly sure there is a simpler way to do this that is equally effective, if not more. Unfortunately, all my tinkering has not prodduced any other way that effects this without outputs that fluctuate a lot .
-C) I'm not too worried about the int overflow possibility, because I don't think I'll have games that long (my math says this works for ~113 days in game-time), but it's not perfect.
P.S. - If there was a solution that could flawlessly assign incremental IDs (so, replacing the T), that would be a superior result...but I also NEED to to make sure that if I throw down 10 of these blueprints, all connected to the central T (the 'ID assigner'), that I never have a chance to get duplicate IDs.
All assistance is most sincerely appreciated!!
Approach:
-Let there be a Timer T
-Arithmetic Combinator, output [self] sent to input (T+1 > T)
-Any new GUID desired to be created will set's value (I) [ID] = the value of T at the time of its creation
Current Solution:
'Initiliazer' Constant Combinator >> (I = 1) (
'Set?' Decider Combinator (If I=1, S)
'SetToT' Decider Combinator (If S=1,T)
'GUID' Arithmetic Combinator (I+T = I)
Connections
* Initiliazer-Output | Set?-Input
* Set?-Input | GUID-Output | GUID-Input
* SetToT-Input | Set?-Output
* SetToT-Output | GUID-Input
+
[to turn on] --> SetToT-Input | Timer-Output
(see screenshot attachment)
Problems:
-Strictly speaking this DOES work...
-A) When the GUID gets set to T, it actually get set to T * 3. I mean, in all liklihood this is still effectively a GUID, but I'm annoyed at that.
-B) A lesser worry is I'm fairly sure there is a simpler way to do this that is equally effective, if not more. Unfortunately, all my tinkering has not prodduced any other way that effects this without outputs that fluctuate a lot .
-C) I'm not too worried about the int overflow possibility, because I don't think I'll have games that long (my math says this works for ~113 days in game-time), but it's not perfect.
P.S. - If there was a solution that could flawlessly assign incremental IDs (so, replacing the T), that would be a superior result...but I also NEED to to make sure that if I throw down 10 of these blueprints, all connected to the central T (the 'ID assigner'), that I never have a chance to get duplicate IDs.
All assistance is most sincerely appreciated!!