Now that that’s out of the way, I want to talk about what exactly is in this release and the distinction between alpha and beta for this software. This version actually has very little in the way of content, so don’t expect to get a ton of playtime out of it. The terms alpha and beta get thrown around a lot in the indie gaming community and often times they are simply indicators of quality. I write software for my day job, so the terms alpha and beta have very specific meanings to me, and I want to explain that a little here as this release has a lot less going for it than many game’s beta versions.
I’m calling this software beta because from a coding perspective, it is complete. There are no more features that need to be coded, no more systems that need to be put into place. Outside of scripting a few scenes the rest of my time spent developing this game will be outside of the compiler. There is still a fair amount of work to be done before the game is truly complete but since the engine driving it all is done, putting this out here now will give me the most time before release to test it and find as many bugs as possible. So please, download the beta and try it out!
Just because I hit a major milestone today does not mean that I’m going to skimp on the normal weekly update. In keeping with what I put up last week, the theme for this week has been AI. I laid out three tasks that were left to finish on the AI, and as I’m sure you’ve already figured out if you’ve read this far, I got them all done. Most of the time was spent working on giving the aliens the ability to search for the player effectively, and that really was a tough nut for me to crack. I haven’t worked on any really complicated AI systems before, and I wanted to figure this one out on my own, so until yesterday it really felt like I was getting nowhere with it. I have to say though that the satisfaction I felt the first time I saw them fan out and actually search for me was pretty amazing, it was well worth it.
The method I laid out in my last post for handling the search behavior was pretty close to what I ended up with. In essence, once they lose track of the player, a search manager tells each alien in turn where to go to look for the player. They use a breadth-first scan similar to the A* algorithm that they use for pathfinding, but the nodes are much larger and there is no defined goal node. The search is also weighted based on the last observed movement of the player, so that they don’t immediately turn around once they lose track of the player. Once the nodes were set up, that part was relatively simple; getting the nodes set up properly, however, was more of a challenge than I thought it would be.
My original plan was to seed the map with a bunch of nodes in arbitrary positions along a grid, expand those out and then scan the map to look for holes and add more nodes, repeating until it reached an acceptable level of coverage. That idea might have worked eventually, but it was incredibly error-prone from the start and it took to long to finish. In the end I threw away the first part of the algorithm and just scanned the map from the start, creating and expanding nodes as I went until each tile had been checked once. This has the benefit of minimizing the number of times each tile is scanned, which made it run significantly faster, and created a more consistent and understandable system of nodes.
Brightly colored debug output showing the boundaries of the search nodes.
Once I had a set of nodes that covered most of the map, I was ready to start trying to figure out how to link them up. I say most of the map because I intentionally left certain areas of the map empty to give the player the opportunity to hide, but made sure those areas were few enough that you have to put some thought into it. Connecting the nodes together was actually pretty straightforward. I simply cast a line out from each tile on the boundary of the node out, up to the the minimum size of the node so it would cover gaps, and tied the nodes together if there was a straight shot between them. This saved me the trouble of having to try and path between them, and the results came out how I had hoped they would. In the end my node network appeared to be pretty comprehensive; all that was left to do was put it to use.
More brightly colored debug information, showing the links between nodes. These are the lines the aliens travel along to look for the player.
I’m pretty happy with myself for the implementation of this. The first attempts were horrible, the aliens just ran back and forth between two nodes, or else they all ran uniformly along the same paths. It became clear to me that I needed something more to manage the searching behavior. Luckily this is a problem that I had already solved when I did the initial pathfinding code for the aliens, so I just took that code and modified it. I would love to show this off, but since I’m on my laptop for the time being and it isn’t set up to record video, you’ll just have to download the game to see it in action. Once the search manager was in place, they fanned out just like you see in the movies. Each alien taking a different direction, spreading out and covering the large area in a surprising amount of time. I was actually having difficulty trying to hide from them long enough to make sure they were behaving correctly.
The last two bits, customizing the AI per unit type and giving them idle activity, took very little time. Since each type of unit covers only a part of the total AI system that was developed and in place, all that took was overriding the different methods that make up the system and essentially just turning them off for different classes. The idle activity isn’t great still, but all it’s lacking is animation to make something that I would actually be happy with. All they do is turn and face different directions based on how “interesting” those directions are to them, but it gives the player a predictable window to get past them, and that’s the most important piece.
I’m pretty excited for how this past week has gone. I’ve been very productive, now that the last of the logistic hurdles from our move is behind us. This next week should be a good one, and since it’s all content from here on out, I should have a lot more screenshots and other media to share.