AI Systems: Difference between revisions

Jump to navigation Jump to search
m
(Some cleanup, but needs some more work.)
Line 24: Line 24:


== AI Models ==
== AI Models ==
Starting with FlightGear version 0.9.4 you can place AI objects in the "FlightGear world". In version 0.9.4 the AI objects can be defined in the preferences.xml file, or in an [[aircraft-set.xml]] file. In later versions they are defined in a "scenario file" only. The types of AI objects you can have are airplanes, ships, thunderstorms, thermals/sinks, static and ballistic objects. AI objects have some things in common: The have a location in the "FlightGear world", they can have an associated exterior 3D model, and they can move according to an internal [[Flight Dynamics Model|FDM]] (flight dynamics model). As of now, these objects are created at simulator start-up by adding some XML code to a scenario file. The scenario file must be in the data/AI directory. You select which scenario files you want to use by naming it in the preferences.xml file. The preferences.xml file has an entry that looks like this (in FlightGear versions newer than 0.9.4, including [[Git]]):  
Starting with FlightGear version 0.9.4 you can place AI objects in the "FlightGear world". They are defined in a "scenario" XML file. The scenario file must be in the "data/AI" directory. There are several different types of AI objects.
=== Types of AI Objects ===
* aircraft
* ship
* thunderstorm
* thermal
* ballistic
* static
* wingmen
AI objects have some things in common:  
* The have a location in the "FlightGear world"
* They can have an associated exterior 3D model
* They can move according to an internal [[Flight Dynamics Model|FDM]] (flight dynamics model).  
 
=== Selecting Scenarios ===
In order to use AI objects it is necessary to load one or more scenario files. There are several ways to select scenarios.
* set it in preferences.xml file
* use commandline parameters
* load/unload through AI menu at runtime
 
==== Set Scenarios in preferences.xml file ====
The preferences.xml file has an entry that looks like this:  
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<ai>
<ai>
   <enabled type="bool">true</enabled>
   <enabled type="bool">true</enabled>
  <scenarios-enabled type="bool" userarchive="y">true</scenarios-enabled>
   <scenario>aircraft_demo</scenario>
   <scenario>aircraft_demo</scenario>
</ai>
</ai>
Line 34: Line 58:
The above bit of XML enables the AI system and selects a scenario file called aircraft_demo.xml.
The above bit of XML enables the AI system and selects a scenario file called aircraft_demo.xml.


Notes:  
==== Load Scenarios with command line parameters ====
* XML tags are case-sensitive.
It is possible to load scenarios with commandline parameters.
* Introducing certain characters into the XML file, even as part of a comment, will cause the file to choke. These include &, <, and --.
 
e.g.: --ai-scenario=aircraft_demo
 
The value of the --ai-scenario parameter is the filename of the scenario xml file in "data/AI" directory.
If necessary the --ai-scenario parameter can be repeated to load multiple scenarios.
 
==== Load Scenarios at runtime ====
In newer FG versions it is also possible to load/unload scenarios at runtime with the menu entry "AI/Traffic and Scenario Settings".


=== Scenario File definition ===
The scenario file contains one entry for each AI object. The entry specifies what kind of object to create, what its initial conditions will be, and optionally (for aircraft and ships) a flight plan. The entry for a sailboat could look like this:
The scenario file contains one entry for each AI object. The entry specifies what kind of object to create, what its initial conditions will be, and optionally (for aircraft and ships) a flight plan. The entry for a sailboat could look like this:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
Line 51: Line 83:
</syntaxhighlight>
</syntaxhighlight>


Most of the parameters are self-explanatory. The "type" of object can be one of "aircraft", "ship", "carrier", "thunderstorm", "thermal", "ballistic" or "static". The rest of the items give the AI object a model, a starting location, and a starting speed and direction. You use the <model> item to give the object any valid exterior model. You can even make the ship look like an airplane if you want! Note that the speed of the AI object is true airspeed, and since AI aircraft and ships don't feel wind or current then this also the ground speed. The "ship" type can also have a <rudder> value specified, which will cause the ship to move in a circle ({{itip|Use small values, five degrees or less, and right rudder is positive}}). Here is an example of how to create an aircraft AI object:
Notes:
* XML tags are case-sensitive.
* Introducing certain characters into the XML file, even as part of a comment, will cause the file to choke.  These include &, <, and --.
 
Most of the parameters are self-explanatory. The "type" of object can be one of "aircraft", "ship", "carrier", "thunderstorm", "thermal", "ballistic", "static" and "wingman". The rest of the items give the AI object a model, a starting location, and a starting speed and direction. You use the <model> item to give the object any valid exterior model. You can even make the ship look like an airplane if you want! Note that the speed of the AI object is true airspeed, and since AI aircraft and ships don't feel wind or current then this also the ground speed. The "ship" type can also have a <rudder> value specified, which will cause the ship to move in a circle ({{itip|Use small values, five degrees or less, and right rudder is positive}}). Here is an example of how to create an aircraft AI object:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<!-- puts an A-4 north of KSFO, orbiting at 7000 ft -->   
<!-- puts an A-4 north of KSFO, orbiting at 7000 ft -->   
546

edits

Navigation menu