Texture Utils

I wrote a texture generator thing:

It makes textures like these:

So, uh, if you want fancy checkerboards that might be your jam. Why would you want fancy checkerboards? Well if you’re me, for debugging 3d graphics. If you’re you, I mean, I can’t really tell you.

A BSP Compiler for Unity 3D

This is a bit obscure, but recently I’ve been finding myself needing to write some code to answer the question “is this object in an area or not.” Unity3D provides some functionality to do this, but it tends to be a bit imprecise in that only very simple primitives can be used (box collider, sphere collider, convex hull, etc.).

So, in order to automate this a bit, I built some tools to make this a bit easier. You can see/download the result on github.


On the left is the original mesh, on the right is a visualization showing which convex “zones” are created.

What this basically does is takes the selected mesh, and “fills” it with convex colliders marked as triggers. You can then use those triggers however you want.

Some caveats: It’s better to do this with low detail models, as the compiler can take quite a while on larger models. Also while there’s not a hard requirement that the meshes are sealed, the results generally will be better if they are.


Here’s a quick video of the game I’m working on right now. I’ll write some more details up soon.

Procedural World

I’ve been working on some prototypes with regards to generating procedural worlds recently, having been inspired quite a bit by this excellent series on polygonal map generation, and this great blog. I’m trying to go for something a bit different than what I think they’re after, but there are a lot of great ideas there.

(For those that don’t know, “procedural world” just means “giving a program a set of rules so it can build a world from scratch without any human intervention”)

One of my goals with this project is to try to generate a procedural world where there are still “dramatic points of interest”, if you will. When I say dramatic, what I mean is that some areas should feel differentiated and special, it shouldn’t feel too uniform. One of the problems with generating a world is that there’s sort of a sameness to everywhere, which I’m trying to avoid.

This is what my most recent attempt looks like, a quick hack-up C# app that I can also hook into Unity:


The idea is to generate a “feature map” describing what the dominant features of each area is, and then generate the terrain based on that. Why not generate the heightmap first and then the features? Mostly because the feature map is relatively clean in terms of being simple convex polygons which are easy to reason about programatically and mathematically. I have a lot of code that tends to be of the variety of “if this area is surrounded by these certain features, do this certain thing”. Height maps are pretty messy, so while you could go the perlin noise route and generate the terrain first, and then try to classify each area later, I thought it would be somewhat easier just to  throw down the polygons first, and then figure out a heightmap that works for it. I think that approach creates something that’s a bit less realistic, but I’m mostly happy with the results so far, although I feel like it could use quite a bit of post processing to look a bit more natural (hard to see from the screenshot, but the transitions are very rigid at the moment).

The goal with the feature maps is mostly to ensure that I end up with something playable in a deterministic way (ie, you can run checks against it and so on), which I think is a bit hard when you’re just working off pure noise.

In this screenshot, the different feature areas are color coded. In this case, the green areas are “highlands”, and the teal areas are canyons, and the dark green areas are bits of forest or foothills.  (You can guess what the blue and grey ones are). The hard to see orange squiggly areas are a (very rough) stab at defining road layouts for towns, although the towns are unconnected at the moment.

You can get a clearer idea of that from the base feature map below, which the above was generated from:


Basically this is just voronoi noise polygons + lloyd relaxation + sampling from a noise source w/ some rules, a lot like the link to Amit’s series above. I still feel like this is all a bit too random at this point though. It lacks points of interests. The next step is going to be to run some simulations across the generated landscapes to come up with more of a world with something of a story to tell.

Voronoi noise is cool

I’ve been playing with procedural world generation for a while now (because I’m lazy when it comes to level design), which of course means noise functions!

I’m really starting to dig voronoi noise after looking at some of the stuff you can do with it So, I hacked together a voronoi noise previewer:

(Next step: making it actually update in real time. It’s slow!)


