Robocode learning Notes (c)

  Yesterday saw Robocode the basic knowledge they wrote a bot, put it on the lack of a repeated BattleField defeated every…… sad ing. 

  Bot understanding of the surrounding environment is very limited.    Other robots can know the distance, position, direction, speed and energy levels.    However, it can not see bullets.    How it can effectively avoid the other side of the bullet? 

  Bot Although not bullets, but the other side's energy levels can still scan that.    As long as the other side will be fired bullets energy depletion, and depletion of the energy range between 0 and 3.    Based on these clues, how to find other robots being fired for it, "Ben Ben" Bot not to easy?    ^ _ ^ 

  Bot detected when the other fired bullets information, left or right movement a small step, Hei hei, down less than 1,10 ~ bullets and most Bot is the aim directly to the target either fired or tried in accordance with the speed Bot location and direction of projection.    If I do not move Bot, two algorithms will be precisely directed at the current location of this Bot fired.    Hahaha, when my mobile Bot again, not to you all can not hit.    (In the novel is not quite the master inaction flavor ?^_^) 

  Below are some code and Notes: 

  Double previousEnergy = 100; / / initial energy of 100 other state 
  Int movementDirection = 1; / / direction of movement 
  Int gunDirection = 1; / / barrel direction 

  / ** 
  * Bot detected each other, trigger events 
  * @ Param e 
  * / 
  Public void onScannedRobot (ScannedRobotEvent e) ( 
  / / Adjust themselves and the angle between each other 
  SetTurnRight (e.getBearing () * movementDirection +90-30); 

  / / If the other side of the energy loss a certain value, avoid action 
  Double changeInEnergy = previousEnergy - e.getEnergy (); 
  If (changeInEnergy> 0 & & changeInEnergy <= 3) ( 
  / / Escape! 
  MovementDirection =-movementDirection; / / and the last escape the opposite direction 
  SetAhead ((e.getDistance () / 4 +25) * movementDirection); 
  ) 
  / / Barrel at the current location of the other party 
  GunDirection =-gunDirection; 
  SetTurnGunRight (99999 * gunDirection); 

  / / Shooting 
  Fire (1); 

  / / Reset other energy 
  PreviousEnergy = e.getEnergy (); 
  ) 

  It is so simple?    This technique is also problematic.    A bullet fired, I Bot mobile, so it may eventually be moved back to within artillery trajectories.    Preferably in bullet to the estimated arrival of more mobile. 

  I have a more bold assumption: it is my Bot hit rate is not high, then if I do not Bot has been fired, but avoid each other's bullets, can be dragged each other's energy 0? 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Releated Articles

  • Popuklar Articles

0 Comments to “Robocode learning Notes (c)”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.