A Brief Foray into Random Name Generation

I got a bee in my bonnet about name generation this morning, so here’s a simple Javascript module for randomly generating names:

/*
# NameGenerator

Usage:

  const starNameGenerator = new NameGenerator(['Ceti Alpha', 'Scorpio', 'Draconis'...]);
  starNameGenerator.generate(); // -> random name

Works better with a decent sized (hundreds) of thematically similar examples to work from.
*/
/* global module */

function pick(array) {
  return array[Math.floor(Math.random() * array.length)];
}

class NameGenerator {
// data is a map from character-pairs to observed successors,
// consider the examples "how", "now", "brown", "cow"
// the pair "ow" would have the following successors
// [undefined, undefined, "n", undefined] (undefined -> end of word)

  constructor(examples) {
    const data = {'': []};
    examples.
    map(s => s.toLowerCase()).
    forEach(example => {
      let pair = '';
      data[pair].push(example[0]);

      for(let i = 0; i < example.length; i++) {
        pair = pair.substr(-1) + example[i];
        if (! data[pair]) data[pair] = [];
        data[pair].push(example[i + 1]);
      }
    });

    console.log(data);
    this.data = data;
  }

  generate() {
    let s = pick(this.data['']);
    let next = pick(this.data[s]);
    while(next){
      s += next;
      next = pick(this.data[s.substr(-2)]);
    }
    return s;
  }
}

module.exports = NameGenerator;

I wrote a much more convoluted (but simple-minded) star name generator for my galaxy generator several years ago.  The approach I took was to take a collection of star names and break them up into syllables (starting, middle, and ending) and then given a range of syllable lengths, assemble a name out of random pieces.

Today it occurred to me that I’ve never explicitly implemented anything using Markov chains before, so how about I build something that way and see how it compares? If you follow the link, you’ll see examples of star names generated randomly the old way (names with “bad words” in them are rejected).

I took a list of proper star names from Wikipedia and cleaned it up (e.g. the Greek letter prefix of a star name simply indicates its brightness relative to other stars in the same constellation, while a Roman Numeral is simply an indicator of a star being part of a binary or trinary system). This gave me a bit over 600 star names with which to seed the generator, and the results are pretty nice. (Again, no need for bad world filtering.)

The major disadvantage of the new generator is that it can generate really long names pretty easily because of the way it terminates. If I implemented a more sophisticated generator that looked at things like overall length and length of current word in weighing the probabilities it would probably help here, but that might be overthinking it (it’s pretty easy just to reject overly long names).

In general, I think the new generator produces more pronounceable names than my earlier attempt, and some of the new names it generates seem like they should be real names, which is exactly what I’m hoping for.

Algorithm

The algorithm is very simple. The constructor looks at which characters follow a given pair of characters in the input data, so if you start with “how”, “now”, “brown”, “cow” you get the following data for the pair “ow”: [undefined, undefined, ‘n’, undefined]. So, using this data to generate names, 75% of names will end immediately after an ‘ow’ and 25% will have an ‘n’.

In this system, the first character of a name is following the empty string, while the second character of a name is following the first letter. It follows that using [“how”, “now”, “brown”, “cow”] all names will begin with ‘h’, ‘n’, ‘b’, or ‘c’. and most will end in ‘w’ and the rest will end in ‘n’. Not super interesting.

Let’s try slightly more interesting seed data: [‘Frodo’, ‘Peregrin’, ‘Meriadoc’, ‘Bilbo’, ‘Adalgrim’, ‘Bandobras’, ‘Celandine’, ‘Doderic’, ‘Erin’, ‘Griffo’]. This doesn’t seem like it will be enormously fruitful at first glance, but it immediately generates lots of new names that, to me, sound authentic: Adalgrin, Adobris, Grine, Bandine, Froderim.

And here’s a link to a jsfiddle to see it in action (with a bigger set of names from Middle Earth as the seed). One of the really nice things about it is that you don’t need to filter out bad words, because they pretty much don’t get created if they’re not in the source data.

It occurs to me that a lot of the random content generation stuff I’ve done in the past was, in effect, recreating Markov chains naively, and understanding what I’ve done in those terms is powerful and clarifying.

And with that, I leave you with a random Jabberwockish word generator. Don’t bewortle! And have a borpallith day.

Father’s Day — Picking Sides in Fallout 4

Random Prattle You Can Skip

As usual, I’m several years behind in my gaming, and — having pretty much completed Skyrim VR (all the major arcs, anyway) I decided to go back and try Fallout 4 (which had frustrated me around the first time I got my ass handed to me repeatedly by synths while doing nothing in particular).

