Codin’ Codin’ Codin’

Well, I’m spending the morning coding my capture the flag AI. It seemed deceptively simple when we started. Pathfinding couldn’t be that hard could it? At the start of the game I have it first figure out if it is horizontally or virtically farther from the opposing team’s flag, then move in the longer direction first, then the shorter. Considering there are 4 impenetrable barriers on any given board, (3 boulders and 1 of your flag) it’s inevitable that you’re going to run into one. Getting around it quickly is the hard part. Randomness can help somewhat, but that doesn’t dependably make the best move. If it runs into an obstacle, it looks for a beneficial move in the other plane of movement. For example, if it were heading west and ran into a rock, it would check to see if moving north or south would help more. If neither was benificial, it would pick one randomly. I haven’t a clue what it would do if it ran right into a rock again.

Ideally, I will next code it to check its distance from the enemy flag compared to that of the enemy to its flag, and protect if needed/possible. Maybe a few players to seek and destroy enemy dots, as well. I’m hungry. Lunch is soon…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.