SOBot proof of concept release

SOBot proof of concept release

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

BBF
Posts: 4
Joined: 17 Jan 2006, 22:44

SOBot proof of concept release

Post by BBF » 31 Jan 2006, 16:51

Hi everyone,

I've being tring to hit on the forums but was having issues (tnx Betalord).
Well, I'm new to TASpring, but I decided to try to contribute something to it aswell.
I know there are a pack of AIs around already, and some are coming out really nice.
But I still wanted to adopt a new approach to current way AIs are being made.

I spent a weekend coding this, and it's FAR from complete, or even functional.
But I wanted to know what the community thinks of it.
What I did, was hook the TASpring GlobalAI API to a ECMAScript (Javascript) handler.

Before any flaming begins, NO, this won't make the AI slow.
Critical parts of the AI shall be implemented still in C.
For example, Krogothe's Metal Class in already in it, and may be accessed thru a global variable called metal.
So I can keep performance critical stuff in C, and expose them to javascript.

My current development has paused, since I'm moving to a new place, and I have no Windows box right now to continue it's development.
But if anyone finds this interesting, and want's to develop the javascript part of the AI, I would be willing to continue.


Well, I'm including a 2 files in this post.
One zip with the AI dll, and a example javascript that documents everything that has been implemented so far, and another one with the JS32.dll which should be placed along with the TASpring.exe

SOBot 0.0.2
JS32 Library

I would love constructive comments and suggestions.

Cya
0 x

User avatar
Michilus_nimbus
Posts: 634
Joined: 19 Nov 2004, 20:38

Post by Michilus_nimbus » 31 Jan 2006, 22:16

Am I right if I say this could be used to create an AI with a Javascript-like language?
In that case, hats off to you!
0 x

Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic » 31 Jan 2006, 23:13

javascript is a bit gayish though :P
why not make all the ai in c++ ?
0 x

User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 » 01 Feb 2006, 00:27

Because not all of us have the degree in quantum physics that C++ requires?
0 x

Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic » 01 Feb 2006, 00:46

Triaxx2 wrote:Because not all of us have the degree in quantum physics that C++ requires?
naa.. c++ doesnt require all that depending on what you want to do its harder or simpler but take one thing at a time should still be pretty fine in c++ :P
0 x

User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen » 01 Feb 2006, 03:02

Because not all of us have the degree in quantum physics that C++ requires?
I should really start learning then ;)
0 x

User avatar
Slamoid
Posts: 237
Joined: 25 Jan 2005, 19:23

Post by Slamoid » 01 Feb 2006, 06:36

Hey, this is a GREAT idea, and so far a fairly great interface! EXCELLENT documentation. Good job.

I just have a couple requests... First, I can see that this will have to be a VERY mod-specific AI. But it still needs some commands:

Entered/Exit LOS/Radar *Location param, Enemy/Friendly destroyed *Location param, and a SendChatMSG command.

Other than that, this looks good! Wait, right now it looks dang good! Just get these new commands and a Build command, and we got it made!
0 x

b1ind
Posts: 48
Joined: 21 Apr 2005, 04:01

Post by b1ind » 01 Feb 2006, 07:56

I for one, think js is an awesome choice! I've been coming to appreaciate the language more and more. The prototyping concept and anonymous functions are just great. I think someone (I'm reluctant to make any commitment myself) could pull off something really neat. Definitely keep up the work!
0 x

submarine
AI Developer
Posts: 804
Joined: 31 Jan 2005, 20:04

Post by submarine » 01 Feb 2006, 09:07

i've been doing quantum mechanics the last few months and could not figure out how wave functions and infinite dimensional hilbert spaces are related to my aai-coding efforts yet :)
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Post by AF » 01 Feb 2006, 20:08

hmmm, Java would be just as hard to learn as c++ if you where doing it solely to work with the spring AI interface to begin with. It's learning the syntax and howto use functions and classes, after whcih it's all stuff like 'how you implement your AI' which is sorta Java/c++ independent.

Nice stuff tho, I tried doing ti with lua a while back but that was a botched attempt, I was less experienced though, maybe I should try again....
0 x

Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic » 01 Feb 2006, 22:15

AF wrote:hmmm, Java would be just as hard to learn as c++ if you where doing it solely to work with the spring AI interface to begin with. It's learning the syntax and howto use functions and classes, after whcih it's all stuff like 'how you implement your AI' which is sorta Java/c++ independent.

