💡 OPEN FEATURE: AI for NPCs

Eggheads talking about bytes and stuff.
Post Reply
User avatar
Krishty
Site Admin
Posts: 1364
Joined: 2022-Jan-09, 00:59

💡 OPEN FEATURE: AI for NPCs

Post by Krishty »

We need AI for other planes in the game. The airliners we currently have just follow waypoints; they are not AI-controlled (yet).

This is a pretty huge project, so I divide it into milestones:

1. Basic Flight Dynamics

Have NPCs not magically turn towards waypoints, but use flight physics to steer into the right direction. In the end, we should have behavior roughly like civilian planes in TAW’s Custom Combat: They fly towards a waypoint and circle when getting there, all via roll/pitch/yaw. Maybe they evade when being hit.

This requires a few preparations:
  • 💡 OPEN FEATURE: Flights
    If there is a takeaway from our TAW analysis, then it’s that flights should be the fundamental unit in mission planning. Handling a flight (with some kind of formation in it) is much easier than teaching individual planes to cooperate.
    Alas, we need to introduce flights before we can introduce mission planning. It’s okay if our flights support only one plane. Since flights are identified by callsigns, these should be introduced here, too. A hard-coded list of callsigns is sufficient.
     
  • 💡 OPEN FEATURE: Waypoints
    TFXplorer already has a very rough draft of waypoints for civilian traffic, but that’s not enough for AI. We need to introduce tasks at waypoints so that CAP flights circle around their waypoint instead of just moving on towards landing. It’s okay to only implement very simple tasks and skip the difficult ones like takeoff and landing.
     
  • 💡 OPEN FEATURE: Simple AI
    This should answer basic questions like “How hard should I bank to change my heading towards the next waypoint?” and “What’s the required angle of attack for maintaining this altitude?”. Sticked together, planes should be able to fly to specific places and circle around waypoints.
     
  • 💡 OPEN FEATURE: Radar
  • 💡 OPEN FEATURE: F-22: Other Planes on HUD/MFD
    We don’t want to watch other planes just via SmartView. We want to be able to see them from our F-22, too. So the API needs to be extended to provide planes with lists of other planes via a very basic radar simulation. The F-22 needs to render the other planes in the HUD and MFDs, possibly with the most important data like speed/altitude/heading.

2. Complex Flight Dynamics

Improve the AI to handle more difficult tasks, like takeoff/landing, intercepting targets, etc.
  • 💡 OPEN FEATURE: AI: Intercept Targets
    This is not only required for dogfighting, but it also lays the groundwork for things like air refuelling.
     
  • 💡 OPEN FEATURE: Extract TAW Airbase Graphs
    In order to take off and land, the AI must know where the runway is located. TAW seems to have a graph data structure to manage that. This graph is used for navigation and pathfinding on the airports, from hangars to the runway and vice versa. We need to decode the structure and make it available to the AI.
     
  • 💡 OPEN FEATURE: Extract Points of Interest from TAW Shapes
    In order to have TAW planes touch ground, we need to know where their wheels are located. TAW reads this information either from the supershapes or from the shape files. I suspect opcodes 0051 and 0086 to designate special places like pylons, engine exhausts, wheels.
     
  • 💡 OPEN FEATURE: AI: Waypoints for Takeoff/Landing
    This does not necessarily mean navigation along the airports. If you watch a plane start/land in TAW’s SmartView, you’ll notice that there is no singular state taking off or landing, but lots of states like lining up, accelerating, rotating, climbing, etc. The AI must be able to generate proper wayoints to trigger these stages. It’s enough to do this only for straight-in approaches.
     
  • 💡 OPEN FEATURE: AI: Takeoff/Landing
    Implement the actual AI behavior for lining up, accelerating, rotating, climbing, etc. Extend and retract the gear. When airborne, proceed to the next waypoint.

3. Flights

At this point, we can have a single plane take off, fly along a few waypoints, and land. The planes cannot fly in pairs, though. Neither can the player have wingmen.
  • 💡 OPEN FEATURE: Wingmen
    Extend the flight logic so there can be more than one plane in a flight. This introduces some design challenges, as “How does the code identify planes?” and “What do planes do when they lose a wingman, thus rendering a handle invalid?”
     
  • 💡 OPEN FEATURE: AI: Formations
    In order to prevent two planes from crashing into each other, introduce basic formations. (One formation is enough; the rest can follow later.) This will have an impact on flight dynamics.
     
  • 💡 OPEN FEATURE: AI: Takeoff/Landing with Wingmen
    Planes cannot take off / land at exactly the same time; they would crash into each other. Introduce basic logic to have them take off / land one after another.
     
  • 💡 OPEN FEATURE: Wingman numbering

4. Dogfights

We now have flights taking off from airports, moving along waypoints, and intercepting targets. This is enough groundwork for gameplay like ADF’s Quick Combat. We haven’t introduced weapons into the mix yet, and these need a roadmap themselves. Still, we could make other planes track the player and try to get on his six.

