I would just have a date-based seed.
For my Royal Mazes game I do this for two things:
- when you do the Daily Challenge Maze, everybody has the same seed for a given date. I randomly chose this formula:
static int GetDailyChallengeSeed( DateTime currentTime)
{
int day = currentTime.Day;
int month = currentTime.Month;
int year = currentTime.Year;
int seed = year * 400 + month * 32 + day;
return seed;
}
and I assign that to Random.seed before generating the maze.
- I also implemented a head-to-head feature where two people simultaneously press SHARE SYNC and it runs this code to produce the identical value on two devices:
static int GetUnixTime() // ChatGPT
{
// Define the Unix epoch (January 1, 1970 00:00:00 UTC)
DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
// Get your DateTime (ensure it's in UTC)
DateTime currentTime = DateTime.UtcNow; // You can replace this with any DateTime
// Calculate the difference between the two DateTime objects
TimeSpan timeSpan = currentTime - unixEpoch;
// Get the total seconds since Unix epoch
long unixTime = (long)timeSpan.TotalSeconds;
return (int)unixTime;
}
and divides the seconds by 60:
int seed = GetUnixTime();
seed /= 60;
To cross-verify visually, it modulos that number with 60 and calls it a “Shared Minute ##” in the pre-game UI.
That way if we both have the same shared minute (easy to see at a glance), a number which is the same as what the clock says, then we both started with the same seed and we see the same maze while we race.
NOTE: throughout all of this, no connection is made to any server and no data is transferred between either phone. This is just for a shared identical initial maze, either Daily or Share Sync.
EDIT: Oh yes: Royal Mazes is a brand-new mode in my KurtMaster2D game package. It is pending release on iPhone (any moment now) but it is fully out on Android.
Apple iTunes: KurtMaster2D on the App Store (pending)
Google Play (including TV): https://play.google.com/store/apps/details?id=com.plbm.plbm1