father (head of the Institute)
Father — head of The Institute in Fallout 4 — and my excuse for writing this post today

I played Fallout and Fallout 2 back when they came out on the Mac in the 90s, and loved them. I played the hell out of Fallout 3, but got frustrated by New Vegas and never finished it. In general, I preferred the original games because you got to make significant moral choices (even if sometimes the content was juvenile).

Fallout 3 seemed to have turned into a more conventional action adventure, which I put down to the technical and cost limitations associated with AAA 3D games (building out huge alternate worlds to display widely varying outcomes is expensive, which is likely also why Mass Effect 3 was so lame.)

Anyway, Fallout 4 seems to me to be a return to the greatness of the originals. The moral issues are back and so, apparently are the choices. And, the game looks wonderful. (Both Skyrim VR and Fallout 4 have pretty terrible audio, frequently making me wonder if I have my headphones on backwards, which is impossible with the VR headset; there are a ton of physics, animation, and AI glitches — all of this just has to be accepted and ignored with Bethesda’s games.)

The Moral Question (SPOILERS!)

So, I’m pretty far along, and I’m confused.

In the Commonwealth there are several key factions, which I’ll summarize:

  • The Minutemen — these are the first folks you encounter, a rag-tag militia that’s almost been wiped out and simply tries to restore a cooperative community across the Commonwealth. Whether you like it or not you end up their “General” but (as someone put it eloquently on a forum) you still end up doing all their fetch and carry busywork.
  • The Brotherhood of Steel — this is the most obviously powerful faction. You encounter them, most likely, trying to find Diamond City (they’re very noisy!) Unlike the “lawful good” BoS from Fallout 3, these are more like the quasi-fascist BoS from Fallout 2. They make a good first impression (they’re defending themselves against feral ghouls), but if you steal a journal one of them has left lying around you quickly learn they have a dark side. In any event, when you join (as you pretty much have to) you quickly discover they are human supremacists and also pretty much anti-science.
  • The Railroad — a nod to the Underground Railroad in more ways than one, is a group of idealists trying to free synths from “slavery” and protect them from a surface population that hates and fears them. They’re run like a parody of John Le Carré.
  • The Institute — just as The Empire is introduced in Skyrim by trying to execute you for no particular reason, The Institute is introduced murdering your spouse (husband in my case) and kidnapping your son. Until you finally meet them face to face, all you know about them is that they killed your spouse, kidnapped your baby, they’re responsible for roving gangs of humanoid killer robots (that think out loud to somewhat comical effect), and that everyone blames them for everything, but disappearing people and replacing them in particular. Also, just as Skyrim’s Empire is the only place where you can bring up kids in relative safety and houses aren’t decorated with broken furniture and dead bodies, The Institute is the only place where you can sit down without wanting to sanitize yourself afterwards. (By way of role-play, I jumped on the chance to get a new toothbrush from a library vending machine…)

One of the interesting things I noticed in forum threads about the moral choice posed by needing to pick between these factions is (a) how sophisticated some of the arguments were (although there were plenty of “BoS are the only good guys” and “BoS are fascist losers” comments too), (b) how clever and effective Fallout 4’s writing is. In particular, in making their arguments, many players clearly take as fact that The Institute is guilty of all the things they’re accused of. Even though every missing persons case you investigate turns out to be entirely prosaic, everyone assumes that The Institute really is stealing people to use their organs, or something.

Here’s what you learn by actually visiting The Institute.

  • They create synths as servants.
  • They may have created the super mutants.
  • There doesn’t seem to be any overt cruelty in the way synths are treated, but then again they can mindwipe and reprogram synths at whim which is worse.
  • The gen-3 are almost certainly sentient, look completely human, and are clearly slaves, but The Institute’s citizens are in denial about this. (My favorite traveling companion is a synth detective, apparently a gen-3 prototype, who definitely seems to be sentient.)
  • You can see gen-3 synths being made from scratch out of goo via 3d printing. They’re not assembling stolen organs. (The sequence is very similar to Westworld’s credits, but this is in real-time game engine and came out before Westworld.)
  • It’s The Railroad that uploads people’s memories into synths to help them blend in (because otherwise the people on the surface would just kill them).
  • The Institute’s population includes scientists (“everyone here is a doctor, but I’m the only physician”) but also children (who seem totally normal and carefree).
  • The Institute have built a fabulous arcology underground.
  • Everyone in The Institute seems to be genuinely trying to make their own lives and life on the surface better. Yes, they’re ignorant and arrogant but so are the folks on the surface.

