Penthouse Posted July 7, 2004 Report Share Posted July 7, 2004 Will there be the ability to write my own AI scripts? Quote Link to comment Share on other sites More sharing options...
Aeros Posted July 7, 2004 Report Share Posted July 7, 2004 in 0AD, yes If you're familiar with Javascript, scripting AI won't be a problem for you. Quote Link to comment Share on other sites More sharing options...
fyhuang Posted July 7, 2004 Report Share Posted July 7, 2004 Wait, why is 0 AD being scripted in Javascript? I always thought that Javascript was oriented towards web design stuff... Quote Link to comment Share on other sites More sharing options...
Aeros Posted July 8, 2004 Report Share Posted July 8, 2004 No, it just so happens that it's used mostly for online stuff (make sure you're not confusing javascript with java, they're completely different things), though it's perfectly suitable for other things. We chose javascript because we believe that more people will be familiar with it, and most importantly it's a much more effecient and quicker (to process) language than Lua or Python, which were our other choices. Quote Link to comment Share on other sites More sharing options...
fyhuang Posted July 8, 2004 Report Share Posted July 8, 2004 Don't worry, I know what Java and Javascript are are how they're different.I think that the choice is interesting . JavaScript is faster? I wonder how many other people know that (or even think about using JavaScript)...Since Javascript is commonly used online, does that mean that you could have online 'demos' of upcoming mods/stuff? Quote Link to comment Share on other sites More sharing options...
Aeros Posted July 8, 2004 Report Share Posted July 8, 2004 Well, we didn't think of it either until someone suggested it in a meeting we ran some tests and it's 6 times faster than Lua or Python, and we definatly want a faster script language since ultimatly it'll result in faster loading times and more units on the map.Demos? Not sure what you mean by that, but later on we'll probably have some stuff on the site that talks about modding and gives examples on how to do things. Quote Link to comment Share on other sites More sharing options...
Zeusthor Posted July 8, 2004 Report Share Posted July 8, 2004 The javascript everyone knows and loves isn't what you will be using in 0ad. We will be using the Javascript language, but the functions you recognize like onload and such are web related and will not be in 0ad.And Javascript isn't faster The language is better, but Lua was fastest. but believe me, Lua isn't something you'd want to code with . Quote Link to comment Share on other sites More sharing options...
Aeros Posted July 8, 2004 Report Share Posted July 8, 2004 I must've been reading something else then, Zeusthor Quote Link to comment Share on other sites More sharing options...
ZeZar Posted July 8, 2004 Report Share Posted July 8, 2004 lol, hope you are not changing now ... do you have any idea how much time i spent looking for a JavaScripter? And yes, i finally got one ... and if you change language ... i will have to do it all again hihihi, no, just kind of kidding, i hope you dont change Another question ... Could you use PHP ? Quote Link to comment Share on other sites More sharing options...
Fire Giant Posted July 8, 2004 Report Share Posted July 8, 2004 Could you use PHP ? PHP is a server-side language that is being parsed by a webserver. I think it's absolutely unusable for any 0 A.D.-game-related things except from websites. People have been using PHP for linux scripts, though, but I don't believe it'd work well with a game.And due to the big differences between PHP and JS, no, they won't be compliant, so you won't be able to write any 0 A.D. script in PHP. Quote Link to comment Share on other sites More sharing options...
ZeZar Posted July 8, 2004 Report Share Posted July 8, 2004 heheh, oki. Was just wondering Thanks Malte Quote Link to comment Share on other sites More sharing options...
Mabuse Posted August 3, 2004 Report Share Posted August 3, 2004 Is there something that we AOK Scripters can play around with yet ?(or a small AI-Faq or something like that ?)I am sure at aiscripters.com would be alot people who would like to test and mess around a bitOr some Game-Stats, Tech-Tree`s and such stuff ?(i know i could search for myself - , but i am so lazy... )great work !!! Quote Link to comment Share on other sites More sharing options...
Aeros Posted August 3, 2004 Report Share Posted August 3, 2004 No, not yet. But towards beta stage we plan to put up some articles about all the modding, design, and scripting details possible in 0AD, and also introducing you to each section. Quote Link to comment Share on other sites More sharing options...
Wijitmaker Posted August 4, 2004 Report Share Posted August 4, 2004 Like CheeZy said, we would love to get the community more involved - but just aren't quite at that stage yet. We'll definately be looking towards aiscripters.com's direction when the time comes. Quote Link to comment Share on other sites More sharing options...
Tonto_Berrys66 Posted August 4, 2004 Report Share Posted August 4, 2004 Hi Guys, long time no see So ... if the scripting interface is essentially JavaScript ... isn't this likely to put AI scripting beyond the reach of the average-joe? I mean, you'll need to be a reasonably profficient programmer in order to create your own AI :-/ Quote Link to comment Share on other sites More sharing options...
DarkAngelBGE Posted August 4, 2004 Report Share Posted August 4, 2004 Ah, Berrys, good to see you again. Well, since I will be developing the computer player AI, I will make sure that the scripting system will be as close to AoK ones as the programmers allow.Instead of setting some variables, we may go the SN-mile, too, let's see. I will also write a top-notch manual on AI scripting in 0 A.D., so it won't be as hard as Javascript might suggest. Quote Link to comment Share on other sites More sharing options...
Matei Posted August 4, 2004 Report Share Posted August 4, 2004 Berrys, I think Javascript should be easy to understand, perhaps more so than the AoK scripting language. (I just figured out after learning Scheme in university that the AoK language is a variant of LISP). Look at a tutorial on Javascript for webpages for example. It's also very similar to PHP, C++, Java, C#, so anyone who's programmed before is likely to know it. I know many people who started programming with Javascript or PHP.DarkAngel, I have a question about how you're using the SpiderMonkey engine. I'm planning to use Javascript in a game I'm making in Java (Mozilla also provides a Java embedding of JS). However, I'm wondering how you can implement "blocking" functions in Javascript while keeping the game single-threaded. For example, in the AI code for a unit, you might have a function like fire() or walk(x, y) which you don't want to return until the unit has completed that anmiation. Same thing might be true in a complicated trigger effect. But I don't see how you can do this if all that a user-provided JS function does is call your implementation within the same thread. Have you gotten that far with the SpiderMonkey engine? If I can't find a solution, I'll probably be forced to create my own interpreter which keeps a queue of some sort of currently waiting scripts.One solution to my problem is to make things event-driven, so scripters can implement functions onFireComplete(), onWalkComplete(), etc. It seems very inconvenient to work with for the scripter though, for complex scripts. Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted August 4, 2004 Report Share Posted August 4, 2004 I think we're solving that by just not having any blocking operations. Most things are event-based -- e.g. using setTimeout(code, time) to execute a piece of code in some amount of time, rather than using sleep(time).Guessing wildly (someone please correct me if I'm wrong ) there won't even be a separate piece of script code that's executing for every unit -- a higher-level AI script will tell the unit to attack, and the unit is made to choose targets and attack them by the C++ engine. (But I wouldn't trust me to be correct about that).It's possible to use closures in JS to emulate something vaguely like coroutines (I think that's what they're called), as a kind of cooperative threading:function stuff(z) { Â var x = 0; Â alert("x = "+x); Â return function(){ Â var y = 1; Â alert("x = "+x+", y = "+y); Â return function(){ Â alert("x = "+x+", y = "+y+", z = "+z); Â }}} (where "return function(){" means "return now but let me be called again to continue from this point" -- a preprocessor could make it less ugly), then use it with something like var a = stuff(5); // says "x = 0"a=a(); // says "x = 0, y = 1"var b = stuff(10); // says "x = 0", as an independent 'thread'a=a(); // says "x = 0, y = 1, z = 5", accessing the original parameter to stuff()Have the engine code store the function-object-thing that's returned, and execute it again when the blocking operation has finished, and that should vaguely work.Alternatively, SpiderMonkey supports multiple 'contexts' which might be a simpler solution to the problem, but I don't know much about them or whether they could do what you want. Quote Link to comment Share on other sites More sharing options...
DarkAngelBGE Posted August 4, 2004 Report Share Posted August 4, 2004 Sounds cool, Matei. What type of game are you going to make? I think Philip very much answered your question? Quote Link to comment Share on other sites More sharing options...
Matei Posted August 4, 2004 Report Share Posted August 4, 2004 Yes, he did. I'll probably do what he suggested, passing a "what to call next" function and an argument to the wait functions. Then I can just have a priority queue of currently waiting scripts. This should be easier to work with than general event handlers which would have to check what the object was last trying to do and then respond appropriately.I actually just sent you a private message about the game . Quote Link to comment Share on other sites More sharing options...
fyhuang Posted August 4, 2004 Report Share Posted August 4, 2004 Well, AI scripting wasn't the easiest thing to begin with. And with the addition of a logical Host API, there shouldn't be much of a problem. When the mundane details of how to get units to move is gone, the pure AI becomes much easier. Quote Link to comment Share on other sites More sharing options...
Dr Who Posted August 11, 2004 Report Share Posted August 11, 2004 Berrys, I think Javascript should be easy to understand, perhaps more so than the AoK scripting language. You must be joking, the AOK method was so easy, it used very easy and logical facts.Example:(unit-type-count villager < villager_dark)when someone reads this, they understand it immediately (note: i used a defconst in this fact).If you're going to use parameters in forms of single-letters or small letters, then there will be confusion in the scripters mind, not to mention the time it will take to learn it.I've seen my brother using JS, PHP and other methods and I can say that there are more symbols to be learned using these scripts. Quote Link to comment Share on other sites More sharing options...
Petsuchos Ra Posted March 11, 2005 Report Share Posted March 11, 2005 Can we have a 'forward-building-type-count <building>' fact? That is annoying in AOK. Quote Link to comment Share on other sites More sharing options...
Mabuse Posted July 8, 2005 Report Share Posted July 8, 2005 I guess if you are able to count Buildings of a certain Type within a certain Area - it is ok and easy to handle.No need to define what "forward" is and so on - Quote Link to comment Share on other sites More sharing options...
Blorx2 Posted July 8, 2005 Report Share Posted July 8, 2005 Cool, I'd like to see this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.