It’s a couple of days after the end of September, but better late than never! This past month was a full one. Long story short: I did a lot of practical learning, and my wife and I adopted twins!
Learning Log
Before we get into all this, let me update you with this month’s learning log:
| Headline | Time | | |
|--------------------------------+---------+-------+-------|
| *Total time* | *51:50* | | |
|--------------------------------+---------+-------+-------|
| GOAL: 6500 Hours | 51:50 | | |
| \_ Book Study | | 11:18 | |
| \_ The Pragmatic Programmer | | | 8:28 |
| \_ Game Engine Architecture | | | 2:50 |
| \_ Emacs | | 8:21 | |
| \_ ABX Development | | 32:11 | |
| \_ Programming | | | 21:56 |
| \_ Art | | | 3:00 |
| \_ Business | | | 5:15 |
| \_ Learning | | | 2:00 |
I added about 17 hours this month, most of it going toward ABX!, with some studying of Game Engine Architecture. So overall, a good month hours-wise, especially considering I didn’t do anything for the last week and a half (I’ll get to that).
Practical Learning
Last month I said I was doing more learning than coding. Well, this month was the complete opposite. I had a lot of time with my hands on the keyboard, which I really enjoyed. I said last month that I was close to getting the engine done, and when I actually sat down to work on it, was I wrong.
ABX! Development
I’m really motivated, for multiple reasons, to ship this game now. It’s still a fun passion project, but now I have some real motivation to see it through. When I sat down and really thought about what I have to do to ship, boy, did I realize I have a lot of work ahead of me.
So this month I laid more groundwork. I figured out and built seeded generation attached to an RNG state machine. There are still no rules around it, but the core wiring is there. Then, since I’m getting to the point of gameplay, I figured I should add a debug menu where I can manually adjust the state, seed, and other aspects of the game. Lastly, to get real testing, I made some CLI flags that let me load specific seeds, levels, and anything else I need to test the game. After doing all this, I still realized I’m far from getting my game done, but now I have a task list to get me there.
Deeper Dive Into ProcGen
Figuring out how to do procgen was interesting. There was a lot to figure out since I had never done it before and had no clue where to start. So let’s start at the beginning.
The first thing I do is create a master seed by getting the current time in nanoseconds and casting it into a u64:
game.master_seed = u64(time.time_to_unix_nano(now))
I then pass that seed into world_init, which passes it into level_init, which calls derive_seed(seed, .Category, number). What this does is create a packed value by taking the SeedCategory enum, bit-shifting it left by 32 bits, and then XOR’ing a number into it. What the number is depends on what the seed is for. The two most common uses are the level number and the wave number. Next, I turn that packed value into an array of bytes. The last step is hash.murmur64a, which creates a new u64 that becomes the seed for that level. Long story short, it’s only four lines of code:
derive_seed :: proc(parent_seed: u64, category: SeedCategory, number: int) -> u64 {
packing := (u64(category) << 32) ~ u64(number)
u8array := mem.any_to_bytes(packing)
return hash.murmur64a(u8array, parent_seed)
}
From there, I create a random state, which then gets passed into a random generator. That’s how I get an RNG machine for each thing that needs one:
entry_rng_state := rand.create(derive_seed(wave_seed, .Entry, 0))
entry_rng := runtime.default_random_generator(&entry_rng_state)
So yeah, that’s the process of creating seeded RNG in Odin.
Big Life Update
My wife and I adopted twins!!! I can’t say much about them due to the legal process, but they’re identical twin boys! So now I have three under three, and my wife and I are officially outnumbered in our household.
What this means is that my time has become even more limited, including my time at home to program and work on things. However, my job is cool with me working on my laptop during downtime, so I’ve gained some time there. I’m hoping it will balance out over time!
Life to the Full
So that has been my past month! I really don’t have much else to say, probably because I’m not sleeping much, lol.
As always, I’ll end with this:
This is life, and I will not lie by saying every day will be sunshine. But there will be sunshine again, and that is a very different thing to say. That is truth.
— Brandon Sanderson, Rhythm of War