In a nutshell, the argument against The Institute is slavery / mindwipe. The argument for it is that it’s the only place you’d want to live or raise children.

Fallout 4 ultimately lets you choose between these four factions at the end. The Minutemen only really demand you kill The Institute whereas the other factions all want to wipe each other out (but don’t care about The Minutemen).

It seems to me that while The Institute is clearly wrong in its treatment of synths (i.e. slavery) it’s hardly worse than the Brotherhood’s position of exterminating all non-humans (i.e. genocide) especially when you consider that The Institute can actually make the world nice again and The Brotherhood can’t and won’t. It’s not at all clear to me that any of the factions are beyond redemption, but given that — uniquely in Fallout 4 — you’re someone who can remember the prewar world, it seems to me that there’s not much dividing the Brotherhood of Steel or the Minutemen from raiders and scavengers (indeed, there’s a diary in the room of the first synth you’re sent to recover detailing the collapse of a Minuteman splinter group into thugs and murderers), and the only way to return the world to a decent state is to keep The Institute around, and deal with its moral flaws.

Happy father’s day.

b8r 1.0

I decided to make the current revision of b8r “1.0” (it’s still marked “prerelease”) based on the fact it’s proven solid and usable during a year of constant use and improvement. It has been at least as robust and easy to work with as the jQuery-dependent library we developed at USPTO. I’ve just updated bindinator.com and my galaxy demo.

Recently, I made the first deliberately breaking changes and the difficulty of adapting various codebases that use b8r was pretty minor. So, I’m pretty confident that b8r is in good shape.

b8r's "fiddle" component in action
b8r’s “fiddle” component in action — b8r’s fiddle.component.js currently weighs in at 272 loc including markup, css, and comments.

I also improved the appearance of the inline fiddle and test components, and added prism.js code-rendering to all the various inline code examples to make the documentation pages look snazzier. A nice change to the test library makes sure that async test results are consistently ordered, and added a visible “pending” state so you can see tests that somehow failed to complete.

b8r has some pretty nice stuff. (Although much of this nice stuff needs to be documented.) You can download b8r, put nwjs in your Applications directory and/or npm install electron and double-click a .command file to see the b8r documentation inside a desktop app. Or you can install nodejs and double-click a .command file and serve it locally via https (I also provide a .command file will generate local ssl keys). (The .command stuff is currently Mac only, for which I apologize. I imagine it would be very easy to do it for Linux and Windows, but I haven’t tried.)

"electron-file-browser" component (running inside nwjs)
“electron-file-browser” component (running inside nwjs)

There’s a cute feature if you load the b8r documentation in nodejs or electron and command-click on a component — the component is loaded in a new window. I’m planning on leveraging this functionality to let the documentation app function as an IDE.

I’m currently working on convenience methods for multi-window desktop applications (it would be super cool if you could transparently bind across windows and browser tabs). I’ve also written a new version of foldermark that uses a very simple PHP back end (nodejs servers are still a much bigger pain to deal with than PHP) combined with b8r on the client-side.

The biggest shortcoming of b8r remains the fact that my team is the only group really using it. Because we’re developing a desktop app using Electron, we aren’t constantly testing on Edge, Firefox, Safari, etc.. I know for a fact that it has problems in IE and Edge, and that some of the example components aren’t touch-friendly, and we’re definitely doing more stuff for Electron than for nwjs (nwjs is much simpler to work with, but it’s becoming increasingly irrelevant, I fear). But if you’re working in reasonably recent releases of Chrome or Chromium, b8r should be very solid.

So, that’s the way it is: b8r 1.0.

BBEdit 12

BBEdit 12 (dark theme) in action BBEdit 12 is out. You can nearly make it look better with a dark theme now (although the circular “close” buttons indicating an open file are ugly) although it seems like there’s a bug in the theme customization right now. The Ulysses folks might consider this: cost of BBEdit 12 upgrade: $30. Cost of Ulysses for existing owners: $30. BBEdit 11 was released in 2014. BBEdit 12 has more new features than Ulysses has features. BBEdit is targeted at a smaller audience than Ulysses, so it’s not like it makes up for its low pricing on volume. That said, Ulysses is definitely prettier than BBEdit.

Replacing Crashplan

I’ve been pretty happy with Crashplan for five years or so, although lately not so much. Obviously, one reason to be unhappy with Crashplan is that they’re no longer supporting the family plan I was using to back up all our Macs. Worse, their quality of service seems to have (understandably) slipped as my plan approaches its termination.

