Monday, September 21, 2009

A robot that'll side step the competition...

As you all know by now from reading my recent blogs, we're been working with RoboCode these pass weeks. As this project comes near the end, we're task to design a robot that will not just beat the 8 sample programs that came along with the program, but also the robots design by our fellow classmates. To beat all the sample robots is no easy task considering that some of their movements and tactics are completely opposite, such as Walls and RamFire. Here is a brief overview of my design:

Movement: Movement is the most important part of this design. In order to beat the 8 sample robots, it had to be able to out maneuver them. I wanted to keep my robot at a certain range away from the enemy robot, where it can chose between different firepower. This is extremely useful when dealing with robots that have a fixed firepower. To get to this certain range, it goes in a diagonal pattern so it avoids majority of the incoming bullets. And when dealing with bots that charges or gets extremely close, it backs off a bit and side steps the enemy. With this design, I was able to keep away from enemies that charges in, and get close to enemies that runs around or away.

Targeting: For target, I used codes from one of the sample robots written by Mathew A. Nelson. It allows the gun to follow the enemy during the onScannedRobot. This is a lot faster than turning the whole robot with a stationary gun.

Firing: For firing, I used a modified version of the smartFire method in the Corner robot. This allow me to adjust the robot's firepower with it's distance away from the enemy. A very useful strategy to conserve energy, and attack enemies with fixed firepower.

Now that you know what the basic design of my robot does, Here are the results from battling the 8 sample robot. To test my robot, I did a 100 rounds against each of the robots.

SittingDuck: Win: 100/100
Fire: Win: 100/100
Corners: Win: 100/100
Tracker: Win: 96 /100
RamFire: Win: 90 /100
Crazy: Win: 97 /100
SpinBot: Win: 67 /100
Walls: Win: 34 /100

As you can see from my result, it didn't do so well against Walls and SpinBot, I knew from the start that these 2 robots would be the hardest to beat. Going up against these 2 robots with my design is seeing how lucky I am at dodging their bullets. I ran a few more test with SpinBot and Walls and the result fluctuate between 50-75% for SpinBot and 25%-40% on Walls. It's not the best design but it's the best that I can come up with at the moment.

I have to admit, I did do some googling to see what the strategies were for some of the advance robots. You know, just to get the feel and some ideas for similar strategies. but the implementation for some of the strategies that I found were way too complicated for me to understand. So I used a simplified version of the "chicken" strategy that I found. Instead of hiding behind other robots, it simply moves back and to the side as the enemy comes close. I know this is just the tip of the iceberg for RoboCode and for Java programming. Hopefully with time, I'll be able to explore deeper into this iceberg.

To download my source code for this SideStep Robot, Please click Here!

0 comments:

Post a Comment