简体   繁体   中英

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!

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:选择机器人的标签

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

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM