Code Samples

This C++ code sample is pulled from my DigiPen senior game project, Last Stand. It implements a highly optimized A* pathfinding algorithm used by the grunt enemies in our game. It makes use of a binary heap for open list sorting. It also uses a data structure for all the tiles on the map maintained between calls with a shifting base ID, so the map does not need to be cleared every time the A* algorithm is run. A further optimization at a higher level, not shown here, is that the grunts only pathfind roughly 15 tiles in the direction toward the goal instead of pathfinding the entire way to the goal, then build a new path once they have reached about half way to the temporary goal. The AI I developed in Last Stand is extremely efficient, so hundreds of enemies can exist in the world without a noticeable impact to performance. This code will not compile on its own as it requires other parts of the project to exist.

This code sample is a complete ASP file pulled directly from my online web game, Teragaia. This file is executed whenever a player clicks one of the move buttons, which is the most logically complicated action in the game. The script must check if the player has moved on open ground, along a road, into his hometown, into another player's town to trade or ally, into an obstructed tile, into a guarded road, off the map, and so on. Once it determines where the player is moving, it takes appropriate action, or gives the user an error message if the action is for some reason illegal. The file uses the VBScript language for the game logic and Microsft Access SQL for the database updates and queries. I have renamed the file to a .txt file so it won't actually run and you can view it in your web browser.