Wednesday, July 15, 2009

Capture the flag

I'm interested in programming A.I. Not in an academic sense, but just for kicks. The problem is that I'm a pretty mediocre programmer. Still, the best way to learn anything is to just dive in there and sort out all the confusion (while making hundreds of ridiculously stupid mistakes.)

The language I chose to work with is c#. The reason is that I already know Java programming from my undergraduate days, and it seem pretty similar. Also, I'm now using a windows box, so why not use the nice .NET framework - I really just don't want to worry about the details.

My first program will be a game of capture the flag, in which the computer competes against itself. It won't serve much of a purpose, aside from sitting around and playing with itself all day (if this serves as a "purpose" in life, please let me know.)

I'm a "ground-up" kind of guy, so I'll start with a really bare-bones project and then build on it. My dream-goal for the end result is to have a program that makes use of a genetic algorithm and evolves to the ideal player for the job. My idea is that each player will have a geometric profile that determines it's characteristics such as acceleration, drag (air resistance), agility, and stamina. I'd like to see which characteristics emerge given the constraints of their duties.

The first iteration will have two teams, each consisting of a defender, a rescuer, and an attacker. The defender will hang out around the flag, and chase after the enemy attacker, the rescuer will help defend, until the attacker get captured, and the attacker will go for the flag. Each player is represented as a point. At each "tick" of the clock, each player thinks and determines his or her acceleration, and moves. They'll bounce off a wall if they run into it. The behavior will be determined by their "type":
Attacker: acceleration is sum of vectors towards flag and away from defender.
Defender: acceleration is towards where the attacker will be in 'n' steps.
Rescuer: If the attacker is captured, same as attacker but towards attacker instead of flag. Otherwise, same as defender.

I'll try to post the result of each coding session, whenever I have time to work on it.

Source code for version 0 (plus an addition or two), here but not commented and buggy ... more to come.

Version 0 in action:

No comments:

Post a Comment