Search code examples
javarobocode

Can't print to console in robocode


I am trying to write anything to Console, but with no luck.

System.out.println("abc");

Should work, but it is not. It is my whole code:

import robocode.HitWallEvent;
import robocode.Robot;

public class MyRobot extends Robot
{

    @Override
    public void run()
    {
        while (true)
        {
            ahead(20);
            System.out.println("Test Test");
        }
    }

    @Override
    public void onHitWall(HitWallEvent event)
    {
        System.out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees.");
    }
}

What am i doing wrong?

Best regards!


Solution

  • Robocode Standard Out

    Each bot prints to its own console. To access a bot's console:

    • Start a match with your bot
    • Click the bot's tag on the panel to the right

    Robocode: select bot's tag

    Now you should see something like this that contains whatever messages your bot is printing to standard out.

    enter image description here

    This window is also what you would use, should you wish to view what your bot has painted on the battlefield. This is a particularly helpful feature for debugging.