Difference between revisions of "Robocode/Console Usage"

From Robowiki
Jump to navigation Jump to search
m
Line 1: Line 1:
 
This page describes how to run Robocode from a console.
 
This page describes how to run Robocode from a console.
  
==== Starting Robocode ====
+
== Starting Robocode ==
 
Robocode is normally started by the robocode.bat (on Windows) or robocode.sh (on Linux and Mac OS) batch files. The batch files is used for setting required parameters for the Java VM in order to start and run Robocode properly.
 
Robocode is normally started by the robocode.bat (on Windows) or robocode.sh (on Linux and Mac OS) batch files. The batch files is used for setting required parameters for the Java VM in order to start and run Robocode properly.
  
Line 19: Line 19:
 
But it is possible to change the way Robocode is started how it must run. That is, you can specify additional parameters to the command line that is used for running Robocode. These parameters are described in the following.
 
But it is possible to change the way Robocode is started how it must run. That is, you can specify additional parameters to the command line that is used for running Robocode. These parameters are described in the following.
  
==== Console Usage ====
+
== Console Usage ==
 
<pre>
 
<pre>
 
Usage: robocode [-cwd path] [-battle filename [-results filename] [-tps tps]
 
Usage: robocode [-cwd path] [-battle filename [-results filename] [-tps tps]
Line 39: Line 39:
 
</pre>
 
</pre>
  
==== Example 1 - Running a battle ====
+
=== Example 1 - Running a battle ===
 
In this first example, Robocode is running the 'sample.battle' from the 'battles' directory without the display (GUI), and where the results are written out to the file named 'results.txt':
 
In this first example, Robocode is running the 'sample.battle' from the 'battles' directory without the display (GUI), and where the results are written out to the file named 'results.txt':
 
<pre>
 
<pre>
Line 48: Line 48:
 
[[Category:Robocode_Documentation]]
 
[[Category:Robocode_Documentation]]
  
==== Example 2 - Disabling security ====
+
=== Example 2 - Disabling security ===
 
With this example the security manager is disabled, which allows a developer to let robots access files and classes from outside Robocode:
 
With this example the security manager is disabled, which allows a developer to let robots access files and classes from outside Robocode:
 
<pre>
 
<pre>

Revision as of 00:51, 27 November 2007

This page describes how to run Robocode from a console.

Starting Robocode

Robocode is normally started by the robocode.bat (on Windows) or robocode.sh (on Linux and Mac OS) batch files. The batch files is used for setting required parameters for the Java VM in order to start and run Robocode properly.

Robocode is started from a console by writing:

java -Xmx512M -Dsun.io.useCanonCaches=false -cp libs/robocode.jar;libs/codesize.jar robocode.Robocode

Here you must stand in the 'robocode' directory where Robocode is installed.

  • "java" is the command used for running the Java VM.
  • "-Xmx512M" sets the maximum heap size the Java VM to 512 MB RAM.
  • "-Dsun.io.useCanonCaches=false" prevents SecurityExceptions to occur when running code outside of Robocode's secured sandbox.
  • "-cp libs/robocode.jar;libs/codesize.jar" specifies the required .jar files for running Robocode.
  • "robocode.Robocode" specifies the main entry class of the Robocode game.

With all of the above, Robocode will startup with a graphical user interface (GUI) waiting for user inputs. But it is possible to change the way Robocode is started how it must run. That is, you can specify additional parameters to the command line that is used for running Robocode. These parameters are described in the following.

Console Usage

Usage: robocode [-cwd path] [-battle filename [-results filename] [-tps tps]
                [-minimize] [-nodisplay] [-nosound]]

where options include:
    -cwd <path>             Change the current working directory
    -battle <battle file>   Run the battle specified in a battle file
    -results <file>         Save results to the specified text file
    -tps <tps>              Set the TPS (Turns Per Second) to use
    -minimize               Run minimized when Robocode starts
    -nodisplay              Run with the display / GUI disabled
    -nosound                Run with sound disabled

properties include:
    -DWORKINGDIRECTORY=<path>  Set the current working directory
    -DNOSECURITY=true|false    Enable or disable Robocode's security manager
    -Ddebug=true|false         Enable or disable System.err messages

Example 1 - Running a battle

In this first example, Robocode is running the 'sample.battle' from the 'battles' directory without the display (GUI), and where the results are written out to the file named 'results.txt':

java -Xmx512M -Dsun.io.useCanonCaches=false -cp libs/robocode.jar robocode.Robocode
 -battle battles/sample.battle -nodisplay -results results.txt

Example 2 - Disabling security

With this example the security manager is disabled, which allows a developer to let robots access files and classes from outside Robocode:

java -Xmx512M -Dsun.io.useCanonCaches=false -cp libs/robocode.jar robocode.Robocode
 -DNOSECURITY=true

This allows a robot developer to let a robot access 3rd party libraries with suport for e.g. neural networks and similar.