jlm-blog
~jlm

29-Nov-2022

twitcode #5: Extract HyperRogue achievements from log file

Filed under: programming — jlm @ 17:28

The game HyperRogue is very interesting. Its main gimmick is that it’s played on a hyperbolic plane (surface with negative curvature) instead of an Euclidean plane (surface with zero curvature) like 99.99% of 2-D games are. Playing in this kind of geometry is compellingly mind-bending. Other than the geometry involved, the main way the game differs from typical roguelikes is that the player character doesn’t gain levels or skills in the course of play — instead, the game opens up new “lands” with new environmental challenges and/or monsters with new attributes as the player demonstrates their skill by meeting the unlock requirements for each land.

The game supports “achievements”, where whenever your gameplay meets the condition of some challenge (some very easy, some nightmarishly hard, most of medium difficulty), it records this in a log file. Of course, met achievements aren’t all that the log file contains, but it’s nice enough to start each “met achievement conditions” record with “ACHIEVEMENT” and a marginally-descriptive achievement name, followed by other relevant information. Unfortunately, you can’t get a list of your fulfilled achievements merely by running  grep '^ACHIEVEMENT ' hyperrogue.log  because the game logs when you fulfill an achievement’s conditions separately for every run, not just the first run to fulfill it. So, to extract the records of each achievement’s first fulfillment, we ignore any record with an achievement name we’ve seen before and print out the line otherwise (ie, if we haven’t seen it before), which is nigh-trivial in awk [link]:

/^ACHIEVEMENT / {
    if (!($2 in ach)) {
        ach[$2] = 1;
        print;
    }
}

At 86 characters, it’s the fifth example from me of “twitcode” (programs under 140 bytes). And being in awk, it’s the fifth language I’ve twitcoded as well.

4-Jul-2022

Wacky security questions

Filed under: travel — jlm @ 13:18

While I privately celebrate Independence Day, let me reminisce on a small, but odd, part of my recent trip to the mother country we independenced from. For a round-trip international flight, you’re questioned by security agents four times: by the TSA before leaving the country, by ICE upon your return, and by their equivalents in the foreign country upon arrival and departure there. The TSA screening was very routine, but the British immigration/customs officer had this weird thing where he’d repeat all my answers back with a really skeptical tone.

“Where are you going from here?”
“I’ll be staying here in London for the next five days.”
“You’re lodging in London?”
“Yes.”
“Why are you coming here?”
“Primarily to visit my family.”
“You’re visiting family, who live in London?”
“Yeah.”
“And when are you leaving?”
“I fly back home on July 1st.”
“You’re flying back to the US on the 1st of July?”
“Yep.”
“And how are you getting to London?”
“I bought a ticket for a National Express bus.” [The “Tube” was shut down due to a labor strike.]
“You’re taking a National Express bus to London?”
“Yup.”
[Dropping the skeptical act] “Very good, welcome to the UK.”

Maybe the idea is somebody fabricating their answers will feel a need to elaborate instead of simply confirming? Whatever. The odder bit was the trip back, where each security officer asked me a strange question.

“Where is your journey starting from?”
“Uh, what?”
“Where is your flight leaving?”
[Borrowing the tone of his countryman] “You want to know the airport my flight departs from?”
“Yes.”
“From this airport, London Heathrow.”
“Very good.”

And then, from ICE:

“What’s in London?”
“Uh, what?”
“You said you flew in from London, what’s there?”
“Well, there are a lot of things in London: Parliament, and a stretch of the River Thames, and several bridges over the river, and millions of people, one of whom is a first cousin, and his wife, and —” [at this point, the agent cuts me off, and I don’t even get a “very good”. I guess that’s a British thing.]

28-May-2022

Why cubie orientations are preserved

Filed under: math — jlm @ 10:59

A while ago in “Rotating only one cubie”, I said there was “extra structure” to the Rubik’s Cube’s moves that preserves the sum-total of all corner cubie orientations, and of all edge cubie orientations, but didn’t preserve the sum-total of center cubie orientations. I didn’t get into that then, because it’s hard to describe, and why they’re preserved wasn’t the point of that post. But I did make a note to get to it later, as I wasn’t aware of any good explanations of it that I could link to, and it’s high time for that “later” to become “now”.

The dynamics of the corner and edge cubies are pretty different in this regard, which is probably expected by everybody who’s played around with the Rubik’s Cube that much — edge and corner cubies have very distinct characters in general. As is usual with the Rubik’s Cube, the corner cubies are easier to think about. (I think this is mostly because there are only 8 of them, while there are 12 edge cubies.) So, let’s do them first.

(more…)

1-May-2022

The quick diplomatic solution

Filed under: humor — jlm @ 21:11

A Mos-Ukr
A Sev S A Mos-Ukr
A Ukr Holds
A War S A Ukr
A Gal S A Ukr
A Rum S A Ukr

As long as I’m being silly here, note that Ukraine must not attack, as it’d lose the support necessary to hold off Moscow’s attack, and that even if Moscow convinced one of the regions supporting Ukraine to switch to supporting their attack, it’d still fail to overcome the Ukrainian defense.

8-Jan-2022

Can’t stop the Omicron

Filed under: covid, news — jlm @ 10:43

Brussels Times: Belgian scientific base in Antarctica engulfed by Covid-19 despite strict measures

• All personnel fully vaccinated? Check. ☑
• Frequent testing? Check. ☑
• Quarantined over the incubation period? Check. ☑
• Covid-19 outbreak anyway? Check. ☹

We can’t stop this.

20-Nov-2021

Who’s logic bombing whom?

Filed under: covid, humor, web — jlm @ 16:58

This is how we know Star Trek is fiction:
[Available vaccines are unavailable]

This kind of thing is how humans break computers in that world. Here in reality, it’s how computers break us humans.

2-Feb-2021

This is me

Filed under: covid, humor — jlm @ 12:18

(from [xkcd])

18-Jan-2021

Vaccines in freezers are 0% effective

Filed under: covid, news — jlm @ 10:41

… they have to be injected into somebody to have an effect. This is an obvious, common sense, undisputed fact. Why are so many people of influence and power (most disappointingly Gov. Gavin Newsom) acting like it’s not?

Today, in this age of online data, we have the advantage of having the actual numbers a click away. As of today, 31,161,075 doses have been distributed, of which 12,279,180 have been administered, leaving 18,881,895 doses chilling out in the freezers. Despite all the public clamor to administer the vaccines, 60% of the doses made for US use so far are still just sitting there in inventory, despite us being over a month into the rollout.

And over at the New York Times, they deem it it important enough to extend their morning newsletter to … try and convince people that they should go get vaccinated:

Right now, public discussion of the vaccines is full of warnings about their limitations: They’re not 100 percent effective. Even vaccinated people may be able to spread the virus. And people shouldn’t change their behavior once they get their shots. These warnings have a basis in truth, just as it’s true that masks are imperfect. But the sum total of the warnings is misleading, as I heard from multiple doctors and epidemiologists last week. “It’s driving me a little bit crazy,” Dr. Ashish Jha, dean of the Brown School of Public Health, told me. “We’re underselling the vaccine,” Dr. Aaron Richterman, an infectious-disease specialist at the University of Pennsylvania, said. “It’s going to save your life — that’s where the emphasis has to be right now,” Dr. Peter Hotez of the Baylor College of Medicine said.

No, it can’t save my life if you won’t let me get it. If everybody in the US was offered the vaccine right here, right now, you’d have 200 million takers, maybe even 250 million. Getting people to want the vaccine is not the problem right now!

Professionals at Pfizer, Moderna, and BioNTech did incredible, amazing, invaluable work, developing astoundingly effective vaccines in record time, and their work will save millions of lives. And it’s being wasted by political-driven delays when every day that vaccination is postponed another 4,000 Americans die needlessly. I can only imagine how infuriating this deadly government obstruction must be to the vaccine developers, hearing about thousands, then tens of thousands of American lives that could have been saved if only all 30 million doses they made so far had been administered right away.

The corrosive effects of the lies from the government officials in Sacramento and DC are despicable and deserve discussion and long-overdue corrective action, but that their “plan” was “do no planning and let the insurance companies, medical facilities, and county health departments deal with it on their own” is deplorable, and that they’re still refusing to get those vaccine doses off the shelves and into people’s arms is unconscionable.

10-Jan-2021

Mainstreaming the extreme

Filed under: politics — jlm @ 16:47

A: At least one more day.

We now have some poll numbers, and hence a more analytical take on the matter at 538.

8-Jan-2021

I’m with Colin Powell

Filed under: politics — jlm @ 20:41

How long am I going to keep beating this drum?

Powered by WordPress