Sunday, September 20, 2009

FiringDock: My First Competitive Robot

Task: Design and implement a single robot that can reliably beat as many of the following eight sample robots as possible: Walls, RamFire, SpinBot, Crazy, Fire, Corners, Tracker, SittingDuck.

After studying the strategies of some simple robots include in the Robocode and brainstorming some strategy to counter those sample robots, for this week I started to build my first competitive robot which called FiringDock. Click here to download.

Movement: This robot sits still and only moves 100 pixels perpendicularly to the bullet when it hit by a bullet.

Targeting: The targeting for FiringDock is similar to the TrackFire. The radar and the gun always points at the enemy.

Firing: The firing strategy for FiringDock is very simple. The FiringDock always fires when the enemy is scanned. It fires with the bullet power proportionally to the distant between the enemy and the enemy's velocity. While minimizing bullet waste and maximizing the chance to shoot the target, it fires the maximum bullet power when the target sits still or is within 300 pixels; otherwise, it fires the lower bullet power.

Sound simple, isn't it? Now let's look at which sample robots it can defeat in a 1v1 battlefield.

Corner: the FiringDock has more chance to win the Corner because the Corner does not attack until it get to the one corner of the battlefield and it only sits still there. The chance that the FiringDock gets hit by the bullet is less because it moves to a new position when getting hit by the first bullet. The FiringDock also has a more efficient firing technique for a still target.

Fire: similary to the FiringDock, the Fire only moves when it hit by a bullet. With the firing technique that always fire hard at the still object, the FiringDock always win the Fire. The FiringDock also has a better targeting technique when it moves or the target moves. It scans for the target faster when it moves or the target moves.

RamFire: the FiringDock can easily win the RamFire because the RamFire take time to turn and move closer (as it tries to ram), it only fires when it hits the enemy and it does not move away from the bullet.

SittingDuck: the firing technique of FiringDock can easily kill the SittingDuck in every battelfield.

Tracker: the FiringDock can easily kill the Tracker because the Tracker only fires when it get within 150 pixels. The FiringDock can at least reduce 1/2 or 1/3 of the Tracker's life before it opens fire.

However, the FiringDock cannot defeat the Walls, the Crazy, and the SpinBot with the same strategies because it does not include a predictive shooting algorithm for a moving target. The FiringDock lost energy in two ways: it gets hit by the enemy and it wastes the bullet. Keep pointing the gun at the target does not work for a moving target.

Lesson learned: I admit that without looking into the code of each sample robot, the FiringDock probably defeat less than the five simple robots above. Designing a real competitive robot is very challenging. Though, we have an idea of how to defeat the wall by following behind it, coding a single robot that could defeat all will not be easy without some movement pattern recognition involve. While trying different ideas to design a single robot that defeat all, another option is escaping the bullet. The constraint to this option is the lack of functionality for scanning when the enemy fires a bullet. By googling the web, I realized that we can track this by tracking the energy drop (between .1 and 3). I beleive, with some additional conditions, this could be a potential solution for surviving the Walls, SpinBot, and Crazy.

No comments:

Post a Comment