Exhibit 1: my wife bought a new laptop. When she tried to restore files from her old laptop, they were MIA.

So, here we are at a nasty juncture where our supposedly bulletproof fire-and-forget backup system is (a) not working terribly well and (b) shortly going to not work at all.

Possible Crashplan Replacements

The obvious replacement is Carbonite. The problem with Carbonite is that it’s going either (a) be a lot more expensive than Crashplan was (because of our family plan — which is the equivalent of, effectively, n $100/year plans where n is the number of computers you back up; the small business plan works out as being stupidly expensive if you have more than 250GB of data) or (b) require me to do a bunch of work (i.e. set up one computer as the family server, have all the other devices back up to it, and then back it up via Carbonite. So Carbonite will either cost $300 (say) per year or $100 per year but require me to be my own network engineer. Oh, and forget mobile backups.

If I want to do a whole bunch of work I might as well just use Amazon S3. For 2TB of data that’s a mere $46/month. Ouch. I could probably use their cheaper long term storage, but now I’m basically starting my own Crashplan / Dropbox implementation and that sounds kind of like hard work. Forget that.

So, on to the “consumer” options (I’ve tried to pick 2TB plans as this is the absolute minimum I can live with):

  • Dropbox — $99 p.a. 1TB (there is no 2TB plan)
  • Box — $540 p.a. for unlimited (3 computers)
  • Hubic — $60 p.a. 10TB
  • Amazon — $120 p.a. 2TB
  • Google — $240 p.a. 2TB
  • Microsoft — $99 p.a. 5 users, 1TB/user
  • Apple — $120 p.a. 2TB (no Android client)

(Edit: TablePress was a disaster.)

Note that all these services support web browser access, so you can get at your files from any device with a web browser, but I’m talking about file-system integration where you can just save your file in the usual place and it’s seamlessly backed up to the cloud. I should note that Dropbox and Hubic even provide Linux clients. Everyone supports Mac, Windows, and iOS.

At first glance, Hubic looks like the standout value-for-money option. (Hubic is essentially like Dropbox, except it’s run by a gigantic hosting company). The problem is that I’ve found Hubic to have a poor user experience, especially with regard to performance. (My own experience is quite limited — and I’m kind of shocked that my blog post on Dropbox vs. Box vs. Hubic ranks quite high on Google searches for “Hubic Review”.) This may be a result of server location, or simply under-provisioning (10TB is so close to “unlimited” that I imagine it attracts a lot of abusive users).

(Edit: I should mention that Hubic offers both Dropbox-like services and backup services. It also has what looks like a pretty robust API. Also there are advantages to storing your data in France. On the other hand — no 2FA.)

At second glance, Microsoft OneDrive seems like a great deal at 5TB for $100/year. The problem is that it’s 5x 1TB per user, which is effectively 1TB. Still, a great deal if you’re happy with 1TB and want Microsoft Office for your family.

The shock comes at third glance — Apple’s product is competitively priced (cheaper than Dropbox!). It doesn’t support Android (surprise!) but aside from that it’s a great deal, you can share it with your family (with each person having segregated storage), it requires no real configuration and — this is the kicker — it’s smart about mirroring stuff to your devices. Want a 1TB photo library in the cloud? Great. Want it on every one of your family computers? Not so much.

Conclusion

Hubic is the clear winner in terms of price per unit storage. Apple is the clear winner in terms of functionality and comes second in price. When I take into account the fact that I pay Apple $3/month for a lower tier of storage just for convenient mobile backups it’s an even better deal (hooray for Opportunity Cost). After some consideration I’m thinking of doing both. Hubic for volume backup and iCloud for convenience.

I’ll let you know how it works out.

Followup…

I nearly gave up on Hubic. After paying for the 10TB plan I received no response and my account didn’t change… Well, until the next day. Sacré bleu! I’m still a bit concerned that the app hasn’t been updated since 2015, but it seems to work.

Anyway, I’m going to start backing up to Hubic and we’ll see how things go.

 

Further research has shown that there are two more reasonably-priced alternatives to Carbonite, notably iDrive and Backblaze. Backblaze seems very compelling for a single computer ($5/month unlimited; $4 with a two year plan), and not bad for a small number of computers (it works out as roughly the same as Crashplan for 3 computers). iDrive is offering some interesting discounts (and lets you handle any number of computers with one account) but I find the website poor to the point of suspecting the competence of the company.