Replies: 3 comments 25 replies
-
@SirStone A bot API might be as simple as the BaseBot from the JVM and .Net APIs. That is a thin layer on top of a web socket. In order to make a Bot API, all aspects involving a "bot" with the schemas must be implemented, which is not very complicated. Basically, a bot must:
You can decide how the API must be, but the ones provided for JVM (Java) and .Net should serve as good sources of inspiration. Btw. there is no need for reverse engineering in the current Bot APIs, as the sources are provided as Open Source, and they have been kept as simple and straightforward as possible. At least that has been the intention. If you think I should write an article about it, then I should like to know where I should put my focus. E.g. the bits that are unclear to you. And I should like you to review it, and perhaps use it for writing a bot API for the language of your interest. That would serve as a good use-case. 🙂 |
Beta Was this translation helpful? Give feedback.
-
@SirStone The Bot API comes in two levels:
The Bot is harder to do, as it needs to keep track of exactly how much it has already been moving, with e.g. forward() from turn to turn. And it needs to take acceleration and deceleration into account using formulas from physics. This was (eventually) done for the original Robocode (from the RoboWiki blog), and I reused this code for Tank Royale. |
Beta Was this translation helpful? Give feedback.
-
@flemming-n-larsen I have some questions now, about how some details work in your original bot API and today I would like to focus on... blocking callsMore I think about these more I'm confused. The basic should be "while a blocking call is not completed not other calls are allowed, forcing the bot to take one action at time" example 1Walls uses on blocking calls, so it starts walking the wall and, using blocking calls like forward(moveAmount) should not be able to do nothing until the command is completed, instead onScannedBot the bot is able to call fire(2), another blocking call, and fire to the enemy and without interrupting or be blocked by the previous forward(moveAmount) command example 2I've made a simple Java bot with this behavior: starts spinning right forever using a blocking call, as a bullet hits the bot, it uses another blocking call to start spinning on the other direction. From my tests I see the bot start spinning right, at first hit the bot prints the message and changes the spinning direction, but only once, and is not responding to the bullet hits anymore until death. This is the code import dev.robocode.tankroyale.botapi.*;
import dev.robocode.tankroyale.botapi.events.*;
public class JavaTester extends Bot {
int direction = 1; // Clockwise or counterclockwise
public static void main(String[] args) {
new JavaTester().start();
}
JavaTester() {
super(BotInfo.fromFile("JavaTester.json"));
}
@Override
public void run() {
while (isRunning()) {
turnRight(Double.MAX_VALUE * direction);
}
}
@Override
public void onHitByBullet(HitByBulletEvent event) {
System.out.println("Ouch, I got hit by a bullet!");
direction = -direction;
turnRight(Double.MAX_VALUE * direction);
}
} PS: Happy Holiday to all readers! |
Beta Was this translation helpful? Give feedback.
-
Hi
I'm finding some interest in using a different programming language for the bots, is there any document that would explain better this piece of software than reverse engineering the java/c# code?
Beta Was this translation helpful? Give feedback.
All reactions