0

I want to generate events based on date and time. It's for a game that has events that are based on date and time. Randomizing would be predictable like getting the next date and time. I couldn't find any information online using the the keywords I could think about. I've here an example use:

DateTimeRandom rand = new DateTimeRandom(5 * 60 * 1000, 30 * 60 * 1000, 30 * 1000, 45 * 1000) // Every 5 to 30 minutes and last for 30 to 45 seconds.

// To get the next event:
LocalDateTime dateTimeNext = rand.nextEvent().

// To get the current event:
if (rand.hasCurrentEvent()) { // Here's the boolean I'm talking about in the title.
    long millis = rand.getCurrentEventDuration(); // Duration in milliseconds.
    long startMillis = rand.getEventStartTime(); // Start time of the event.
}

It's ok if time is in nanos.
The class I need DateTimeRandom would have the following paramaters: (long min, long max, long minLength, long maxLength) the parameters are meaning the time that's between every event, and the last two are for the length. I hope this is enough information. The question here is for input only, my questions is a more advanced: I try to make an game event system that will have random game events based on date and time, the events will be predictible so that the user that plays the game can see the next event. This would also be useful for weather events.

Qboi
  • 15
  • 1
  • 6
  • Does this answer your question? [Is there an algorithm or function that outputs a random number given n number values?](https://stackoverflow.com/questions/66888099/is-there-an-algorithm-or-function-that-outputs-a-random-number-given-n-number-va) – Peter O. Apr 22 '21 at 00:54
  • @PeterO. Nope, that's for randomizing from inputs only and I don't see a way to make events from it that are predictable. – Qboi Apr 22 '21 at 12:14
  • Your question is rather vague. It appears that you want to divide time into a sequence of non-overlapping windows, with each window's length chosen pseudorandomly, and one event will start and finish at a pseudorandom time in each window. And it seems that you somehow want these event windows to be deterministic. Is this correct? – Peter O. Apr 22 '21 at 13:03
  • @PeterO. I think, if it's possible to make random weather events for a game with that, I'm not so familar with randomizing. – Qboi Apr 22 '21 at 16:36

0 Answers0