Help a developer work
full time on 0 A.D.!
Help us by donating on a regular basis!

Wildfire Games Community Forums: AI Scripting ? - Wildfire Games Community Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

AI Scripting ?

#1 User is offline   Penthouse 

  • Pip
  • Group: Community Members
  • Posts: 81
  • Joined: 19-September 03

Posted 07 July 2004 - 01:35 PM

Will there be the ability to write my own AI scripts? :D

#2 User is offline   Aeros 

  • Group: WFG Retired
  • Posts: 3,380
  • Joined: 21-September 03

Posted 07 July 2004 - 10:13 PM

in 0AD, yes :D If you're familiar with Javascript, scripting AI won't be a problem for you.
Bobby Ognyanov [aka CheeZy]

Wildfire Games Artist, Scenario Design Lead
Contact me bobby@wildfiregames.com

#3 User is offline   fyhuang 

  • Group: Community Members
  • Posts: 838
  • Joined: 07-July 04

Posted 07 July 2004 - 11:36 PM

Wait, why is 0 AD being scripted in Javascript? I always thought that Javascript was oriented towards web design stuff...
Fyhuang [ Blog | Site | Simulus Game Engine ]

#4 User is offline   Aeros 

  • Group: WFG Retired
  • Posts: 3,380
  • Joined: 21-September 03

Posted 08 July 2004 - 12:18 AM

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.
Bobby Ognyanov [aka CheeZy]

Wildfire Games Artist, Scenario Design Lead
Contact me bobby@wildfiregames.com

#5 User is offline   fyhuang 

  • Group: Community Members
  • Posts: 838
  • Joined: 07-July 04

Posted 08 July 2004 - 01:05 AM

Don't worry, I know what Java and Javascript are are how they're different.

I think that the choice is interesting :D. 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?
Fyhuang [ Blog | Site | Simulus Game Engine ]

#6 User is offline   Aeros 

  • Group: WFG Retired
  • Posts: 3,380
  • Joined: 21-September 03

Posted 08 July 2004 - 01:49 AM

Well, we didn't think of it either until someone suggested it in a meeting :D 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.
Bobby Ognyanov [aka CheeZy]

Wildfire Games Artist, Scenario Design Lead
Contact me bobby@wildfiregames.com

#7 User is offline   Zeusthor 

  • Group: WFG Retired
  • Posts: 469
  • Joined: 11-December 03

Posted 08 July 2004 - 02:28 AM

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 :D The language is better, but Lua was fastest. but believe me, Lua isn't something you'd want to code with :D.
Jeffrey Tavares [ aka Zeusthor ]

Wildfire Games 0AD Scripter
Contact me: jeffrey@wildfiregames.com

Support Wildfire Games!


#8 User is offline   Aeros 

  • Group: WFG Retired
  • Posts: 3,380
  • Joined: 21-September 03

Posted 08 July 2004 - 02:52 AM

I must've been reading something else then, Zeusthor :D
Bobby Ognyanov [aka CheeZy]

Wildfire Games Artist, Scenario Design Lead
Contact me bobby@wildfiregames.com

#9 User is offline   ZeZar 

  • Group: Community Members
  • Posts: 1,868
  • Joined: 22-September 03

Posted 08 July 2004 - 01:15 PM

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 :D

:P

hihihi, no, just kind of kidding, i hope you dont change :D Another question ... Could you use PHP ?
- Øyvind M.Tjøstheim
"How's my dri.... posting?" :)

#10 User is offline   Fire Giant 

  • Group: WFG Retired
  • Posts: 1,319
  • Joined: 27-April 03

Posted 08 July 2004 - 07:08 PM

ZeZar, on Jul 8 2004, 02:15 PM, said:

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.
Malte Schwarzkopf [aka Fire Giant]

Wildfire Games User Interface Designer and Artist
Contact me: malte@wildfiregames.com


Roma Victor Faction - Winter doesn't stop the Roman Legions...

Support Wildfire Games!

#11 User is offline   ZeZar 

  • Group: Community Members
  • Posts: 1,868
  • Joined: 22-September 03

Posted 08 July 2004 - 08:29 PM

heheh, oki. Was just wondering :D
Thanks Malte :D
- Øyvind M.Tjøstheim
"How's my dri.... posting?" :)

#12 User is offline   Mabuse 

  • Group: WFG Retired
  • Posts: 46
  • Joined: 06-July 04

Posted 03 August 2004 - 05:16 AM

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 bit

Or some Game-Stats, Tech-Tree`s and such stuff ?
(i know i could search for myself - :) , but i am so lazy... :D )

great work !!!

#13 User is offline   Aeros 

  • Group: WFG Retired
  • Posts: 3,380
  • Joined: 21-September 03

Posted 03 August 2004 - 05:19 AM

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.
Bobby Ognyanov [aka CheeZy]

Wildfire Games Artist, Scenario Design Lead
Contact me bobby@wildfiregames.com

#14 User is online   Wijitmaker 

  • Group: 0 A.D. Art Team
  • Posts: 9,231
  • Joined: 27-April 03

Posted 04 August 2004 - 07:32 AM

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. :)
Jason Bishop [ aka Wijitmaker ]

Wildfire Games CFO, retired artist
Contact me: jason@wildfiregames.com

Support Wildfire Games!!!

#15 User is offline   Tonto_Berrys66 

  • Group: WFG Retired
  • Posts: 33
  • Joined: 28-August 03

Posted 04 August 2004 - 09:16 AM

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 :-/
AI Scripters, the home of AI Scripting on the web.

#16 User is offline   DarkAngelBGE 

  • Group: WFG Retired
  • Posts: 7,686
  • Joined: 25-August 03

Posted 04 August 2004 - 03:15 PM

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. :D
Tim Koschuetzki [ aka DarkAngelBGE ]

Wildfire Games Community Administrator, Webmaster, Human Resources Manager
Contact me: tim@wildfiregames.com

My website: tim-koschuetzki.com

Recent work: PHP Design Patterns | PHP Coding Practices | Stop the Smoking! | My Services | My Blog

Support Wildfire Games!


#17 User is offline   Matei 

  • Group: WFG Retired
  • Posts: 1,754
  • Joined: 22-November 03

Posted 04 August 2004 - 04:50 PM

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.
Matei Zaharia

Wildfire Games Programmer
Contact me: matei@wildfiregames.com

Support Wildfire Games!

#18 User is offline   Ykkrosh 

  • Group: WFG Programming Team
  • Posts: 4,720
  • Joined: 31-May 04

Posted 04 August 2004 - 05:36 PM

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.
Philip Taylor [aka Ykkrosh]

Wildfire Games Programmer
Contact me: philip@wildfiregames.com

#19 User is offline   DarkAngelBGE 

  • Group: WFG Retired
  • Posts: 7,686
  • Joined: 25-August 03

Posted 04 August 2004 - 08:56 PM

Sounds cool, Matei. What type of game are you going to make? I think Philip very much answered your question?
Tim Koschuetzki [ aka DarkAngelBGE ]

Wildfire Games Community Administrator, Webmaster, Human Resources Manager
Contact me: tim@wildfiregames.com

My website: tim-koschuetzki.com

Recent work: PHP Design Patterns | PHP Coding Practices | Stop the Smoking! | My Services | My Blog

Support Wildfire Games!


#20 User is offline   Matei 

  • Group: WFG Retired
  • Posts: 1,754
  • Joined: 22-November 03

Posted 04 August 2004 - 09:17 PM

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 :).
Matei Zaharia

Wildfire Games Programmer
Contact me: matei@wildfiregames.com

Support Wildfire Games!

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users