## Tapped out!

We had a bunch of kiddos over for a birthday party yesterday and Benson is just done.

## Sid Meier’s Memoir!: A Life in Computer Games

The Civilization series is easily one of my favorite video games of all time. (See here, here, here, here and here). I have very fond memories of talking to my middle school teacher about various strategies to utilize within Civ I and I still vividly remember the wickedly cool box art.

So, it’s no surprise that I’d dig into the memoir of the man who created the games himself, Sid Meier.

It’s a nerdy trip through early computer gaming history and fostered a bunch of nostalgia for old DOS games that I used to play. It’s also a fantastic romp through the mind of a game designer.

There were a number of fun little quotes and life lessons, as well:

“I think that in life, as in game design, you have to find the fun. There is joy out there waiting to be discovered, but it might not be where you expected. You can’t decide what something’s going to be before you embark on it, and you shouldn’t stick with a bad idea just because you’re fond of it. Take action as quickly and repeatedly as possible, take advantage of what you already know, and take liberties with tradition. But most importantly, take the time to appreciate the possibilities, and make sure all of your decisions are interesting ones.”

## Generating terrain maps

Recently, I went down a rabbit hole attempting to learn how to generate interesting looking maps for games (insert mind-blown-gif here). While I’m not going to be using Voronoi diagrams anytime soon,  I am still interested in attempting to generate Civilization-like maps.

Most map generation algorithms rely on perlin noise. I wanted to go a different route.

So far, these are the rules that I’ve come up with for my algorithm:

1. Create a grid of some given size (e.g., 100 x 50). Set all tiles to “ocean”.
2. Randomly pick 8 tiles (variable) across the map to seed as “land”.
3. Now iterate across all tiles on the map and build an array of tiles that are “ocean” tiles but have a land tile N/W/S/E of them.
4. Once you have this array, randomly pick a single value. Flip it from “ocean” to “land”
5. Repeat step 3 until a given number of tiles have been filled across the grid (e.g., for an “Earth-like planet”, 30% of tiles will be land).
6. Now, to add some additional randomness — iterate across all tiles and build an array containing all “land” tiles next to water (N/W/S/E).
7. Randomly pick 1, flip from land to ocean.
8. Repeat step 6 a given number of tries (e.g., 100).
9. Done! (Maybe)

Height maps, biomes and all that can come later. To quote Amit, whom I linked to earlier:

The most realistic approach would have been to define elevation first, and then define the coastline to be where the elevation reaches sea level. Instead, I’m starting with the goal, which is a good coastline, and working backwards from there.

Anyway, it’s been kind of neat to figure out.

Another example map, created using the above rules:

## Troubleshooting a (Royal) Kludge (RK G68): Sleep issues with my swanky new mechanical keyboard

TL;DR After a lot of testing and isolating devices, I’ve determined that the RK G68 RF receiver for my swanky new mechanical keyboard causes my Windows 10 machine to wake up immediately after putting it to sleep. And I’m not sure how to fix it.

Join me on an epic journey of heartbreak, anger, loss, triumph and sadness as I try to diagnose some sleep issues.

—-

So, the issue is that if I manually put my computer to sleep (`Start Menu -> Power -> Sleep`), the machine goes to sleep, fans turn off, and all that. Sweet! Then, after about 5 seconds, it wakes right back up. Uh, what?

I’ve done a number of debugging and testing steps which I’ll outline below (hopefully, this helps some folks in the future).

Let’s do a couple of finger stretches, put on our hacker pants, and open up PowerShell (with admin access). We can run a nifty command called `powercfg /requests`

I see the following output:

```DISPLAY:
None.

SYSTEM:
None.

AWAYMODE:
None.

EXECUTION:
None.

PERFBOOST:
[DRIVER] Legacy Kernel Caller
Power Manager

ACTIVELOCKSCREEN:
None.
```

`powercfg -requestsoverride Driver "Legacy Kernel Caller" System`

You haven’t lived until you’ve copy and pasted random commands from the Internet into your terminal. Let’s do it! I run that and make the computer go to sleep again. Monitor turns off, fans spool down. Yes! Yes?

Obviously, it immediately wakes up. No dice.

Ah, ha! Maybe read the command first, dude? The issue here is that the Legacy Kernel Caller is in the PERFBOOST category, not SYSTEM category. That’s easy to fix.

…but it isn’t.

Of course, you can’t actually disable the driver for items in the PERFBOOST category. Of course.

Next up: A suggestion to check waketimers. I have no idea what that is, but sure: `powercfg -waketimers`

```There are no active wake timers in the system.
```

Okay.

Yo, Goooooooogle… again!

Ah, another command! `powercfg -lastwake`

Now we’re getting somewhere. We see that this is a USB device that is waking the computer:

```Wake History Count - 1
Wake History [0]
Wake Source Count - 1
Wake Source [0]
Type: Device
Instance Path: USB\VID_25A7&PID_FA70\8&e5ec113&0&4
Friendly Name:
Description: USB Composite Device
Manufacturer: (Standard USB Host Controller)
```

But… how do we determine what it is? Looking at the path, we see VID and PID. That means:

Vendor ID: 25A7
Product ID: FA70

Let’s Google those: It turns out, the vendor is `Areson Technology Corp` and it looks like they make RF receivers for various input devices, such as wireless mice. Interesting! No hits for the product ID. That’s fine, there’s probably more types of RF receivers on planet Earth than there are people.

But that gives me a starting point.

I decide to start unplugging various devices and put my computer to sleep.

• Unplug Logitech USB receiver: Still wakes up.
• Unplug Anker USB Bluetooth receiver / transmitter: Still wakes up. I feel like I’m not having much fun anymore.
• Unplug this random, unlabeled RF receiver: Hey, my keyboard input stopped working from my mechanical keyboard! Ah well. Go to sleep computer…

IT DOESN’T WAKE BACK UP!!!!

Victory. Party dance. Switch out the hacker pants for party pants. Now we’re getting somewhere!

I plug the receiver back in and open device manager. I go to the keyboard section (randomly, there are like 4 different devices listed there). I open the properties dialog box for each of them, go to the `Power Management` tab and uncheck “`Allow this device to wake the computer.`

I got you now, pesky sleep problems! :blow-smoke-off-gun-gif-dot-com-dot-net:

I put the computer to sleep.

IT IMMEDIATELY WAKES BACK UP!

I’ll be honest. There was a lot of screaming, kicking, swearing. My dog got up and left the room (he never does that). I almost knocked over a coffee cup onto my keyboard and I DIDN’T CARE.

Okay, fine.

No big deal, really. I’m not okay, you’re okay.

On a hunch, I expand the `Universal Serial Bus controllers` section inside the device manager. Sure enough, there are a bunch of things that say `USB Composite Device.` You might remember from earlier (but probably not), that a “USB Composite Device” was called out using the `--lastwake` command.

If you open up the properties for each USB Composite Device and go to the events tab, you will see the device ID in the information section. Keep looking until you find the device ID that was called out: `USB\VID_25A7&PID_FA70\8&e5ec113&0&4`

Click. Close. Click. Close. Click. FOUND IT!

```Device USB\VID_25A7&PID_FA70\8&e5ec113&0&4 was configured.

Driver Name: usb.inf
Class Guid: {36fc9e60-c465-11cf-8056-444553540000}
Driver Date: 06/21/2006
Driver Version: 10.0.19041.488
Driver Provider: Microsoft
Driver Section: Composite.Dev.NT
Driver Rank: 0xFF2003
Matching Device Id: USB\COMPOSITE
Outranked Drivers:
Device Updated: false
Parent Device: USB\VID_0BDA&PID_5411\7&b8f002b&0&2.
```

Sweet, now to just open up the Power M…. THERE IS NO POWER MANAGEMENT TAB.

