Difference between revisions of "Infinity/Understanding Infinity"

From Robowiki
Jump to navigation Jump to search
(First pass Infinity tutorial)
 
m (MultiplyByZer0 moved page Melee Strategy/UnderstandingInfinity to Infinity/Understanding Infinity: Make it a subpage of the bot)
 

Latest revision as of 20:29, 9 August 2017

Infinity was my best nano melee bot for a long time until I shrank DustBunny enough to improve its aim. It's general strategy is to immediately run to an edge (hopefully a corner, but any edge is fine) and then move in a box pattern. I'll go into the details below.

Classes

Infinity is a nano - 99% of its code is in the onScannedEvent:

Functions

OnDeath clears the radar minimum scan distance to help with new battle target aquisition. OnHitWall resets my movement length. This is how I know when I'm on the edge of the battlefield instead of ramming someone. OnScanned is the rest.

Globals

  • movement How far to travel each leg of the square. Set huge to begin with to hit a wall.
  • lastHeading wasting space here.
  • lastTarget Name of the closest scanned robots. How I know who to aim at when it comes time to lock.
  • lastDistance Closest robot to me this scan.

Radar

InfiniteRadarLock when gunHeat is > 1, locks onto lastTarget when less than 1 so our aim is good. Resets lastDistance upon firing to make sure we are aiming at the closest bot.

Gun

setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians() + 
	Math.max((1 - e.getDistance() / (GUN_FACTOR+100)),0) * 
	Math.asin(e.getVelocity() / 11) * Math.sin(e.getHeadingRadians() - absoluteBearing) ));					

Basically, the closer to our target, the closer to a 1.0 guess factor we use. GUN_FACTOR is 500 so, at distance 0, full lead, at distance 600 and beyond, 0 lead. Assume full power bullets (11), so we tend to fire higher at higher guess factors than you would expect due to energy management.

Energy Management

Fire based on your own energy level divided by the distance to target. Basically, fire hard when you have energy, conserve if you do not, don't fire at opponents > 500 pixels. I've tested adding a 0 energy check, but it hurts my score.

Movement

Run to an edge, then move in a 90 degree box psattern. The exact length of each leg is very important! The area you traverse must be large enough that Head on Targeting has very low hit ratio while small enough that full linear/circulr targeting will be fooled as well. But! You must also make sure the length of each leg isn't too big as it will draw fire from more robots as well. Triangles work well, but have a higher chance of moving directly at an attacking bot (bad), More corners than a square make you traverse too large an area and makes you a target of opportunity too often and makes it more difficult to dodge linear/circular aim.

Overall thoughts

Infinity does well because its movement defeats head on targeting, linear/circular targeting at beyond 200ish range, and because it locks onto the highest threat it can find (the closest person!) It also does not fire at an enemy unless it had a decent chance of hitting - this version I believe that range was around 500ish. That change, while hurting my overall bullet score, boosts me way up in overall score. It only works though if he's the only one doing it. When 2 or more bots do this, the bonus in suriving is lost.