Hi guys, I'm currently switching from mechanical engineering to Computer Programming analyst in September so I have a few months to learn how to do this..

What I want to do is make a Bot for a game.. The game is written in Java and I want to load it in C++ and use mouse functions to play for me..

I need a little push because I searched all over google and came across JNI and stuff but I still can't find any examples or someone who thought of this idea before :S

How would I go about calling java in c++ or invoking it.. I basically was trying to create a form with a large area and then I want to have it load the java applet.. If this is possible does anyone have any examples or links I can refer to?

I see no reason why you could do ALL of this in java?

Is the java application accepting command line parameters?

How would I go about calling java in c++ or invoking it..

I don't think you need to do that. Usually, a bot doesn't have access to the game's code.
It only interacts with the game the same way a human would interact with it. That is, by
getting visual input from the screen and sending mouse clicks to appropriate positions.

I believe the most straightforward way to do this in C++ would be to...

(1) Use OS API calls to get color information from the game window.
(2) Use that information to locate the player, the obstacles, the target, etc...
(3) Use some logic to decide what the next move should be.
(4) Use OS API calls to send keystrokes or mouse clicks to the game.
(5) goto step (1)

If you're on windows, these could be useful:


Umm but the bot does have access to the game's code.. the game is coded in java and the bot has to use reflection to determine player position or else I would have to use a whole bunch of colour finding functions to determine if they moved or not..

Btw the game in question is runescape.. Not that I play it, its just that I wanted to challenge this game as I see a lot of bots out there for it but can't figure out how they made it.. and they're all made in Java so I thought I'd make the first C++ one to see how hard it would be and if it would be possible to load java in c++ and how hard that would be :S

But judging by the amount of replies.. I guess it must be out of my league :c

JNI is used to access C/C++ and other machine code components from Java, not the other way around. That said, I think that there are ways to access Java code from C/C++ applications, but it has been a lonnnng time since I read anything about that. Anyway, my Google search on "calling java code from C" provided some interesting links. Here are a few:


(somewhat off-topic) BTW, if you want something for C++ you should really check this out -> http://code.google.com/p/bwapi/

I downloaded it recently and I'm playing around with it these days. I couldn't get version 3.5 to work; I'm using 3.4 beta with VS 2008 express.
I haven't tried the latest version yet. Here's a video with my latest creation -> http://www.4shared.com/file/pX1C5h00/capture_the_probe_AI.html
I use A* guided by an influence map to find the shortest path to a probe for my zergling, avoiding the photon cannons along the way (^_^)