Re: passing data between RobocodeEngine and the robots

fnl <[email protected]> Sun, 7 Feb 2021 12:06:29 -0800 (PST)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Robots in Robocode are constrained in what they can access on purpose.
But they do have small storage of 200.000 bytes for writing and reading 
data. This is used for e.g. robots based on genetic programming where the 
genes are stored as a string.

But you might be able to use this storage for your purpose as well.
Robots store their data into a directory named MyRobot.data if the class 
name of the robot is MyRobot in the 'robots' directory.
Try to run the sample bot sample.SittingDuck and check the 
/robots/sample/SittingDuck.data directory.

You can use e.g. getDirectory() 
<https://robocode.sourceforge.io/docs/robocode/robocode/AdvancedRobot.html#getDataDirectory--> 
and getDataFile(filename) 
<https://robocode.sourceforge.io/docs/robocode/robocode/AdvancedRobot.html#getDataFile-java.lang.String-> 
to get the File for the individual robot:

And you can write to the file using RobocodeFileOutputStream or 
RobocodeFileWriter, and read from it using regular input streams, e.g. 
FileReader (have a look at SittingDuck sample robot).

With this knowledge, it should be possible to write into the data directory 
with a file from the RobocodeEngine which the robots can read in.

Best regards,
- Flemming N. Larsen
søndag den 7. februar 2021 kl. 20.47.02 UTC+1 skrev [email protected]:

> I was wondering if there's any method to pass data (primitives or not) 
> from the engine to the sandboxed robots and vice versa other than writing 
> the files to the disk.
>
> I was thinking that a good way could be that the engine "offers" a 
> globally shared data point that the bots can write in and the engine read 
> from it.
>

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/robocode/dd2a707b-c255-4d60-b919-7a017661e8a4n%40googlegroups.com.