AI

**Artificial Intelligence** can be used to make vehicles and structures fully autonomous.

* AI Mainframe - essential core component

Consider: you've made a huge battleship. With cannons. And missiles. And torpedoes. And decoys. And flares. And stuff. But in testing you realise that manually operating all these systems is next to impossible; there's just too much stuff on your ship. Wouldn't it be nice if the flares just... fired themselves?

Or consider: After making the tour of the nearby island, and sinking your first few ships, you may want to add a second one. But who is going to pilot that? Quite the conundrum, isn't it?

The solution is Automation, and there are five ways to accomplish it in the game:

* The Control Block, great for automating a simple task, like raising shields when an enemy is around. Found in the 'Control' tab.
* The AI Mainframe, found in the 'AI' tab. Simply put, it's an autopilot, and a fairly smart one at that, able to perform bombing runs, ramming attacks, hovering at a set distance from a target, and so on. It's also got the ability to read the world's heightmap, and will ideally (but sadly not always) stop itself from running aground (or crashing into a mountain).
* The non-AI Breadboard.
* The AI Breadboard, which can be used to modify the maneuvering behavior of AI Mainframes.
* The Lua Box, which can be used to run custom missile guidance programs, amongst other things.

## Mainframe AI

The Mainframe AI in From the Depths can do just about everything you can with a vehicle. It can read the world's heightmap and steer clear of areas that are too shallow or too mountainous to be passable, and it can recieve target data from Detection systems, allowing it to position itself relative to the target, and perform basic evasive maneuvers if the detection systems sense incoming fire.

### Basics

The absolute minimum you need is AI Mainframe block. This is the core of anything smart. If you manage to destroy the AI core of an enemy ship, you can board and claim the ship. Or you can board first and hunt for the core second. A core on its own doesn't do much, it needs processing cards and links to the weapons, and also some detection systems if you want it to be able to find targets on its own. You can place the core anywhere you like.

Adding cards is done by attaching a couple of card slots and placing cards next to them.

### Parts

* AI Mainframe
* AI Card Slot
	+ (CARD) Naval AI
	+ (CARD) sailing
	+ (CARD) Aerial AI
	+ (CARD) water start
	+ (CARD) target prioritisation
	+ (CARD) Aim point selection
	+ (CARD) Fortress AI
	+ (CARD) Propulsion Balancing
	+ (CARD) Land AI
* Connector
* General Purpose Processing Card
* Wireless Transmitter
	+ Wireless Receiver
* Local Weapon Controller
	+ Anti Missile Cannon Controller
	+ Failsafe
* Enemy Simulator
* Flag post
* PID
* Intra Vehicle Transmitter
* Munition Warner
* Laser Warner
	+ Smoke dispenser

## AI Behaviors

Behaviors are how a mainframe will try to position itself relative to its target.

* Attack run with flyover - Overflies the target. Useful for bombers.
* Attack run with U-turn - Charges the target, then turns and runs away.
* Broadside 1 -
* Broadside 2 -
* Circle - Will try to circle around the target at a set range.
* Hover above/below - Unit will try to hover above or below the target. Useful for airships and melee submarines.
* Point at - Hovers at a set distance with the front facing the target.
* Ram -
* Resource gathering - Tries to stay in the center of the nearest resource zone.

## Adjustments

Movement requests (in the form of waypoints) from the active Behavior are passed through here before being carried out by the Manoeuvre mode.

### **Vehicle type**

* New waypoints will be rejected if they are in the wrong environment. Ships will refuse to go on land, land units will refuse to become airborne, and aircraft will refuse to fly underwater.
* You can also go a bit nuts and build a tank that drives around on the seafloor or something, using the "Unset" option.

### **Collision avoidance**

* Tries to avoid colliding with other vehicles (or just friendly ones). Can also be set to not care at all.

### **Altitude Clamping**

* Sets minimum altitudes above land and water (useful for aircraft and airships, but also for making sure that submarines don't hit the seafloor.
* The max altitude setting is mostly for making sure that a construct doesn't get itself stuck in a loop trying to reach a waypoint that's too high up.

### **Surface pathfinding**

* Keeps a ship from navigating between two on-water waypoints using an on-land path, and vice versa for land vehicles.

### **Extra options**

* Terrain height prediction lets the unit predict the terrain height of wherever it's about to be, and preemptively adjust its altitude before it gets there, to avoid violating the "minimum altitude above land" setting.

## AI Manoeuvre modes

The Maneouvre mode is what the AI Mainframe thinks the unit is. For example, if the Mainframe thinks the unit is an aircraft, it will try to fly the unit like an aircraft. If it thinks the unit is a ship, it will try to drive it around like a ship. Buildings, being fixed in place, naturally cannot use these.

* Airplane 1 -
* Airplane 2 - More complex airplane control laws.
* Empty - Placeholder to stop the AI mainframe from interfering with the control inputs from an AI Breadboard.
* Fortress - Unit is a fortress (fortresses can move in all six directions, and yaw, but cannot pitch or roll).
* Hover - Unit can hover at a set altitude, and also has forwards and backwards propulsion.
* Ship or Tank - Unit
* Six axis - Unit can move in all of the cardinal directions.

## Additional Routines

Auxiliary behaviors such as performing evasive maneuvers if a projectile is detected nearby, or deploying flotation aids when crashed in the water. Also included are some behaviors that can control rigging and spinblock-mounted masts to keep wind in the sails on sail-propelled vessels.

## PIDs

PID dampening can smoothen out oscillations in movement. For example, the basic Ship/tank manoeuvre mode tends to "slam" the rudders left and right, resulting in an inefficient tail-wagging movement. basic PID dampening smoothens out the rudder movements by predicting what the situation will look like in the future, and then compensating for it until the future predicted situation aligns with the desired outcome.