Nice stuff tho, I tried doing ti with lua a while back but that was a botched attempt, I was less experienced though, maybe I should try again....
Java is still diferent from Javascript
0 x

User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 » 02 Feb 2006, 00:14

I think that every last one of us is crazy, trying to learn C++, and start building an AI with it? But if we were all sane, we'd have to play with other people.
0 x

User avatar
munch
Posts: 311
Joined: 26 May 2005, 20:00

Post by munch » 02 Feb 2006, 14:24

AF wrote:hmmm, Java would be just as hard to learn as c++ if you where doing it solely to work with the spring AI interface to begin with.
I disagree. The problem with learning C++ is that there are a ton of pitfalls to fall into. If you write C++ the obvious way it looks like it should be written you end up with code that crashes. Java on the otherhand protects you from almost all of the C++ pitfalls. They're either defined away by the language (e.g. no direct access to pointers) or caught by the compiler. Java does take a long time to learn, but that's largely because of the vast standard library, which of course you don't have to learn... and when you do, it just saves you time since you use the library classes you've learnt about instead of spending time writing and testing them yourself. As with all standard libraries, you get the benefit of a vast user base feeding back any bugs etc.

However like somebody else already said, ECMAscript is a different language from Java!

Just my tuppence

Munch
0 x

Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic » 02 Feb 2006, 19:26

munch wrote:
AF wrote:hmmm, Java would be just as hard to learn as c++ if you where doing it solely to work with the spring AI interface to begin with.
I disagree. The problem with learning C++ is that there are a ton of pitfalls to fall into. If you write C++ the obvious way it looks like it should be written you end up with code that crashes. Java on the otherhand protects you from almost all of the C++ pitfalls. They're either defined away by the language (e.g. no direct access to pointers) or caught by the compiler. Java does take a long time to learn, but that's largely because of the vast standard library, which of course you don't have to learn... and when you do, it just saves you time since you use the library classes you've learnt about instead of spending time writing and testing them yourself. As with all standard libraries, you get the benefit of a vast user base feeding back any bugs etc.

However like somebody else already said, ECMAscript is a different language from Java!

Just my tuppence

Munch
theres a very interesting point in java thought wich is that its main intention remains on object oriented principles and it gives the programers all those bug protections you told and some more like security issues and so, therefore its pointed out that java has performance penalties over c++ at the cost of other things of course.
So if you are to make a quite complex ai that requires some quite complex algorithms and so, java is probably not the best to go for.
0 x

mongus
Posts: 1463
Joined: 15 Apr 2005, 18:52

Post by mongus » 03 Feb 2006, 00:38

hey anyone got this ai to work yet?

i cant.

put the files in

globalai\

sobot\
sobot.dll


and the jre32 (or something) in the root TASpring folder.

i get a missing dll for sobot.

any help please?

edit: the js32_release.rar file was unpacked of course, and the js32.dll inside it was put in spring root folder, thats how i attemped to run it.
anyhow thanks for the try.
Last edited by mongus on 04 Feb 2006, 00:04, edited 1 time in total.
0 x

BBF
Posts: 4
Joined: 17 Jan 2006, 22:44

Post by BBF » 03 Feb 2006, 13:09

mongus wrote:hey anyone got this ai to work yet?

i cant.

put the files in

globalai\

sobot\
sobot.dll


and the jre32 (or something) in the root TASpring folder.

i get a missing dll for sobot.

any help please?
That JRE32 needs to be unpacked into the root directory of Spring. It was packed with RAR, so you need something like WinRAR. Later on, I'll post a zip version of it also.

@ Michilus_nimbus

Yup, that's it

@ munch

Your words couldn't be more right.
My attempt to implement the javascript interface is make the community more able to code AIs, in a safe place.
You can't do a bad reference in javascript, and crash the whole thing.
Of course nothing is 100% idiot-proof, but it's much safer.
Also, people who are interested in coding an AI, be it a complex one for all mods, or a simple one for something like Nanoblobs, will have a much easier learning curve, without all the required C/C++ background.
And really, our current AIs aren't really stable, because there are a lot of errors that are not being caught.
Don't expect malloc() to always return you a pointer even with your massive 1 gb of RAM.
I'm being very paranoid about every possible thing that could crash this AI aiming for a really rock-solid (OpenBSD style) interface. (Ah, ok, maybe not OpenBSD, but near it... )