My dog came back. He immediately left again. You can probably guess why.

“Ensure drivers are updated”.

Okay. Sure. Blah, blah. But maybe it’ll work. It won’t though. I already know. Who am I kidding?

```The best drivers for your device are already installed.
```

Fine. I’ll just uninstall the driver.

Oh, cool, now my keyboard doesn’t work.

BUT YOU KNOW WHAT?! MY COMPUTER STAYS ASLEEP!

—-

A few other things to note.

• If I have a USB-C cable plugged into the keyboard, it will stay asleep (even though the RF receiver is still plugged in).
• If I turn off the keyboard itself, it will stay asleep.
• If you just walk away from the computer, it will go to sleep (according to my power plan settings — 15 minutes). I suspect this is because the RK software (I’m on version 2, by the way, which I think just came out and the latest firmware) is setup to put the keyboard to sleep after about 5 minutes or so. I really haven’t tried to experiment with this because I DON’T CARE ANYMORE.

(I do care. Deeply. I just can’t right now.)

## Book Review: Empire of Pain by Patrick Radden Keefe

What a fantastic book about a horrible family.

The first half of the book is a true rags-to-riches story, following the life and rise of Arthur Sackler and his brothers. The son of an immigrant, he came of age during the Great Depression. This man could hustle and there was nothing that could stop him.

The second half is about the pharmaceutical company they purchased and ran. In the 90’s, they created a ridiculously powerful pain killer (OxyContin). In an effort to maximize profit, they pushed the drug onto unsuspecting patients and physicians despite knowing (and hiding) how addictive and dangerous it was.

The damage is jaw dropping. And like most crimes involving the ultra rich, the family members who ran the company (and used it as their personal piggy bank) got away with it.

## Book Review: The Code Breaker by Walter Isaacson

At first glance, this book seems to be a biography of Jennifer Doudna, a biochemist and one of the pioneers of CRISPR research.

While there is some focus on her upbringing and the things that may have driven her to become a fantastic scientist, the book is really about the wide range of characters who helped discover CRISPR DNA sequences and their potential applications in modern medicine.

I’ve heard CRISPR and CRISPR-based technology mentioned in various things I’ve read and how it is something that could potentially revolutionize medicine. But that’s really all I know about it.

This book digs into how Jennifer and her team of researchers discovered the CRISPR process — essentially duplicating the way that bacteria has fought off viruses for eons — and how it could ultimately be used for various therapies, treatments and even diagnoses.

The book briefly mentions its use in the Moderna and Pfizer vaccines for COVID-19 as well as some of the more controversial and ethically questionable uses — editing the genes of a fetus, for example, to choose certain traits (which will then be passed down to its own children).

This was an enjoyable and informative read and it covered all sorts of things from the science of CRISPR, legal issues related to patents, and the use cases for CRISPR based technologies today.

## Book Review: The Plot by Jean Hanff Korelitz

Quick summary: Washed up author (Jake) teaching a writing workshop finds out a former student of his (Evan) — who had an amazing idea for a story that was guaranteed to be a best seller — suddenly died without publishing or apparently sharing his story with anyone.

Jake helps himself to the idea and ends up publishing a best selling book. Only… some Internet troll knows the truth and is sending him some anonymous, threatening letters. And so begins a wild goose chase.

I definitely enjoyed this. It starts off a bit slow, but as the story goes on the pace picks up and I couldn’t put it down

I’ll be honest: I *knew* there was going to be a plot twist around a certain character the moment we met them. I just knew it. But the deviousness of it still surprised me and I really wasn’t prepared for how things went down.

That said, some of the threats the anonymous person was making toward Jake felt a bit hollow. Knowing what we knew this person probably did, they couldn’t really threaten Jake without exposing their own crimes. So, that whole thing was kind of strange…

But we find out that it actually doesn’t matter, because there is a longer game at play and Jake is merely a pawn.

It’s crazy.