Made this goofing around to see if I could compress an entire python program into a single expression. Who said Python Lambda’s aren’t powerful?!

    not globals().__setitem__('sys', __import__('sys'))
    and not globals().__setitem__('this', sys.modules[globals()['__name__']])
    and not globals().__setitem__('time', __import__('time'))
    [setattr(this, k, v) for k,v in {
            'set_color': (lambda c: w(['*', ' '][c])),
            'abs': (lambda t: (t + (t >> 31)) ^ (t >> 31)),
            'w': sys.stdout.write,
            'smash': (lambda t: -((t * -1) >> 31)),
            'color': (lambda n,k: set_color(smash (k & (n - k)))),
            'col': (lambda n, k: k <= n and not color(n,k) and col(n,k + 1)),
            'row': (lambda n: not w(' ' * (40-abs(n/2)))
                              and (col(abs(n), 0) or True)
                              and not w("\n")
                              and (abs(n) < 63 or n < 0)
                              and not time.sleep(0.05)
                              and row(n+1)),
            'triangle': lambda: row(-60) or True and triangle()
        }.items() ] and triangle() )()


My reddit game jam game

I made this for the reddit game jam about a month ago, but forgot to post it here. So… here it is. It’s pretty short, but for 8 hours it’s surprisingly playable. (I started late)

On Motivation in Game Design

This is a pretty cool animation of Dan Pink’s talk on motivation at the  RSA. (I didn’t make it, just linking it here). I think he also did a  similar talk at TED; and if you haven’t read Drive yet, you should.

A connection I think worth making here is that, in terms of game design, a lot of being a game designer is being a professional motivator. You want to motivate players to engage in some sort of activity (presumably a fun one — but; I’d argue it doesn’t have to be fun). If you’re good they’ll continue to do that task for a long period of time, and if not, they’ll quickly move on to something else. I know that’s a leaky abstraction, but it’s a potentially useful way to think about it.

Now, the most interesting point of that video comes about two minutes in when he’s talking about how rewards affect motivation, and the surprising conclusion that science has come to, which is: adding rewards to tasks only increases performance for activities that are cognitively rudimentary. Once tasks require more than basic cognition skills, rewards actually hurt performance.

So, if I were to give you a dollar every time you pressed a button, you would press that button a lot more, but if I were to give you a dollar every time you solved a puzzle, it’s likely that would actually solve fewer puzzles, even though you’d want to solve more for because it would net you more money; and increasing the reward seems to magnify that effect.

When you think about casual and social games, which tend to lean very heavily on reward systems to motivate players, it becomes obvious why they tend to be so stupidly simple. It has to be something anyone can do without thinking, or else it will become frustrating.

Now, what I’m curious about (and I don’t have an actual answer for this), is this: while we know that changing how we motivate players affects performance, it’s unclear to me how it affects engagement.

I mean, Farmville/Cityville/Whateverville games are not an intrinsically interesting activities on their own merits, I’d say. Those games rely heavily on intermittent reward schedules and social obligations. Yet they’re pretty engaging to the people who play them. On the other hand, games like Dwarf Fortress and Minecraft don’t rely on extrinsic motivation at all (if anything they tend to arbitrarily punish players), yet they’re also quite engaging to the people that play them.

So it seems to me that both intrinsic motivation and extrinsic motivation can be effective, but it’s not clear to me if mixing the two motivation types can amplify the amount of engagement they provide, or if they’re fundamentally incompatible. I’m guessing it could potentially amplify, but I couldn’t say for sure. As a thought experiment, say you put a leader board into Minecraft for who mined the most gold. Would that detract from players enjoying the game as a creative sandbox? Would players then not view the game as a sandbox, and instead focus solely on the most efficient way to dig for/find gold? Would that be less fun? I suspect the answer might be yes to all of those, but it’s something to think about.

Lessons learned from rapid prototyping