@ AF

I did initially implement this using LUA, but even tho LUA is as easy to learn as ECMAScript, who really does know LUA ?
Also, there are tons of features in ECMAScript which are nicer then LUA.
So I gave up on the LUA version also.
I also choose Javascript because I had already seen a project which used it, and it worked really nice.
I wonder if anyone ever seen d2jsp. My pindleskin run took about half the time the public script took. :twisted:

@ Slamoid

The interface isn't actually mod-specific at all.
I have implemented nothing mod-specific so far, and don't intend to.
I'll implement a game.GetModFile() or alike so you can find out which mod is being used from javascript, and act accordingly.
About the Location param, even tho I could implement that, it currently isn't provided by TASpring's API.
And I haven't checked the latest code on SVN to see if there was any change, but I doubt there's something like that.
Before I go wild on implementing stuff like that, I really would like to implement fully, all functions provided by the API.
My next step will surely be to implement the group functions.

Code: Select all

// let's say "target" just attacked out unit
var bravo_grp = unit.getCurrentGroup();
bravo_grp.Attack( target );
But since I'm in process of moving and without a windows box, it'll take at least another week.

And I have yet to define a standard on naming of the functions. I think Java's standard for Javascript shall work nice, like:

Code: Select all

unit.move()
unit.doSomething()
// instead of:
unit.Move()
unit.DoSomething() unit.dosomething()
Any comments on that ?
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Post by AF » 03 Feb 2006, 20:13

Don't expect malloc() to always return you a pointer even with your massive 1 gb of RAM.
mwha, I've never used malloc, one needs to brush up on ones c++, and howto sue new and delete statements.

Either way I have not looked directly at the itnerface you provided but those quotes show me it's looking very different, can you not attempt to add the current system whereas a command structure is sent off along with a unit id then we can define the command id and add whichever parameters we wish? I find ti would be a much more pwoerful tool than the likes of group.attack()
0 x

User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon » 03 Feb 2006, 22:52

Java AIs? Madness, but I can't pass it up!
0 x

b1ind
Posts: 48
Joined: 21 Apr 2005, 04:01

Post by b1ind » 04 Feb 2006, 05:03

OT: Just as malloc() can fail, so can new. Keep that in mind.
0 x

BBF
Posts: 4
Joined: 17 Jan 2006, 22:44

Post by BBF » 04 Feb 2006, 14:15

AF wrote:
Don't expect malloc() to always return you a pointer even with your massive 1 gb of RAM.
mwha, I've never used malloc, one needs to brush up on ones c++, and howto sue new and delete statements.

Either way I have not looked directly at the itnerface you provided but those quotes show me it's looking very different, can you not attempt to add the current system whereas a command structure is sent off along with a unit id then we can define the command id and add whichever parameters we wish? I find ti would be a much more pwoerful tool than the likes of group.attack()
AF, malloc was just an example of a common error, which I bet I can find in your sources :wink: I'm not saying I don't make mistakes also, but it seems everyone around is focused on just building an AI that will be better then the other, while I'm just trying to something really stable, even if it can just move units around so far.
Also, I'll not make a unit.giveCommand( cmd, ... )
The problem with the current API, is it being complex, and undocumented. By creating a method for each avaiable command, with fixed and documented params, I think it'll have a much more nicer learning curve, then having to know how much params are required for each possible command.

@ Veylon

Well, let's clear this up. This is NOT a JAVA interface, rather an ECMAScript interface (aka Javascript). The overhead to run the whole Java VM would be a lot bigger then the ECMAScript VM. ECMAScript tho, was built so webpages could run simple "java" like scripts inside the browser. That's why it was friendly named Javascript instead of ECMAScript. And, as it progressed, it became more and more distant from Java.

@ b1ind

Yup, anything involving pointers can go bad... Either do strict checking, or use some lib that does it for you 8)
Not only that, for example, in Krogothe's current release of his class, there's a nice division by zero condition in the class :) And btw, I didn't fix it, so if this AI crashes, I can still blame him LOL (j/k Krog). But for now, don't use any maps that have MetalExtractorRadius = 0.
0 x

Post Reply

Return to “AI”