interfacing to C++ for bot coding

Discuss Artificial Intelligence and Bot programming.
Post Reply
skelterjohn
Posts: 4
Joined: Mon Mar 10, 2008 6:10 pm

interfacing to C++ for bot coding

Post by skelterjohn »

Hi all,

My question is how feasible is it to take a mod (specifically Battlemech - [url]http://static.condemned.com/bmech.shtml[/url]), and interface it to a C++ code base to do AI. I have a rather large C++ code base for adaptive learning algorithms (I am a grad student at Rutgers University in the Reinforcement Learning lab), and porting it all to .qc is not really an option.

Any tips? I don't have experience in hacking id engines, but I'm willing to put the effort in.

- John
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

edit pr_cmds.c
add some new builtins. there should be a list of em at the bottom.
index in that list is the builtin number its going to use.
use the G_* macros to read/write parameters, and return value.
How easy it is really depends on what existing interfaces you already have with your c++ code. Contexts might be tricky.
Labman
Posts: 62
Joined: Fri Nov 05, 2004 2:39 am
Location: Brisbane, Australia
Contact:

Post by Labman »

Tomaz's globot is an engine side bot written in C, so that might be a good place to start as well.

The Vr2 codebase has it, its not the original one as i've hacked around with it a bit, check out the bot.c, bot_*.c and bot.h files you can download the source and other stuff at entar's site http://entar.quakedev.com/

Also theres nn_main.c which contains an almost finished artificial neural network system for learning.
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

Note that he's pretty keen on having an engine that runs without problems in Linux (he and I have been talking by email). He's able to run Bmech's TomazQuake (the default engine) without problems, so I'm assuming TQ and related engines are are inherently linux compatible unless something has been done to break that compatibility.

He also wants to avoid coding his AI in QC, as the things he's trying to do will not lend themselves well to QC's abilities. He will need true arrays, large processing power, etc. As FrikaC and other bot coders will probably tell you, there's a few nasty limitations that QC requires you to overcome or compensate for, and building the bot in the engine's C code is actually going to be a very good idea. It's especially nice that Tomaz has already provided a basic bot in his code to build off of, so he doesn't have to worry about how to plug into Quake's client system etc.

Unfortunately, Darkplaces might not be an option because I can't get Battlemech's cameras to place nice with it (and he does want to use battlemech as the environment for his bots). However, I'll bet the TomazQuake family will more than serve his needs, so long as it's linux compatible etc.

Thanks for helping him out, everyone!
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

Try cl_movement 0?
i should not be here
xaGe
Posts: 465
Joined: Wed Mar 01, 2006 8:29 am
Location: Upstate, New York
Contact:

Post by xaGe »

That is needed leileilol, but its more than just that... The game plays fine under the last DP release with the exception of the mech's head movement. It goes from very jerky slow turning to jerky, jittery... Not sure if any setting could be changed to fix that yet?
leileilol wrote:Try cl_movement 0?
skelterjohn
Posts: 4
Joined: Mon Mar 10, 2008 6:10 pm

Post by skelterjohn »

So, I have DP built and running the battlemech mod (camera issues aside), but the source is a bit much for me at the moment. Anyone have some tips on what to look for to put in my own hooks? I scanned prvm_cmds.c (since a poster mentioned pr_cmds.c), but not sure what to do there... is there a particular source file that the AI is contained in?

People also mentioned globot as part of the TQ distribution, which I also downloaded (but have not been able to build in linux). I'm having the same trouble there, many source files and none of them are labeled "globot.c" (nor does the word globot appear at any point in the source, so it's possible it just isn't in this dist).

Any help is appreciated!

- John
Labman
Posts: 62
Joined: Fri Nov 05, 2004 2:39 am
Location: Brisbane, Australia
Contact:

Post by Labman »

skelterjohn wrote:So, I have DP built and running the battlemech mod (camera issues aside), but the source is a bit much for me at the moment. Anyone have some tips on what to look for to put in my own hooks? I scanned prvm_cmds.c (since a poster mentioned pr_cmds.c), but not sure what to do there... is there a particular source file that the AI is contained in?

People also mentioned globot as part of the TQ distribution, which I also downloaded (but have not been able to build in linux). I'm having the same trouble there, many source files and none of them are labeled "globot.c" (nor does the word globot appear at any point in the source, so it's possible it just isn't in this dist).

Any help is appreciated!

- John
Globot while by Tomaz isn't in any TomazQuake version (afaik). If you really need to be using linux for this, then i would suggest:
1) Finding an engine that compiles on linux already which hopefully works with the mod you have.
2) Having a look here http://www.flyingsaucepan.com/QMB/Code/ for the latest version of the Globot code that i've worked on for the Vr2 engine (which you can get the source for at http://entar.quakedev.com/Vengeance%202 ... source.zip if you need any more files to look. But Vr2 has never been ported to linux so that could be some work which is why i would suggest a different engine)
skelterjohn
Posts: 4
Joined: Mon Mar 10, 2008 6:10 pm

Post by skelterjohn »

Thanks, Labman, this is going to be very helpful :)

- John
skelterjohn
Posts: 4
Joined: Mon Mar 10, 2008 6:10 pm

darkplaces and the turning bug

Post by skelterjohn »

Hey

Any darkplaces code experts in here? No problem getting darkplaces source to build and run battlemech, but there is an issue with the mouse turning the mech (ie, it doesn't). I think the basic issue is the mouse is trying to turn the entity that hovers above the mech rather than the mech itself, and then that this entity gets continuous setangle messages. Anyone know how to figure out which entity to use to control the mech itself?

- John
Electro
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia
Contact:

Post by Electro »

it has scarey comments throughout the code!

Code: Select all

//#include "java_vm.h"
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Labman
Posts: 62
Joined: Fri Nov 05, 2004 2:39 am
Location: Brisbane, Australia
Contact:

Post by Labman »

Electro wrote:it has scarey comments throughout the code!

Code: Select all

//#include "java_vm.h"
Java hater!!!

I had an interface to call java call from quake and was considering hooking it up so you could call java code from quakeC, but there was too much environment setup fluff to make java work.

Also this is unrelated to the question at hand.



It sounds like you have a camera object which is attached to the mech object that you want to control, there are some camera solutions around but that's not something i have expertise in
Post Reply