Welcome to brianmacintosh.com. I'm Brian MacIntosh, and I am a game programmer in the Orange County area of Southern California. This site serves to host and distribute some of my games and my blog, below.

I have developed games and apps for the XBox 360, Windows PC, iPad, Amazon Alexa, and Windows 7 Phone. I'm particularly interesting in procedural generation, pixel art, and emergent gameplay, and I'm looking forward to developing more games with these technologies.

Blog

.gitignore: permit only certain paths with negation

Today I was trying to create a .gitignore file for a project that has to live in the same directory as a number of different folders. I wanted the git repo to only include folders that start with the string heroscape, while excluding any other folder.

The gitignore man pages point out that you can negate a pattern by putting a ! in front of it. I didn't notice at first that this does not ignore anything that does not match the pattern. Instead, it re-includes any previously ignored paths that match the negated pattern.

So to achieve what I wanted, I had to do the following, first ignoring all folders, then re-including folders that begin with "heroscape".

Keeping cmd windows open with /K

I like using .BAT files to run common tasks like compiling Java code or starting my NodeJS server. It's very convenient to just execute a .BAT where you've already written out all the proper parameters rather than typing out an entire call every time you need it. This does cause a problem, though - if any of the programs that execute from the .BAT returns an error code, the command window will immediately close. This makes it impossible to debug those programs.

I tried adding the pause command at the end of each file, but to no avail - the command window exits immediately when a program returns an error and doesn't execute the rest of the file (which is responsible of it, admittedly).

The solution was to use a parameter to the cmd program itself:

cmd /K bat/mybat.bat

The /K parameter keeps the window open even if the .BAT stops executing. I simply copied all my .BATs to a subdirectory and created wrapper bats using this line.

Computers in computers - Camera Obscura Adder

It's always fun to see people building computer-like circuits in games like Minecraft and Dwarf Fortress. While it's outlandishly impractical to build computers in computers, it's just so much fun and so educational. Well, today I figured out how to do it in the Camera Obscura engine using moving platforms and I was irrationally excited about it, so I built a four-bit adder circuit. It adds two four-bit numbers together and show the results. Check it out:

Boring details on how this works: there are several very small sets of logic gates, the basic building blocks of electronic chips, that can be provably used to create every other possible logic gate (trivia: NAND gates alone are sufficient, as are NOR gates). Camera Obscura's mechanics are capable of creating two gates: OR, by simply linking multiple sources to the same moving platform, and NOT (at least as far as I've discovered). Fortunately these two gates together are sufficient. Information can propagate through the system because moving platforms can press buttons that trigger other platforms...and so forth.

This possibility also provides some pseudo-scripting functionality to game levels. Imagine a passcode-protected vault that only opens when you enter the right number, or even a game of Mastermind within the level.

Side Project: Random Music Generation

This week's random side project was inspired by my friend Bryan Ploof and my Music and Technology class. We've been discussing music generated by computers with little or no human influence, including attempts to map anything from fractals to sorting algorithms to musical notes. Michael Matthews gave a lecture on his research in creating music using cellular automata. Cellular automata are sets of simple rules that define how a grid of "cells" evolves over time. They provide very interesting possibilities in the generation of music because their rules often generate musically interesting patterns and progressions. Michael's approach was to use a one-dimensional automata to control the pitches and timbres of sound available to a player, who modulated the sound directly through motions picked up by a webcam.

My goal was to make a system that could act autonomously to create a unified tune with a strong melody. My approach was to create three seperate automata to control different aspects of the music. One controls the rhythm of the song by selecting the timing of each note (quarter, eighth, etc). The other two control the notes that are played: one selects a chord from a pre-defined set, and the other selects which notes from the chord are activated.

Here's a sample! This video uses a few chords selected from the Star Wars theme to generate a tune.

An executable and the full C++ source are available on my code page. Future plans for the project may include replacing the chord-selection mechanism with a Markov chain to make it more musically coherent, and implementing samples and ADSR so the notes can be things other than sine and square waves.

Side-Project of the Week: Randomized Dungeons

This week, my friends Chris and Kevin and I were hanging out late one night. This, of course, led to a number of crazy ideas being bounced around (this, of course, is how most software engineering gets started). I actually decided that one of these crazy ideas might be doable, cool, and useful: a program that procedurally generates tabletop-RPG-style dungeons: monsters, loot, and most importantly, interesting and complex maps. I'm also using the project as an opportunity to learn more about rendering custom controls in a native Windows Forms project.

This is what it looks like, about three days later:

It can certainly generate some very entertaining map layouts, what with the occasional hallway where the floor is lava.