Status of AI in FlightGear

From FlightGear wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

AI Scenarios vs. Scripting

Cquote1.png I have the feeling they're a bit of a legacy feature. The AI system is pretty limited in what you can do, so AI gets replaced by more versatile Nasal solutions.


Compare tanker.nas with the AI aerial refueling demos - you can call the Nasal-spawned tanker everywhere when you're out of fuel, it interactively can provide you instructions to reach it, it automatically selects the tanker apprpriate for what you're flying,...

Compare the thermal demo with Advanced Weather - the AI thermals are on pre-defined locations, so there's just zero element of surprise in glider flight, you have to do a lot of preparation up-front in order to get gliding in a different location - Advanced Weather just generates them anywhere in the world, merged right into the other weather patterns,...

Nasal in static models makes them interact with aircraft, no need to pre-define AI or pre-load anything.

So if not for the Carriers, I think we could safely get rid of the AI scenarios - Nasal-driven Wingmen would be far superior in interactivity.


— Thorsten (Fri Feb 08). Re: AI-Scenarios.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I have to agree completely with Thorsten here. Scripting via Nasal makes it possible to move development of such features to the base package and delegate it to "user space" (contributors not core developers).


So that core developers can focus on writing C++ core. Just look at examples like tanker.nas, fox2.nas, [url]Curt's fully autonomous f14 demo[/url] or flug's bombable addon: They all use Durk's AI traffic system as their backbone and foundation, but they provide totally different and novel features on top of it.
In fact, there has so much more "AI" development taken place, just because the AI traffic system has become scriptable through the property tree.

Using Nasal, it would be possible to create AI traffic that responds to ATC instructions, and even ATC controllers that control simulated and AI traffic
So there's tons of flexibility here without C++ developers and their spare time being the bottleneck


— Hooray (Fri Feb 08). Re: AI-Scenarios.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png The AI system itself is not all that flexible, but the various scripted approaches (tanker.nas, bombable etc) do use it as the backend for placing traffic, even though all the control logic is then handled in scripting space.
Cquote2.png
Cquote1.png the code to do this is already readily available in FlightGear.

$FG_ROOT/tanker.nas is a good demonstration for code that iterates over the AI properties.
Another good example is the multiplayer pilot list, which also iterates over the property tree.
You only need to combine snippets from these two files to come up with what you need.


— Hooray (Mon Nov 29). Re: Working with AI/Multiplayer properties.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png the most flexible approach would be using scripting - FligthGear has a built-in scripting language (called "Nasal"), that can be used to control aircraft, and even to instantiate multiple AI aircraft, one of the most straightforward examples is the "tanker.nas" script, which creates a fully scripted AI tanker - that could be easily extended to create dozens of tankers, and obviously you could also change the 3D model if you wanted to. In fact, we have a separate addon, named "bombable" that adds "AI bots" to the simulator, for dogfighting purposes - none of that required C++ changes, it's all done in scripting space. Another users implemented a fully scripted missile (fox2.nas) that tracks aircraft - and we also have a feature for "wingman" support, too.


Actually, you could even create scripted AI pilots and scripted AI ATC that interact with eachother - it's all doable, and doesn't require rebuilding FlightGear from source.


Cquote2.png

Scripted AI in FlightGear

Cquote1.png Another example is the "tanker.nas" script in $FG_ROOT which implements a simple scripted AI tanker for AAR purposes: search.php?st=0&sk=t&sd=d&sr=posts&keywords=tanker.nas

http://www.mail-archive.com/search?q=ta ... eforge.net

And then we have the fox2.nas script which implements a fox2 AI missile using Nasal: search.php?st=0&sk=t&sd=d&sr=posts&keywords=fox2.nas

The "bombable" addon is completely implemented in Nasal and created multiple virtual pilots for dogfighting purposes: Bombable

<iframe width="420" height="315" src="http://www.youtube.com/embed/LL7bdHrR8uI" frameborder="0" allowfullscreen=""></iframe>

Cquote2.png
Cquote1.png he simplest solution is probably using scripted AI traffic nodes. Note however that AI traffic cannot currently make use of any FDMs (JSBSim/YaSim), instead you need to come up with your own "pseudo FDM" in scripting space.


You might be able to circumvent this restriction by coming up with a separate FDM and communicating with FG using sockets.

We have a number of more or less complex examples for this. $FG_ROOT/Nasal/tanker.nas is the simplest test case you'll find, which basically spawns an "AI tanker" that can be used for refueling purposes. It would be possible to generalize the script some more in order to spawn an arbitrary number of aircraft. Also, you could equip them with a scripted control loop, so that each node can be controlled individually, i.e. by either setting a bunch of properties, or even by issuing ATC instructions.

Curt has recently provided a more complex example.
The most complex example for this technique is certainly the "bombable addon" which implements "AI bots" entirely in scripting space to provide "dog fighting" support.

I would suggest to search the archives (wiki, forum, mailing list) and look into the aforementioned examples.

Also, you'll inevitably need to look into the Nasal documentation, too: Nasal_scripting_language


— Hooray (Tue Jan 03). Re: Multiple intelligent flyers.
(powered by Instant-Cquotes)
Cquote2.png

Scripted AI Missiles

Cquote1.png xiii is the developer of the F14b's fox2 implementation, the original thread was: Subject: Missiles with seeking capabilities.


To find related threads, see:
search.php?st=0&sk=t&sd=d&sr=posts&keywords=fox2.nas

Subject: Custom dialog, nasal console etc. to fire a missile?

<iframe width="420" height="315" src="http://www.youtube.com/embed/UL7jQkl1qe4" frameborder="0" allowfullscreen=""></iframe>

— Hooray (Sun May 05). Re: F-14B's Weapon System  .
(powered by Instant-Cquotes)
Cquote2.png

Fully Automatized Missions

Cquote1.png Yes, it is possible "to make" such a mission - but you will literally have to MAKE it by writing a script to outline all required steps for your aircraft.

Curt did that a while back for the f14b, which did a fully automated carrier approach using just Nasal scripting:

http://diydrones.com/profiles/blogs/uas ... simulation
http://www.mail-archive.com/flightgear- ... 33987.html
http://www.flightgear.org/forums/viewto ... =4&t=13615

<iframe width="420" height="315" src="http://www.youtube.com/embed/cvbtSG9cy20" frameborder="0" allowfullscreen=""></iframe>

Cquote2.png