Pathfinding and Politics

This post will cover two very different topics. If you could care less about programming or any of my projects, you might as well scroll down to the next topic in this post or close the web browser completely.


Right now I am in the middle of development on a combination tower defense/arcade shooting game. The idea is that the tower placement and planning is only part of the way to win. You also have to actively control a tower and shoot opponents as you fight through the waves. As the game progresses, it will shift from an arcade game to a tower defense game. Initially the player will start with a very limited supply of resources and will have to fight every enemy, but as points and resources are gained the player will be able to rely on their respective defense structure more.

I am not going to upload any screenshots at this time because the game is very early in development. The core engine is in place now, but it certainly doesn’t really look like a game yet. I need to code more main tower options, build the tower types and a placement system, and then add all the enemies. Once I’ve done that it should be ready for beta testing. When that happens, I’ll post something on here about getting testers, but will also flood Facebook and Purdue’s email lists with requests. The last couple weeks I’ve been making a ton of progress. Without marching band I’ve pretty much been dedicating my Saturday’s to working on the game. In fact, I’ve hit the critical point in which it’s more fun to work on the game than do a lot of other things, as was evidenced by my Friday and Saturday nights.

There are some interesting things that I learned about Android through the process, and have had to develop to make the game function properly. Because this isn’t a tower defense game with a direct enemy route, I had to implement basic pathfinding. In fact, that is one of the coolest parts of this game. The enemies come from three sides of the screen, so tower placement gives the player complete control over the paths that the enemies take. I used a reduced A* pathfinding system. I start from the final position and search outwards, without a destination in mind. This allows for a complete direction map from any node to the target tower. Any place that wasn’t visited sends the enemies in a diagonal path towards the base. The interesting thing about that is that in theory the user could just build walls around the base to slow the enemies down, although eventually they would fight through them and either be destroyed by the walls, or destroy the walls. Every time a new wall is placed, the direction map is updated and the enemies begin to follow the new route, so the player could also lure the enemies around the map and then close something off and force the units to move back the way that they have come. If there is a path to the tower from a given location, it will always be taken.

I also experienced an interesting problem with Android development that I never found with any of my PC coding. When the tower shoots, the direction is calculated, and the bullet travels in a given direction updating every game loop by adding the x and y velocity. What this ultimately meant was that the bullet could skip over enemies if the velocity was great enough. The bullet looks fine to the human eye, but was certainly not smooth enough to make the game function right. For collision detection, I have to take the dx and dy from the last update to the current position and break that down into ten smaller positions. Checking each of the ten small positions makes the movement small enough that a bullet can no longer mysteriously miss an enemy.

To conclude this section, I’ve learned an interesting thing about WidgetLocker. The application is incredible. It lets you completely customize the look of your lockscreen, and make it exponentially more useful. A couple months ago when I was first figuring out accelerometer programming, I noticed that the lockscreen replacement actually caused some issues with pausing and resuming the event listeners. Ultimately that ended up being a problem I had, I was not pausing and resuming the main thread, and everything was resolved. Recently I’ve noticed that some applications on my phone do not always work correctly. Like EA’s Dead Space rarely seems to work right. It turns out that WidgetLocker and the HTC EVO Design 4g don’t always agree. I have no idea if this is a bug that exists for every build or just on my phone, but it is quite annoying. What is does is makes it so the phone can no longer keep track of a specific ID of a finger on the touchscreen. This makes tracking the fingers pretty much impossible and destroys any well-written application. I am confident that I am doing nothing to cause this error, as I have tested with and without the lockscreen mod enabled and have used code that works correctly for other people. Anyway, that is a bit disappointing to discover, but it is nice to know that I am not completely crazy in thinking my code should always work right. The moral of this story is that themeing phones can actually have a negative effect on performance and functionality.


I’ve been taking Intro to US Foreign Policy as an elective from Dr. Targ. The course is a study of foreign policy from the end of WWII to the present. We’ve had to read some excellent books including Rise to Globalism by Ambrose, Overthrow by Kinzer and Superpower on Crusade by Gurtov. I’ve learned a lot and overall it has been an great class. I finished the Gurtov work this weekend, and was really intrigued by the portrait he paints of Bush. Growing up, I was too young to really focus on politics and pretty much just assumed he was a good president. After reading that book, I have no idea how I feel. It gave me a ton of mixed feelings about the position the United States takes on foreign affairs.

The class has pretty much highlighted the US position that financial and political gains act as the main motivators for US actions abroad. Studying South and Central America, Asia and Africa, it is very clear that the United States supports whoever agrees with the present political goals. Regardless of a nations ultimate goals or positions on social issues, they will receive United States support if they agree to fight whatever stands as the present state of fear.

From a capitalistic standpoint, our government is essentially a business in the business of supporting its citizens. A country works to protect their interests and secure wealth and sustainability for them. From a business standpoint the game of war makes a lot of sense. For the most part, the United States does not have a ton to lose, and everything to gain. And with that, the Bush Doctrine of preemptive attack makes a lot of sense. It really is no different than a business trying to develop something before their competition can and thus undermine the oppositions profits and market share.

Going on from the concept of a business, it also makes sense to ignore the social issues of another country, unless of course they are creating a better social state then you are. In that case, copy their social programs. Looked at from a business standpoint, human rights violations, war, genocide, famine, etc. only matters when it hurts the given country that you are a part of.

The problem is that a government is not a business, and letting a government fall or abuse its “employees” means that real people are being killed or hurt in some way. That isn’t right, or good in any way.

I do not know where I am going with this. Maybe the fact that more than anything, it is hard to be a good politician. I’ve realized that I lean more right than I expected, but certainly do not agree with everything. I would recommend that you read those books though. Education is the only way to solve the problems that exist. Politics matter and our future matters. I have no idea what the answer is, and where the line is drawn between government as a limited support system and government as a complete social system, but there has to be a right answer somewhere. It should be possible to save people and to stay safe and sufficiently affluent at home.

Overall I am just appalled at the kind of governments that can receive United States support and military aid, considering the conditions that their citizens live in. At some point the United States stopped practicing what it really preaches, or maybe it stopped preaching and no one noticed.

Anyway, just some food for though. If you only read one book, pick Overthrow, it was quite interesting and very entertaining.