Shuffling datasets is a fairly standard fare operation in data science. Without it, we risk training a model on a moving target which gradually shifts over time. For most interesting datasets, we can't fit all of the data in memory, but we'd still like to be able to access it at random. Sure, you can generate a random number and seek on disk to that location, but that doesn't guarantee that the sought position will be one with a valid line. Jumping into the middle of a JSON blob and seeking to the end is bound to yield a bad time. Here is a brief solution:

class LineSeekableFile:
    def __init__(self, seekable):
        self.fin = seekable
        self.line_count = 0
        self.line_map = list() # Map from line index -> file position.
        self.line_map.append(0)
        while seekable.readline():
            self.line_map.append(seekable.tell())
            self.line_count += 1
    
    def __getitem__(self, index):
        # NOTE: This assumes that you're not reading the file sequentially.  For that, just use 'for line in file'.
        self.fin.seek(self.line_map[index])
        return self.fin.readline()

    def __len__():
        return self.line_count

It is available here as a Python Gist:

Overview

Goose Game, but instead of a horrible goose you are a good dog whose job it is to break up fights at holiday parties. Let's game it out.

Gameplay

Simulated people will run through the motions for a party. Each guest will have a set of desires and some personal goals to achieve. For the sake of gameplay, everyone that can see the dog (player) will attempt to intervene when the player is misbehaving, rather than deferring to a host or someone else.

Visuals

Something visually simple with bright colors and simple geometry. This game should be very easy on system resources and should operate smoothly on low-resource machines or mobile devices. One option:

Low Poly pack by @Quaternius

Audio

High-fidelity, cheerful music with cute sound effects. Human speech and communication should _not_ be real human speech, but should be some sort of non-lexical vocalization like Simlish.

Interesting Challenges

Fundamentally, the interpersonal interactions will drive the game. For replayability (and developer sanity) it is desirable to have conflicts emerge naturally from NPC interactions. Additional household events can add color or fun as discoverables, but the most fundamental piece of the game is the temperature of discourse.

At the close of my earlier update I mentioned wanting to try 'Tracer-style' time travel where only the player moves backwards and everything else stays in place. I gave it a go and got it working, but it wasn't particularly interesting. It was basically just the player moving in the opposite direction. Animation could probably jazz that up, but a more fun idea came to me in the middle of a sleepless night:

Seeing the future.

Trivially, if everything in the world rewinds and the player can make different decisions, that's basically seeing the future. And that's what I built:

It's not perfect. You'll notice that the dynamic cubes retain their velocity after the time rewind happens, but that's solvable.

Here's how it works: there's a global time keeper which records the current tick. The base class has three methods (_process, get_state, and set_state), and two variables (start_tick and history[]).

The global time keeper sends a signal when time starts to rewind. During the rewind process, each tick is a step backwards instead of a step forward. The _process method of the base class checks to see if a rewind is active and, if so, calls set_state(history[global_tick]). If rewind is not active, we append or update the history. There's some nuance to tracking deltas and despawning, but really that's about it. Simple, eh?

"Your theme is... 60 Seconds!"

And so the brain storming begins. I feel like anything that doesn't explicitly involve time-travel of some sort will get dinged by the Theme-Adherence police, and besides, time travel is fun.

I've never made a game with time travel before, but it presents plenty of opportunities to do novel things. At the very least, even if the mechanics aren't original, I can do things like make the player character switch from replay to AI-driven if the player interacts with his/her previous self or force players to avoid interacting with their previous selves by avoiding line-of-sight and such. All of this is predicated on Terminator-style time travel, where the player goes back into a previous timeframe and can never return to their original. Minute Physics calls this "new/changed history" time travel and I'd call it 'forked history' time travel. The other form would be self-influencing time travel, where you happen to see yourself from the future coming in to your present.

I tried a lot of architectures. It began with the simplest thing I thought would work: A controller component would record keypresses and emit signals. The parent object would listen for signals on the child component and act as though it were receiving input. This worked, but it was hard to jump to a specific point in time.

The next thing I tried was a 'global manager'. Each actor had a 'get state' and 'set state' method. In record mode, actors would append to their history. In replay mode, they'd pull from history and set state. Things got complicated when it came to handling travelling backwards in time and then interacting differently. It was easy to go back to a time and replay, but it wasn't easy to go back, replay, and record at the same time. That part was necessary if we wanted to see ourselves and interact in tandem.

The third thing I tried was similar to the first. Each actor would be a deterministic function of time. We 'set time' which consists of taking the time and setting state accordingly. Functions are determined as only a function of the current timestamp. That works fine. After playing with it, however, it's really hard to make puzzles for it.

Shown Here: Player Jumping Backwards in Time and Seeing Other Selves

I'm going to try the Tracer-style time travel thing where the player can go back 60-Seconds into their previous state while the world stays as it is. This is closer to the self-consistent/non-branching timeline.

Thematically, I really want to rip off Zero-Wing and do a terrible translation of the plot. Character has a time-travel device that sends him/her back 30 seconds, but it has a 60-second recharge. The player got a lethal dose of radiation and needs to go back to save him/herself. The goal is to get past unity and into the net-time-gain territory. Either a recharge of 29 seconds or a jump of 61 seconds.