Status of AI in FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 115: Line 115:
     |author=<nowiki>Hooray</nowiki>
     |author=<nowiki>Hooray</nowiki>
     |date=<nowiki>Sun May 05</nowiki>
     |date=<nowiki>Sun May 05</nowiki>
  }}
}}
== Learning AI ==
{{FGCquote
  |most everything is possible here.<br/>
<br/>
Just a little damper, Bombable is not really supported and imho wasn't conceived with software architecture in mind. I think it would be better to think on a robust and modular AI implementation so any other existing or future piece could use it without requiring Bombable. This doesn't say that Bombable couldn't use it.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=161203&sid=cdbcaaa2eec329e95718082e84d7a04d#p161203
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>xiii</nowiki>
    |date=<nowiki>Fri Jul 06</nowiki>
  }}
}}
{{FGCquote
  |It is certainly possible (like xiii said already), however it will require a solid background in AI and coding. It could definitely be implemented without touching any C++ though (i.e. using scripted Nasal code).<br/>
I am disagreeing a little with xiii regarding the feasibility of using the bombability package for this, it's actually pretty well-written and well-commented source code. However, it is obviously a huge and complex piece of software. Just understanding how everything works, will take weeks or even months. <br/>
In other words, it might be simpler to start out with something standalone - i.e. based on the tanker.nas example, so that you could first create an AI bot using NN which controls the tanker (or some other aircraft) and then consider integrating this with the bombable package later on.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=161383&sid=cdbcaaa2eec329e95718082e84d7a04d#p161383
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sun Jul 08</nowiki>
  }}
}}
{{FGCquote
  |Bombable is definitely large &amp; complex and though I'm interested in continuing to develop it I am also very limited in my spare time available right now.<br/>
<br/>
Flip side is, it could written (in fact probably SHOULD be written) as a completely stand alone module that just reads the location &amp; other info from the property tree for the main AC and the AI AC of interest, and gets the general geographical and other information it needs to navigate the through the regular FG functions and the property tree variables for that sort of thing.  <br/>
<br/>
Then you could develop some kind of API type thing to communicate with Bombable where the AI pilot module puts the current piloting info into the property tree (or just a nasal data structure, probably better for speed), including info like:<br/>
<br/>
* which direction/how much to turn/turn rate<br/>
* which direction/how much to climb or dive/climb or dive rate<br/>
* whether to speed up, slow down and by how much, and rate<br/>
* Also right now Bombable implements loops as a special/separate routine - but they are easy enough to trigger with the same API type of approach, just send the data along via the API to say 'start loop' and a few parameters to define what the loop will do.<br/>
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=163315&sid=cdbcaaa2eec329e95718082e84d7a04d#p163315
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>flug</nowiki>
    |date=<nowiki>Thu Aug 02</nowiki>
  }}
}}
{{FGCquote
  |Bombable could then read these nasal variables and/or the property tree or however the module-to-module communications API is worked out, and take the appropriate action.  <br/>
<br/>
This would be pretty simple to implement just because Bombable is already doing something very similar to this, but it uses its own internal logic to make those decisions about turning, climbing, diving, looping, etc.  It could just as easily take those cues from an outside module.<br/>
<br/>
The only other things that Bombable is currently using for AI aircraft decision-making are (1) weapons hits and near hits on the AI/AC, (2) overall AI/AC damage level, and (3) in the last version I implemented some code to simulate the AI/AC's fuel situation  (with good fuel reserves the AC will attack aggressively, when fuel gets low it turns tail and slows down to conserve fuel).  Those things could easily be implemented via the AI module as well, with info passed back &amp; forth via the property tree or a nasal data structure.  There are only a few simple parameters for all of those items.<br/>
<br/>
So--I think this *could* be done with Bombable as a completely separate module that only interfaces with Bombable via an API type interface and furthermore, the API would be pretty simple.  I think.  (Famous last words, I know!)
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=163315&sid=cdbcaaa2eec329e95718082e84d7a04d#p163315
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>flug</nowiki>
    |date=<nowiki>Thu Aug 02</nowiki>
  }}
}}
{{FGCquote
  |The other flip side is, even if this is the long term plan it might still be smarter to start by implementing this same kind of an AI system (including the idea of an API-type interface that would allow the new AI piloting module to get needed info from other modules as needed and transmit the piloting instructions back to another different module that would do the actual piloting) but choosing a much simpler task for the first project.<br/>
<br/>
Then once the basic ideas have been worked out and are functional, tackle the much more complicated project of making a convincing AI fighter pilot module--which, really when you think about it, is what is needed for Bombable.<br/>
<br/>
Making an complete, realistic AI fighter pilot module is a pretty daunting project, really!  The only thing that makes me think it is even possible at all is that the current Bombable pilot AI really only has a very, very few basic behaviors (attack in certain situations, evade in certain situations, do a loop in certain situations, retreat in certain situations--that's about it) and it really works much better than I ever imagined it would, given that absolute simplicity and complete unsophisticated-ness of the AI pilot model it's using.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=163316&sid=cdbcaaa2eec329e95718082e84d7a04d#p163316
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>flug</nowiki>
    |date=<nowiki>Thu Aug 02</nowiki>
  }}
}}
{{FGCquote
  |we should probably consider this a long-term goal, and then it would make sense to extract the AI control code from bombable into some separate "ai.nas" module, i.e. splitting up bombable into separate files. <br/>
<br/>
So that some of these could eventually be moved to the Nasal standard library directory in $FG_ROOT/Nasal, this is where we could then have a separate "ai.nas" module that allows controlling AI objects via the property tree. And another "pilot.nas" module which uses the ai.nas module.<br/>
<br/>
It should definitely be simpler to do this with some standalone aircraft, or maybe just the tanker.nas module. So that we could tackle this task separately, reuse as much of the bombable code as possible, and re-integrate the results later on via some sort of API, like you say.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=163343&sid=cdbcaaa2eec329e95718082e84d7a04d#p163343
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Aug 02</nowiki>
  }}
}}
{{FGCquote
  |Custom "pilot" implementations could then be provided for different purposes, i.e. by reimplementing an abstract "pilot" base class and overriding functionality as required.<br/>
<br/>
Currently, the major showstopper is probably the complexity of the whole system, and having to understand it in its entirety, if bombable could be split up into separate modules, that should be made easier - also, adding the bombable package as a Nasal subsystem (sub module) to the base package should be easier then.<br/>
<br/>
Also it's worth mentioning that there have been discussions on exposing the autopilot/route manager system and the FDM system to Nasal space via the property tree and/or new Nasal extension functions, that could also help to make some old code obsolete, i.e. because a real autopilot or FDM could be used for scripted AI traffic eventually.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=163343&sid=cdbcaaa2eec329e95718082e84d7a04d#p163343
    |title=<nowiki>Re: Possibility of incorporating "learning" AI?</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Aug 02</nowiki>
   }}
   }}
}}
}}

Navigation menu