Category: Life

Every other post.

  • Being trans in Ottawa (Interactive Fiction)

    Being trans in Ottawa (Interactive Fiction)

    Today I’m proud to show off a short work of interactive fiction that I wrote, about being trans in Ottawa. You can play through the story by clicking here.

    In the rest of this post, I’ll talk a bit about the process behind the creation of this game.

    Four Stages

    From the outset, I realized that I wanted to create my own interactive fiction engine, that is to say, my own tools to create works interactive fiction. I did this because I thought it would be quicker to write my own than learning to become proficient in someone else’s, and because I had the ultimate goal of making the works I produced available online. I thought it would be easier to accomplish the latter if I didn’t have to work with someone else’s tools.

    This would be the second interactive fiction engine I created. I used lessons I learned from my first go at it, Story Creator. Story Creator was designed to be easy to learn, but wasn’t scalable – writing longer and more complex stories became unmanageable.

    If I wanted to create this work, I needed to follow four steps:

    1. Design a scripting language with which to create stories.
    2. Put together an interactive fiction engine that could turn those stories into playable games.
    3. Create a tool that would use the interactive fiction engine, and create a website through which people could play the game.
    4. Write the work of interactive fiction I had intended.

    Creating the Scripting Language

    I set out to create a scripting language – a way to formulate stories that a computer could understand as to make playable experiences. I spent a week or two writing tidbits of code on paper, imagining how a story could be written. This was a really fun challenge for me.

    I realised that these stories, much like computer programs, could be boiled down into two fundamental ingredients: state machines and the means to move between them.

    Everything in a story can be reduced to a state. The location of a player (bottom left) or a conversation with a character in the story (bottom right).

    In the case of a work of interactive fiction, each state can have text associated with it. If the player is in a bedroom, then there can be text specific to that, talking about the bed and so forth. If the player is in a different location, say, a washroom, the text can be different, talking about the sink and tub.

    The other fundamental ingredient, actions, change the state of these state machines. These actions can have different names depending on the state machine. For changing the location, the action could be called walking. For navigating a conversation tree it could be called speaking. The name is irrelevant. They all do the same thing: change state machines from one value to another.

    With that in mind, I separated the scripting of these stories into two: entities which would contain the state machines, and actions to change their state. The state machines would be defined using a graph description language called dot.

    In them, only the states of a state machine would be defined and how the states went from one to another.

    graph location {
    
        subgraph house {
            bedroom -- upstairsHallway -- bathroom
            stairs -- upstairsHallway -- masterBedroom
            livingRoom -- entrance -- stairs
            entrance -- kitchen -- livingRoom
        }
    
        shed -- lawn -- entrance
        lawn -- street
    }

    For the text to display with each state, I used a lightweight markup language called Markdown.

    # location
    
    ## house
    
    ### bedroom
    
    You are in the bedroom. It hasn't changed since your childhood. Your pink
    bed sheets. The blue walls. Your plush animals. Your polly pocket and
    transformers lining the shelves. Traces of your teenage self - the boxes
    of video games you kept perfectly. The computer you built, and rebuilt.
    An entire life that suddenly stops midway through university.
    
    ### bathroom
    
    You are in the bathroom.
    
    ### entrance
    
    You are at the entrance.

    Then for anything else related to the state machine, such as what initial state the state machine should be in, and what actions apply to the state machine, YAML was used.

    location:
      value: bedroom
      actions: [walk]

    Actions were also written in YAML. The idea was to trigger a change in state, to a specified value, by pattern matching against the sentences written by a player.

    action: change
    templates:
      - walk to the @value
      - walk to @value
      - walk the @value
      - walk @value
    synonyms:
      walk:
        - travel
        - go
        - head
        - enter

    The scripting language I designed on paper only received minor alterations during the implementation.

    Writing the Engine

    Writing the engine took place over the course of many months; I wrote about my efforts here when I was done. The task was broken into four parts:

    • The first was creating a compiler which would take works of interactive fiction written in the scripting language defined earlier and turn it into state machines it could use.
    • The second part was creating an engine which took the state machines and changed their state according to what the player wrote to advance the story.
    • The third was creating a command-line tool that could act as a front-end for the compiler and engine.
    • The fourth was documenting everything including how to write stories and all the parts of the engine. There’s no way I’d remember all the details in six months.

    In reality, all parts took place more or less simultaneously. I put together short works of interactive fiction, which I would pass through the compiler/engine using the command-line tool to test.

    I was very pleased with the end result. You could write simple sentences, and the engine would understand it, or present alternatives that it thought it understood.

    Writing the Web Tool

    Command-lines like that above were very convenient to me, as a software developer who enjoys retro experiences, but inaccessible to most people. If I wanted to create something other people could experience, I needed to put it online, and I needed to remove the part where people could write sentences in plain English. I created a tool that made websites for the interactive fiction, so that the only thing someone needed to play them was a web browser.

    This portion only took a week to do. The majority of the work had already been done when I created the engine. Meanwhile creating simple dynamic websites was easy with React, Bootstrap and Gulp. I wrote the code to combine the two.

    Creating the Interactive Fiction

    With tools in hand, I set out to create the work of interactive fiction. I had wanted to do a story about being trans in Ottawa. I wanted to show how transphobia was embedded in the everyday – whether walking down a sidewalk, going into a shop, reading a newspaper or using the washroom. I also wanted to show other aspects, including queer spaces and friendships.

    The story I ended up doing was about a life in a day in Ottawa. The protagonist starts off in their apartment bedroom, and is able to explore the city. Main Ottawa streets like Bank, Somerset, Wellington, Rideau, King Edward, etc. are here. So too are places like the Byward Market, shopping center, etc. The player is tasked with three objectives: get a coffee, go for a laser hair removal session, and attend a potluck.

    I’m very pleased with the final product. Though most of the content will go unread by a casual player, there are many random events, four characters that can be conversed with, and perhaps a slightly different view of the city.

    Feel free to give it a go yourself! The playable story is found here.

    The code for the story, in the scripting language I created, is found here.

  • To young women in tech (2018)

    To young women in tech (2018)

    The other day I decided to compile statistics on the gender balance at my workplace. I found that:

    • 0% of leadership (managers and above) are composed of women
    • 7% of technical roles are made up of women
    • 12% of all employees are women

    Now compare this to the 2016 census data. For Ottawa-Gatineau, where my workplace is located:

    • 29% of individuals ages 25-64 who majored in computer and information sciences and support services are women
    • 18% of individuals ages 25-64 who majored in engineering are women
    • 40% of workers over age 15 in professional, scientific and technical services are women

    My workplace discriminates against women. It isn’t intentional, but it is obvious. There’s even a physical manifestation of how this office regards women in terms of the washroom layout. Men have four stalls, four urinals, four sinks, and an air dryer. Women get three stalls, two sinks, and a roll of industrial paper towel that’s left on top of the garbage receptacle. The office layout including the washrooms was designed by one of the company’s senior staff, a man.

    I’ve tried to discuss the lack of diversity with HR and my manager to no avail. I was told women simply didn’t apply, as if our discriminatory hiring process was the fault of the women. Emails to the corporate diversity person and liaison for the women’s group to get resources went unanswered. This inaction is frustrating as I know that when companies try, they can do much better on gender diversity.

    This is the least gender diverse company I’ve worked at, but they are hardly alone. At a previous employer, a tech startup, only 9% of technical positions were filled by women. My own team seemed isolated from that sexism, at 40% women, but I saw those numbers crumble as a new director brought on only employees he personally knew, all of which were men.

    On my last day at that startup, an executive confided in me that she had been groped by an employee. Another worker told me she had been passed over for a promotion by the same director who exclusively brought on men, in favour of a less qualified candidate. At the same time that the company sponsored initiatives to improve gender representation, its CTO encouraged the sexualization of women in the company-wide group chat.

    This wasn’t remarkable. Anecdotes of impropriety specific to women are common in tech. One just has to listen to the women. On my end alone:

    • A manager told a group of us that the reasons that he didn’t hire a candidate was that she was conventionally attractive, and during her interview male employees were gesturing rudely behind her. He was sure hiring her would end with a sexual harassment case. She didn’t get the job because male employees behaved inappropriately.
    • A superior jokingly massaged me and another young female developer without our consent.
    • A friend told me how employees kept trying to ask her on dates. So did another at a different employer.
    • An employee cat called the wait staff during a work lunch. The same employee joked about grabbing women’s breasts without consent at the office.
    • Male employees wear t-shirts that objectify women at work and engage in sexually objectifying banter.
    • I’ve witnessed different groups of senior employees deride inclusive hiring practices.

    The executive who confided in me that she was groped did not report it to HR. Not a single woman I know who has been touched without their consent at work has reported it. For all the policies about workplace harassment, women still have to choose between risking their livelihood and enduring abuse. Every one of these companies had an anti-discrimination policy. They are ineffective.

    When women stand up, they’re thought of as unreasonable, as politically correct, as taking fun away. We need the men to stand up with us. Not just in word – the words come so easily – but in deed. To do so proactively. I’ve only met a few men like that in my career.

    So to young women interested in getting in tech, know that the work can be amazing. Your team mates can be amazing. Your boss can be amazing. Know too you will have to meet a higher standard than men to get the same job as men. Know you will not be promoted to positions of leadership like men are. Know you will have to put up with workplace behaviours that men will rarely if ever face. Know that other women, powerless to effectuate change, will be there for moral support. That others yet in positions of power will uphold the status quo.

    But you know what? A lot of women go through their careers without noticing this stuff and the pay is hella good. So join us. We’ll be here for ya.

  • 3D printing!

    3D printing!

    I got my first taste of 3D printing!

    I had been exposed to it five years ago when 3D printers started to get into the consumer market. The geophysics company I worked for had a 3D printer in one of its offices to test out manufacturing replacement parts, including tail fins.

    Fast forward a few years and 3D printing has entered the consumer market for hobbyists. The Ottawa Public Library has a 3D printer. A number of my coworkers at my current employer have one too.

    So for (a very belated) Christmas gift, I was asked for a map of Vancouver to figure out the best bicycle routes. This is actually a pretty complicated problem. Rudimentary car navigation relies on cost equations along lines (roads). These lines have different weight based on their individual speed limit, so that highways are prioritized over side roads. Then you figure out the shortest path, following the lines (roads), from one point to another keeping those weights in mind.

    With bicycles, you have to give paths weight according to the energy required to go up hills. This means combining two classes of data: vector (think lines like roads) with raster (think images like elevation). Open-source tools are pretty awful at combining these two. The math is fun, but difficult to implement and I don’t think the end-result would be useful. There are so many things you can do that wouldn’t be taken into account.

    So I thought of an alternative: what if they had a 3D printed topographical map of Vancouver? Then they could see for themselves what routes might be better for them. Our brains are pretty great computers.

    Making the model

    The first step was to download elevation data of Vancouver. Vancouver, like many other cities, releases this data for free as part of an open data initiative. This was likely collected through aerial surveys using LIDAR, post-processed to remove buildings and make the topography evident.

    I downloaded the data and loaded it into QGis, an open-source GIS software. I also downloaded road data and bicycle routes from Vancouver’s open data website. The person this was for had also given me important locations to them, which I loaded in as point data (not shown in these screenshots for privacy).

    I then used a plug-in for QGis, called DEMto3D, to create a 3D mesh in the STL format commonly used by 3D printers. I loaded this mesh into a free tool called Autodesk Meshmixer, as to simplify the mesh. The mesh file was initially 250 MB, and the 3D printer I was using supported a maximum of 64 MB.

    I then printed the mesh. The end result was pretty great! I lost some of the detail in the original mesh, which showed the road as bumps.

    I was very pleased with the end result!

  • Web front-end for Adventure

    Web front-end for Adventure

    In a previous blog post, I announced the completion of an open-source text adventure game engine, aptly called Adventure.

    The game engine came with a command-line front-end for demonstration purposes.

    I’ve now implemented a quick-and-dirty web front-end of the engine. It also includes text-to-speech, reading out the contents of the story to the user. I had intended to implement speech recognition as well, but this isn’t enabled in Firefox by default so I didn’t include it.

    Unlike the engine, this front-end is not really put together with other developers in mind, but if you’re interested, you can get the code here. It’s pretty simple stuff; the UI is made with React, gulp is the task runner putting everything together, and I use Express as a web server.

    Next up is writing a work of interactive fiction.

  • Open-Source Project: Adventure

    Open-Source Project: Adventure

    After four months of work, I’ve completed a new coding project!

    It’s an interactive fiction game engine. It lets you create text adventures – those games before the age of computer graphics that played like a novel unfolding before your eyes. The player would write what they wanted to do in plain language, and the game would understand that and spit out what happened next.

    A story in action.

    There are tons of game engines like this out there. I wrote mine because I wanted to write interactive fiction, and I wanted to write it in a way that was intuitive to me. I also wanted to have games playable through a web browser and that could be written in languages other than English.

    I created a declarative language for creating the games. Instead of programming the game by specifying what each step was to get to a final result, I made it so I could define rules for how things were related, and the game engine would figure out the rest.

    Writing an interactive fiction for the game.

    I’m very proud of what I’ve put together. Next up is writing the interactive fiction I’ve been meaning to create and putting that online.

    You can download the source code at GitHub.

    If you’re interested in writing interactive fiction, I would recommend downloading and using Inform 7 rather than what I’ve put together. Writing stories in Inform 7 is more intuitive to non-programmers, it has great documentation, and is just much more mature of a product.