1 / 19

Winning Strategy in the Programming Game Robocode

Winning Strategy in the Programming Game Robocode. A Project by Daniel L. Rapp drapp1@pride.hofstra.edu August, 2010. What is Robocode ?. An environment consisting of several independently functioning robots. Each robot has certain attributes.

janina
Download Presentation

Winning Strategy in the Programming Game Robocode

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Winning Strategy in the Programming Game Robocode A Project by Daniel L. Rapp drapp1@pride.hofstra.edu August, 2010

  2. What is Robocode? • An environment consisting of several independently functioning robots. • Each robot has certain attributes. • Robots are comprised of three important parts: • Vehicle • Radar • Gun • Every robot has a distinct movement pattern. • Battles are over when there is one robot remaining.

  3. Research Goal • Achieve each of three metrics. • Winning Percentage = 100%!! • Health Percentage > 80 Points. • Accuracy Rating >= 90%.

  4. The Competitors - Walls • Walls is one of the precompiled robots that are packaged within the Robocode environment. • When matched up against all default robots, Walls is the top performer. • Movement pattern follows perimeter of battle area in a clockwise fashion. • Radar always faces forward. • Bullet always fired directly at enemy.

  5. The Competitors - Walls Walls Robot Radar and Movement Pattern

  6. The Competitors - WallsKiller • Radar spins freely, regardless of tank heading. • Movement of vehicle is in the shape of a diamond. • Travels in a counter-clockwise direction. • Smart firing mechanism accomplishes: • Calculates anticipated position of enemy. • Not firing shot if target is stationary. • Suppress fire if anticipated position not in battle arena.

  7. The Competitors - WallsKiller WallsKiller Movement Pattern

  8. Event Flow / Terminology Used • AdvancedRobot - Super class inherited by WallsKiller • ScannedRobotEvent - Occurs when enemy robot crosses the path of the radar • BattleData - Contains information at a particular point in time. • FireControlSystem - Calculates direction to fire. • FireCommand - Directive passed to gun. • Bullet - Fired at enemy.

  9. Firing Angle Calculation

  10. Firing Angle Calculation – cont. • The general formula applied here to calculate the Beta value is: • For the example on previous slide, Beta can be represented as: …since WallsHeading = 180.

  11. Firing Angle Calculation – cont. • Focus on triangle formed by robots and collision point. A = Beta from previous calculation a = Distance between robots b = Derived from enemy velocity * time c = Derived from bullet velocity * time Since the value of the time is shared between b and c, this value must be solved for to represent the two paths.

  12. Firing Angle Calculation – cont. • Given the following from the previous slide… a = Distance between WallsKiller and enemy = d b = Speed of enemy * time = v2 * t c = Speed of bullet * time = v1 * t A = Beta = Beta • And applying the Law of Cosines…

  13. Firing Angle Calculation – cont. The final formula, is in the form, …so we apply the quadratic formula. and the value used will be the difference in the numerator. This value provides the positive root.

  14. Firing Angle Calculation – cont. • Now that all values are known, reapply Law of Cosines. A = Beta from earlier a = Distance between robots b = Distance between enemy and collision point c = Distance between WallsKiller and collision point When the new value of this angle if determined, the final firing angle is the value of A above added to WallsKiller’s heading and the enemy bearing. This is the total angle from the zero degree reference.

  15. Firing Mechanism • Additional checks made to determine if a bullet should be fired. • If enemy not moving – DON’T FIRE!!! • Enemy is likely in the corner turning. Fired bullet at this position will not likely strike enemy. • If bullet out of bounds – DON’T FIRE!!! • Use special triangle formed between WallsKiller position and battle arena corner gun was calculated to point. • If the path from WallsKiller to collision position greater than special triangle hypotenuse, don’t fire. • If less than, collision position expected to be in battle arena, so fire. • If all conditions are met, bullet expected to fire.

  16. WallsKiller Results • Sampled across 15 battles: • Winning Percentage = 100% • Average Health Points after battle = 118.3666 • Average Accuracy = 86.5956 • Failed accuracy metric.

  17. Future Enhancements • Improving accuracy! • Alter shotOutOfRange logic. • Attempt solving for actual position of shot. • Ensure that enemy robot is against the Wall. • Account for enemy acceleration • Check for constant speed across two different ScannedRobotEvents.

  18. Conclusion • New software design tactics learned • Great insight to the overall development lifecycle • Fun!

  19. Thank you!

More Related