3

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!

Marek
  • 1,189
  • 3
  • 13
  • 33

2 Answers2

11

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.

NonlinearFruit
  • 2,509
  • 1
  • 25
  • 27
0

I'm not sure whether you are actually able to print something to the console.

But I know you can write data into files which usually should be more useful anyway :).

If you want you can check the sample robot "SittingDuck" there is example code which is using file writers and readers.

Wald
  • 1,063
  • 7
  • 13