Bot.java Explanation
Bot.java is the entry point for your ByteBot and is created by default in each new project.
Let's break down the default code:
The Bot Class
First, we have the Bot class. This is a public class that contains a single instance of your robot (class MyRobot in this case), which is created when the game starts. This is how the game knows about your robot. Remember that the file that contains this Bot class must be named Bot.java. You can change "My Robot Name" to whatever you want.
MyRobot Class
Next, we have the MyRobot class, which extends the ByteBot class. You can change the class name MyRobot to whatever you want (this name won't show up in game), but make sure to also change all instances of the name MyRobot to match it. The ByteBot class is the base class that provides all the functionality for your robot, and is required in order for your bot to function. You will probably put most of your code in this class.
MyRobot Class Constructor
This is the constructor for your robot. By default, all it does it set your robot's name by calling the constructor of the ByteBot class with super(name). This constructor always has to atleast set the name of your robot, but you can add more fields/functionality if you want to.
OnGameStep Method
Finally, we have the OnGameStep method. This method is called by the game every single turn. This is where you can start adding logic to your bot. If you haven't already, try adding moveForward(); to this method to make your bot move forward every turn!
ByteBrawl
0