Menu

Wall Detection

Help
Winkler707
2007-05-24
2012-09-15
  • Winkler707

    Winkler707 - 2007-05-24

    I've just started working on my first bot, and thought I'd try to put in a wall avoidance system, I figured that the most effective one would be to check continually check to see if the walls that I'm facing are too close for comfort, if they are, then I turn, It works exactly how I want it most times, but sometimes, when I'm firing or doing something else, it's as if the robot gets distracted or something, can't figure out a better way to put it, and it completely forgets to check if there is a wall, does anybody know why this might be???

     
    • Flemming N. Larsen

      I could be due to the events you are receiving when the radar sees a robot (onScannedRobotEvent) and similar events. Ideally you should put as little code in your event handlers as possible. The more code you put into the event handlers, the more code will be executed when the event occurs, and execution time will be "taken" from your run() execution time.

      By suggestion is, that you only use the event handlers to quickly update your internal model (e.g. where your enemies are currently located etc.), and then let your run() method react on the information you receive from the event handlers.

       
    • GrubbmGait

      GrubbmGait - 2007-05-29

      Please note that if you extend Robot, things like 'Ahead' and 'Turnxx' are blocking calls. That means they do not return until finished. That can take several turns! The command 'Fire' ends your turn immediately.
      If you want to avoid that, you should extend AdvancedRobot. This type is able to do several things at the same time, using 'Setxxx' (non-blocking) commands.
      Never use both blocking calls and non-blocking in your bot, except when you really know what you are doing.

       

Log in to post a comment.

MongoDB Logo MongoDB