Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[2.2]Programmable AI via scripting
#51
Manythanks for the _type :3
My Creations: (Click to View)

Return (String) System.getNewsOfTheDay();
Barely active, expect slow responses. If at all.


Greetz,
Alblaka
Reply
Thanks given by:
#52
self and target are global (yay!), but left(), left(1, 0), left(1) etc. don't work.
i've tried finding what the problem is, but can't seem to get anything going:
    CHAI_V1_2-Code:
clr();
print("left_arity: ${left.get_arity()}");
var params = left.get_param_types();
print("size: ${params.size()}");
for (var i = 0; i < params.size(); ++i) {
	print("i: ${i}");
	var param = params[i].cpp_name();
	print("param: ${param}");
}
 
var fs = left.get_contained_functions();
print("fs.size() : ${fs.size()}");
var f0 = fs[0];
var f1 = fs[1];
print("f0_arity: ${f0.get_arity()}");
print("f1_arity: ${f1.get_arity()}");


    OUTPUT-Code:
left_arity: -1
size: 1
i: 0
param: class chaiscript::Boxed_Value
fs.size() : 2
f0_arity: 1
f1_arity: 2


don't know if that's much help.
f0(); f0(0); don't work.



Azriel~
Reply
Thanks given by:
#53
Just wanted to give a heads up, on the porting to AngelScript:
It is going rather well, but my computer crashed, and I'm unable to retrieve the data for now.
Will be delayed sadly :(
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by:
#54
Time for an update:
Presenting version 2.0:

Change log (Click to View)
Download: http://www.mediafire.com/?pxd026nqoqgw0
Release, is the version you should use, when you actually play the game. Debug is for when you are writing your code.

The source code is available too. You'll need Visual C++ Express 2010, directX SDK 2007 and AngelScript 2.23.1.
Depending on where you install them you might have to change some of the paths in the project.
AngelScript should be compiled with the same code generation options as the DLL.
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by:
#55
Can anyone explain the two parameters for the key-press functions at some point?
My Creations: (Click to View)

Return (String) System.getNewsOfTheDay();
Barely active, expect slow responses. If at all.


Greetz,
Alblaka
Reply
Thanks given by:
#56
(06-30-2012, 01:49 PM)Alblaka Wrote:  Can anyone explain the two parameters for the key-press functions at some point?

What I do is; try all possible combinations until it works like I want it too :p. Before we had the two inputs and only had A() and stuff, it was doing A(1,0). Then in the basic AI method it'd reset inputs to 0,0 for all the things, and then the method would be called again. Right now since we support rewriting basic ai, we need to allow people to set A(0,0) by them selves. So at the top of all id() (when you are overwriting basic AI) stuff you'd most likely have

Code:
    // reset all inputs
    left(0,0);
    right(0,0);
    J(0,0);
    up(0,0);
    down(0,0);
    A(0,0);
    D(0,0);

If you are using ego() (which was is what we had previously), you only need to worry about left and right so that walking is possible. I think left(1,1) is walking.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by: Alblaka
#57
Minor update: 2.1
Added stage_bound and stage_clear global variables.
Download: http://www.mediafire.com/?pxd026nqoqgw0
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by:
#58
(06-08-2012, 06:31 PM)Lord Silva Wrote:  
Quote:quick steps:
1. put the dll in the lf2 folder (i.e. /lf2/ddraw.dll). done
2. make a folder "ai" in the lf2 folder (i.e. /lf2/ai) done
3. in this ai folder, any [id].as files ([id] being the id of ur char) will be used as an ai script for ur char, so you'll have 13.as for an id 13: char. done
4. start coding. error

I dont know why it isn't happening:(
New Deep acts just like a template.
My lf2 version is 2.0a
HELP!

this is what i've added to data.txt:
id: 400 type: 0 file: data\deep.dat

in ai folder this is the ai file:
[Image: 9sq77s.png]

and this is what there is inside file:

EDIT:
VV That worked!
[Image: llqsMqz.jpg][Image: llqsMqz.jpg][Image: llqsMqz.jpg][Image: llqsMqz.jpg]
Reply
Thanks given by:
#59
(07-05-2012, 10:33 AM)xmfcx Wrote:  HELP!

the syntax is a little stricter now that's why the old code won't work
i have not fully grasped all the changes myself
but this version of the code you are trying works:
Code:
int ego(){
if(target.D==true){D();}
if(target.up==true){down();}
if(target.down==true){up();}
if(target.left==true&&self.state>2){right();}
else if(target.right==true&&self.state>2){left();}
else if(target.state==2&&target.facing==true){right();}
else if(target.state==2){left();}
else if(self.facing==false&&self.state==2){left();}
else if(self.state==2){right();}
if(target.facing==self.facing){
if(self.facing==true){right(1,0);}
else{left(1,0);}
}
if(target.J==true){J();}
if(target.A==true){A();}
if(target.DJA==3){DJA();}
else if(target.DuJ==3){DuJ();}
else if(target.DdJ==3){DdJ();}
else if(target.DlJ==3){DrJ();}
else if(target.DrJ==3){DlJ();}
else if(target.DuA==3){DuA();}
else if(target.DdA==3){DdA();}
else if(target.DlA==3){DrA();}
else if(target.DrA==3){DlA();}
return 1;
}

the most pressing changes are the introduction of the int ego() function and the void id() function
if you just want to add special moves and leave the basic AI intact then you will need to put your code into the ego function the way i did up there - however this mirroring script would be a better fit for the id function (basic AI - nothing but your code gets executed)
also you will always need ; after any command
and variable types are extremely strict - that's why i had to compare all the boolean ones (0 or 1) with true or false now

quite difficult compared to chai but hopefully i can update my tutorial for easy comprehension (after all this stuff still recompiles at run time so the better performance and new features really make up for the strict syntax)
Reply
Thanks given by: mfc
#60
There is no need to compare things to be true.

if(target.D==true)

is the same as:

if(target.D)

if you want to see if it's not true then you can use:

if(!target.D)
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)