One of my favorite things to do is rapid prototyping — of anything really — but especially of games. There’s something inherently thrilling about hitting the ground running as hard as you can and aiming for done rather than perfect. I think, if you want to be good at making games, you absolutely have to do this.

The key to having good ideas is to have a lot of ideas, and similarly, I think the key to making good games is to make a lot of games.

The trick is to not dwell on any one game for too long.

I’m far from perfect at this, but having done it a few times, I think I’ve learned a few lessons.

Lesson #1: Measuring “Done” is easier than Measuring “Good”

The hardest part of creating something, for me at least, is dealing with the constant inner critic telling you that what you’re making isn’t close to what you were expecting.

The critic is right, but he’s not useful.

Ira Glass describes this way better than I can:

Personally, I like to view my games as experiments rather than products. I find an idea I want to explore, and explore it, then come to a conclusion about it. Sometimes the experiment results in something great, and sometimes it results in something that sucks, but it allows for the possibility of constructive failure.

Lesson #2: Deadlines matter, pick one that’s absolute.

Ideally you should have a time scale that’s long enough to get to the core of the idea, but not so long that you have the luxury of padding the game. Work always expands to fill the allotted space, as the saying goes.

I like one week.

One day is probably too short, unless you’re well practiced. One month can work, but it can be hard to not get distracted. One week seems to be long enough to get to the core of the idea while being constraining enough that you don’t wander too far from the goal.

Lesson #3: You aint gonna need it

You aint gonna need it. Times a million. You should get this tattooed on your forehead.

Lesson #4: The biggest time sink is polishing things

You are going to be constantly tempted to polish features that don’t matter. You have to avoid this temptation. Polish the gameplay, absolutely, but if you find yourself spending a lot of time on the menu screen, you’re polishing the wrong thing.

Lesson #5: Minimalism is your best friend

Try to find an art style that’s interesting or attractive but doesn’t take a lot of effort. Most indie games go with a “retro” look for this exact reason. Vector art can work well too, although it can be difficult to render, so be careful.

Darwinia is really visually interesting even though it’s mostly stick figures and polygons:


Minecraft is all squares, but the consistency of it is what actually makes the gameplay possible:

Lesson #6: Try to focus on a few core mechanics

I think this is a good design principle in general, but it applies even more here. It’s tempting when you’re designing something to think in terms of what you’re adding, but sometimes, the best ideas come from subtracting things.

On elite education

This is a great article on the disadvantages of elite education.

This part in particular struck me:

But if you’re afraid to fail, you’re afraid to take risks, which begins to explain the final and most damning disadvantage of an elite education: that it is profoundly anti-intellectual. This will seem counterintuitive. Aren’t kids at elite schools the smartest ones around, at least in the narrow academic sense? Don’t they work harder than anyone else—indeed, harder than any previous generation? They are. They do. But being an intellectual is not the same as being smart. Being an intellectual means more than doing your homework.

If so few kids come to college understanding this, it is no wonder. They are products of a system that rarely asked them to think about something bigger than the next assignment. The system forgot to teach them, along the way to the prestige admissions and the lucrative jobs, that the most important achievements can’t be measured by a letter or a number or a name. It forgot that the true purpose of education is to make minds, not careers.

Being an intellectual means, first of all, being passionate about ideas—and not just for the duration of a semester, for the sake of pleasing the teacher, or for getting a good grade. A friend who teaches at the University of Connecticut once complained to me that his students don’t think for themselves. Well, I said, Yale students think for themselves, but only because they know we want them to. I’ve had many wonderful students at Yale and Columbia, bright, thoughtful, creative kids whom it’s been a pleasure to talk with and learn from. But most of them have seemed content to color within the lines that their education had marked out for them. Only a small minority have seen their education as part of a larger intellectual journey, have approached the work of the mind with a pilgrim soul. These few have tended to feel like freaks, not least because they get so little support from the university itself. Places like Yale, as one of them put it to me, are not conducive to searchers.