Sunday, September 20, 2009

CounterAll, the All-in-One Robot

After creating simple robots and analyzing sample robots it was time to use my newly aquired knowledge to create my all-in-one powerful robot that could defeat the sample robots and hopefully any other opponent it came across.

Download: CounterAll

Movement
My robot uses a similar movement to the sample Walls robot where it moves along the walls with its gun facing inwards. There are some differences however including the direction it moves. The Walls sample robot moves clockwise around the battlefield while my CounterAll robot moves counterclockwise. If it is hit by enemy fire coming from in front or behind the CounterAll robot it will change directions. This is to minimize attacks from its "blind spot" where its gun is not pointed and therefore its radar cannot see.


/**
* Turns and moves left when hit by enemy fire.
*
* @param event Hit by bullet event set by the game
*/
public void onHitByBullet(HitByBulletEvent event) {
out.println("bearing = " + event.getBearing());
bulletBearing = event.getBearing();
// Only changes direction if the enemy is firing from in front or behind ("blind spots") where
// the gun is not pointed
if ((bulletBearing <= 0 && bulletBearing > -4)
|| (bulletBearing >= -90 && bulletBearing < -86)) {
turnLeft(90);
ahead(moveAmount);
}
}




Tracking
My CounterAll robot does not actively track its enemies. However, when an enemy runs into the CounterAll robot, it will turn to where that opponent is to fire at it.

Firing
The CounterAll robot fires at maximum power when it spots an enemy. It also fires at maximum power when another robot runs into it.

Win
My CounterAll robot can reliably beat the SittingDuck, Corners, Crazy, and Fire sample robots. SittingDuck, Corners, and Fire are easily beaten because they are stationary robots and make easy targets. Crazy may avoid bullets and other robots, but since it focuses mainly on moving it is not much of a threat attack-wise.

Lose
SpinBot and Tracker were two robots that my CounterAll robot had a hard time beating. SpinBot was definately the hardest robot to beat. It is constantly moving and therefore difficult to hit with bullets. It also had more ram points than CounterAll because it was usually closer to the center of the battlefield where there were more robots to ram into. The Tracker robot was difficult to beat because it actively tracked and hunted a robot. It was also a mobile robot which made it difficult to attack.

Draw
Walls and RamFire were considered a draw. If the CounterAll robot battled the Walls robot individually it would reliably beat it. However, when there is a battle that includes other robots as well, CounterAll does not reliably beat Walls. The second case is the RamFire robot. Scorewise, the CounterAll robot can beat RamFire. There is an exception when RamFire can catch up to or corner CounterAll resulting generally in a win for the sample robot.

Lessons Learned
There were certain strategies I learned that were better than others. Robots that were constantly moving made it difficult to shoot at. Therefore, avoidance strategies seemed stronger than attack strategies. When it came to tracking, robots that tried to track their enemies did not do a very good job and had difficulties keeping up with mobile robots. However, not using tracking strategies left firing up to chance that the robot would spot an enemy. I would probably do more testing the next time I did a project like this. Winning against one robot doesn't necessarily mean that it will beat the same robot if there are other robots in the same battle.

0 comments:

Post a Comment