User Tools

Site Tools


cs175:robocode_lab_-_gotocenter_gotocoords_methods

More on Methods in Robocode


See a version of the CenterBot from Assignment 4. This version uses Approach #3 to get to the center of the battlefield.

  • A. In CenterBot4.java, define the public void gotoCenter method, and call it from the Robot main loop to get to the center. Use the NearestWallBot1 as an example of defining a method and calling it.
  • B. Write a generalized variation of the gotoCenter method called gotoCoords that allows the robot to go to any x,y coordinates. It would be used like this from the Robot main loop,
         // x=0, y=0; moves to lower left corner
         gotoCoords( 0, 0 );

         // x=800, y=600; moves to upper right corner
         gotoCoords( 800, 600 );

Link to CenterBot4.java


cs175/robocode_lab_-_gotocenter_gotocoords_methods.txt · Last modified: 2014/11/29 22:21 by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki