Need help: combinator generating GUID

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
LazarusDarkeyes
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jul 04, 2018 6:59 pm
Contact:

Need help: combinator generating GUID

Post by LazarusDarkeyes »

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!! :D
Attachments
factorio screenshot.jpg
factorio screenshot.jpg (21.55 KiB) Viewed 1227 times

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Need help: combinator generating GUID

Post by Koub »

[Koub] Moved to Gameplay Help
Koub - Please consider English is not my native language.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Need help: combinator generating GUID

Post by eradicator »

Maybe i'm missing something here, not being a combinator expert, but why do you want a timer?
A unique ID is basically any integer that's only used once, unless you have a requirement for the integer to have a fixed number of digits? Otherwise i'd just use a constant combinator T=-intmax and a decider combinator T if T as a memory cell. To get a new ID you send T = 1 (for one tick) to the memory cell, increasing it's count by 1. Thus you get incremental integers from -intmax to +intmax. (Ofc the memory cell may never lose power.)

4xel
Fast Inserter
Fast Inserter
Posts: 108
Joined: Fri May 26, 2017 3:31 pm
Contact:

Re: Need help: combinator generating GUID

Post by 4xel »

Are you trying to make something like a random or a pseudo random generator?

Mesuring a time dependant on player interaction in ticks like you do looks like the best idea.

You would never lower the chance of a duplicate down to zero, but you can lower it to a practical zero by combining several random numbers.

For a game instance unique idea, combining the map seed and a time measured in ticks should make the probability of duplicate a practical zero.

Savegame name and path ensures absolute zero duplicate, providing you never overwrite a save you load.

Uranium processing theoretically generates true randomness, although an impractical one, and in practice relying on a pseudo random generator not (easily) perceptible from within the game.

I would be interested to know wheter splitter are random or not. I know they alternate, but how do they choose their starting side? (there are symetric ways to pick a side without randomness, I'll have a llok at this, but I don't have high hopes).

Post Reply

Return to “Gameplay Help”