My intention is to do this while the topic is still “hot”. If I interrupt it for a year to implement weapons and explosions, and after that come back to do AI, then I’ll have to get into the topic again.
  • 💡 OPEN FEATURE: AI: Terrain Awareness
    Pilots should perceive the terrain around them. They should be able to navigate without crashing into it. TAW uses special data structures for that; we need to analyze that or come up with our own solution.
     
  • 💡 OPEN FEATURE: AI: Tactical Interception
    Flights should break up when encountering the player, to attack from two sides.
     
  • 💡 OPEN FEATURE: AI: Dogfighting
    Planes should be able to chase the player without crashing into terrain. (This will be fun in the Ace Combat levels with skyscrapers!) Wait, TAW is known for the AI crashing into the terrain when you’re low, so maybe it’s not important after all. But at least they should try.
     
  • 💡 OPEN FEATURE: AI: Evasion
    When chased by the player, planes should try to get him off their six. This does not just mean close dogfights, but also BVR tactics.
     
  • 💡 OPEN FEATURE: AI: Guns
    TFXplorer already has a pretty good gun simulation capable of different calibres, firing rates, etc. We could mount guns to AI planes to enable actual dogfights.

5. Coordination
  • 💡 OPEN FEATURE: Allegiances
    So far, all planes fight the player, which was neat for testing purposes. But we need a system to specify countries and fractions. The system must be dynamic so that a friendly country can become an enemy and vice versa (for the dynamic campaign). There must also be neutral countries. Ace Combat must be covered by the same system; maybe even more needs to be done for that.
     
  • 💡 OPEN FEATURE: Radio Transmissions
    We cannot have air traffic control or target assignment without this. This is a pretty huge chunk: We need to introduce frequencies. Buffers with messages. The time it takes to transmit a message depends on the transmission content. Content is created dynamically from WAV files. Do we have the TruSpeech codec? This should get its own roadmap … 🙁
     
  • 💡 OPEN FEATURE: AI: Airport Navigation
    This is actually a critical feature because we cannot have more than one flight taking off from an airport without it. Flights must find their hangars/aprons and stop if another plane is blocking them.
     
  • 💡 OPEN FEATURE: Air Traffic Control
    Should get its own roadmap, too 🙁 Likely requires us to implement other landing modes (go-round), too, or else flights will crash into each other circling exactly above the airport.

6. Generalization

We now have the most important AI abilities for a TAW clone. This AI, however, is only usable within our TAW extension – no way to use it in the EF2000 levels, or in the Ace Combat levels. Re-writing the entire AI for each of those from scratch is insanity, so I’d like to move as much as possible of the above from the DIDtoUAW F22 extension to the engine itself.
  • 💡 OPEN FEATURE: Generalized Waypoints
    Remember these special tasks in waypoints like accelerating, rotating, climbing? If we moved them to the core, we’d have a general waypoint system that could be used by all our extensions. This would allow to directly import missions from EF2000 and Ace Combat 3 later on.
     
  • 💡 OPEN FEATURE: Generalized Flight Dynamics
    TAW’s flight dynamics base upon very few values, such as engine power + cruising speed + wing area + g limit (and a few more). We could turn this into an interface and move the actual implementation to the engine core. Careful analysis is required to find out where to draw the line. We most likely need a way for extensions to override the default behavior in special cases.
     
  • 💡 OPEN FEATURE: Generalized AI
    We should try to move all AI to the engine core. Whether this is feasible depends on how many special cases the AI has, e.g. every if(plane == F22) could ruin it.

7. Finishing Up

At this point we should probably look into other important things (like weapons or ground units). But we all know that I do other things when I have a bad day, so here is all the stuff that didn’t seem important before:
  • 💡 OPEN FEATURE: Helicopter Physics
    TAW treats helicopters different from planes (of course). The flight physics are one place and …
     
  • 💡 OPEN FEATURE: Helicopter Takeoff/Landing
    … the different apron slots and different airport navigation is another.
     
  • 💡 OPEN FEATURE: AI: Air Refuelling
    Not the actual refuelling, just the ability to escort a tanker and get into the right place for refuelling.
     
  • 💡 OPEN FEATURE: EF2000 Planes
    With flight dynamics and AI in the core, bringing back EF2000’s planes is literally just providing a list of properties and shape indices (given that no other problems appear, like compatibility problems with our shape renderer). We could then fight EF2000’s enemies (but from an F-22, of course).
     
  • 💡 OPEN FEATURE: AI: Escort
  • 💡 OPEN FEATURE: AI: Search
mikew
Data Genius
Posts: 603
Joined: 2022-Jan-09, 20:21

Re: 💡 OPEN FEATURE: AI for NPCs

Post by mikew »

Great post!

Just commenting on 1. for now.
We already have plenty of callsigns in 'f22data/callsign.txt'
Can we use the existing .Xdl TAW format to set up flights?

TAW already has some concept of tasks/states and I think circling the waypoint would be 'patrolling'. Seems a good idea to keep these basic states as they can be handled separately and refined later.

For 'Radar', it's good to start with everything on the MFD, with as you say, being able to select a target and get its parameters.
Post Reply