Science Tech Device Generator

July 16th, 2008

I’ve been mucking about generating a list for some test code here at work. To keep myself awake, I’ve been amusing myself by using some Back to the Futureish words.

flux capacitor

Here’s the code in case you need to generate a list of dumb device names in C++.

    vector<string> adjective_wordlist;
    adjective_wordlist.push_back("");
    adjective_wordlist.push_back("Inductive");
    adjective_wordlist.push_back("Sonic");
    adjective_wordlist.push_back("Retroactive");
    adjective_wordlist.push_back("Photovoltaic");
    adjective_wordlist.push_back("Universal");

    vector<string> pronoun_wordlist;
    pronoun_wordlist.push_back("Flux");
    pronoun_wordlist.push_back("Vortex");
    pronoun_wordlist.push_back("Space/Time");
    pronoun_wordlist.push_back("Field");
    pronoun_wordlist.push_back("Dimension");
    pronoun_wordlist.push_back("");

    vector<string> noun_wordlist;
    noun_wordlist.push_back("Capacitor");
    noun_wordlist.push_back("Coupling");
    noun_wordlist.push_back("Maximiser");
    noun_wordlist.push_back("Virtualiser");
    noun_wordlist.push_back("Retroactivator");
    noun_wordlist.push_back("Confabulator");



    for (int ii = 0; ii < 100; ii++) {
        string label;
        int pronoun_idx = ((ii / (noun_wordlist.size() * adjective_wordlist.size())) + ii)
                            % pronoun_wordlist.size();
        int adjective_idx = ((ii / noun_wordlist.size()) + ii) % adjective_wordlist.size();
        int noun_idx = ii % noun_wordlist.size();
        label += adjective_wordlist[adjective_idx] + " ";
        label += pronoun_wordlist[pronoun_idx] + " ";
        label += noun_wordlist[noun_idx] + " Power";
        cout << label << eol;
    }

Quick! to the Delorean!

[tags]back to the future, C++, geekery, list generator, programming, word generator[/tags]