## Purpose:

Provide a means of control of the movements, actions and attacks for non-human opponent ships for the X-Wing Miniatures Game, using FFG's 2nd Edition ruleset and a simplified "artificial intelligence" generated by the x-wing-ai.com app. This will allow one or more human player(s) to play against a non-human opponent. This works on the physical tabletop as well as in conjunction with other programs such as Tabletop Simulator.
While this app was made for use with X-Wing: The Miniatures Game 2nd Edition Ruleset, it will work using "2.5 Edition" rules, though the AI movements will not take into account any scenario objectives. To help with this, you might consider using the "Not-Quite-As-Stupid AI Pilot" Rule (see below).

## Setup:

Setup your game per standard 2nd Edition/2.5 Edition rules, choosing any squadrons and/or missions.

## Usage Overview:

### The Hotlist

XWing AI now contains a user Hotlist in 2/2.5Ed and HotAC/FGA Pages. You can select any number of ships to put in the hotlist, irrespective of their factions.
To use the Hotlist, go to any faction list and select any ship. Double-click or long-press (for touch devices) on the large ship icon in the center of the Target location picture and the ship will be added to the Hotlist. A short message will appear for ~2 seconds to inform you that the ship has been saved to your hotlist. To view your Hotlist, click on the Hotlist "Sun" Icon in the Factions area, and the Hotlist will display the ship(s) you selected. This is a convenience so you don't have to keep going from Faction to Faction searching for your AI ships - they can now be conveniently located in your Hotlist and operated from there.
To remove a ship from the Hotlist, double-click or long-press (for touch devices) on its large ship picture in the Target Location area again. A short 2-second message will appear above the Target Location area informing you that the ship has been removed from your hotlist.
Hotlist information is saved during your play session. It will remain as long as you remain on the Browser Tab that is running x-wing-ai.com. The Hotlist will be deleted if you close the Tab or close your browser. It would be wise to set up your Hotlist as soon as you open up x-wing-ai.com to play your solo game.

### Using x-wing-ai.com To Play For the AI in a Solo Game

On the AI main page, for each AI controlled ship, during each round, you will:

1. Click on the Faction or Hotlist and then click on the ship icon on the left side of the page for the AI ship you are controlling.
2. The page will update to show the selected ship's picture in the middle of an "aiming reticle" field, the ship's stats, abilities and all prioritized activities the ship can perform in each phase.
3. Each sector of the "aiming reticle" corresponds to the location where the Target Ship is in relation to the AI ship, and is a "live" (clickable) area.
4. When you are ready to select the AI ship's maneuver, you will click on the appropriate sector, and the app will "roll the dice" and update the potential maneuvers.

## The Game Round:

1. Planning Phase: Most AI ships do nothing during the Planning Phase. However, AI ships equipped with a "Cloaking Device" (Illicit Upgrade) must test to decloak during this phase. The notes will inform you of the AI's actions if required.
2. System Phase: AI ships carry out any actions listed under the System Phase header on the app.

   ### HOTAC Optional AI Rules for Devices:

   The HotAC/FGA page now includes "HOTAC Optional AI Rules for Devices" by Dovi Anderson. Bombers (and some scum with Illicit Payloads) who are capable of dropping or launching Payloads (Bombs, Mines, Remotes etc.) now have a dropdown menu to allow you to select a payload. Hover your mouse over the "Payload Selection" button and the dropdown list will appear. Click on a payload and a "Logic Diagram" will appear.

   Which diagram you see depends on if the device is activated via "Timing" (e.g., at the end of the Activation Phase) or "Movement" (e.g., mines, where any ship that overlaps or crosses it will cause it to activate). See Dovi's Device Rules for full details. Using the Logic Diagram, determine if the AI will drop or launch a device (if it can do so) referencing the Attack Die Roll shown below the table. When the AI chooses to drop or launch a device, it will always try to place the best device it can in the place where it will do the most potential damage to as many enemies as possible.

   ### AI Interactions with Friendly Devices

   AI will usually not detonate friendly munitions.

   1. AI ships do not detonate or suffer effects of non-obstacle friendly Motion-Triggered ( Class B "Movement") Devices.
   2. Before a friendly End of Activation (Class A "Timing") Device detonates that would only affect friendly AI ships, remove the device from the board without effect.
   3. When a friendly End of Activation Device detonates that affects MORE friendly AI ships than enemy ships, reduce the number of AI ships affected until the same number of ships are affected on both sides. AI ships furthest from the device are spared.
   See Dovi's Rules for details.

   ### AI Avoidance of Enemy Devices (not dependent on AI Device Dropping/Launching)

   If an AI ship's maneuver or reposition action (such as barrel rolling to get a shot) would cause it to suffer the effects of 1 or more enemy devices this round, determine if it attempts to avoid them:
   1. If the ship would be destroyed by direct damage from enemy devices (damage not determined by dice), it will always attempt to avoid enemy devices. Include seismic charges that could effect the ship as doing direct damage for this calculation.
   2. Otherwise, the ship rolls 1 defense die for every enemy device it is threatened by (including seismic charges): If 1 or more results are rolled, the ship attempts to avoid enemy devices. Device avoiding ships that entered threat via repositioning simply cancel the action and select another.

   Device avoiding ships that entered threat via its maneuver will attempt to:
   Use reposition actions to avoid the effects of enemy End of Activation Devices as follows:

   1. Avoid the most enemy devices possible (include all obstacle threats via seismic charges).
   2. Then, in priority order: avoid target's arc and get a shot / get a shot / avoid target's arc.

   NOTE: Interceptors that use 1 reposition may focus first if they pick up a shot, as normal.

3. Activation Phase:

1. Take any pre-move actions for the AI as indicated.
2. Pick a Target (human-controlled) ship for the AI ship using the priorities shown under Select Target Location.
3. Click on the location on the "aiming reticle" that matches the location of the Target ship (relative to the AI ship).
   The app will update the four possible maneuvers the AI ship can perform, depending on the range and aspect (i.e., "closing or opening") of the Target ship from the AI ship and whether the AI is "Stressed".
4. Move the AI Ship using the displayed maneuver:

- Choose the "Tgt R1/R2(Closing)" maneuver if the Target ship is in Range 1 or is in Range 2 and facing towards the the AI ship ("Closing" aspect).
- Choose the "R2(Fleeing)/R3" maneuver if the Target ship is in Range 2 and facing away from the AI ship ("Opening" aspect) or is in Range 3.
- Choose the "R4+" maneuver if the Target ship is beyond Range 3 from the AI ship.
- Choose the "AI Stressed" maneuver if the AI ship has a token.

Remember that AI ships do NOT gain a token as a result of conducting a "Difficult" (Red) maneuver.
However, they may not take an action in the Action portion of the Activation Phase if they conducted a "Difficult" (Red) maneuver.
AI ships CAN gain a token as a result of other game mechanics, such as collisions with obstacles, executing an action, card direction, etc.

OPTIONAL RULE: The "Not-Quite-As-Stupid AI Pilot Rule". If the AI maneuver would cause the AI ship to overlap an obstacle (as defined in the 2.0/2.5 rules) or move away from a scenario objective (if using 2.5Ed rules), you may reroll the AI's maneuver ONCE (click on the appropriate target location sector again to reroll). Then you may select the most helpful or least harmful maneuver of the two for the AI to execute. If the reroll comes up the same as the first roll, oh well! This rule does NOT apply if the original AI move would cause it to overlap another ship (i.e. a partial maneuver). If you choose to use the "Not-Quite-As-Stupid AI Pilot Rule", you should use it consistently throughout your game.

4. Choosing an action:

1. In the Action portion of the Activation Phase, if the AI is not prohibited from performing an action (for instance, prohibitions due to an obstacle overlap or posessing a stress token), choose the Action for the AI ship using the Action Selection priorities listed on the app.
2. Don't forget to take any other additional allowed actions resulting from ship/pilot abilities, card direction, etc.
3. If the selected ship can perform the Target Lock action, this is a free action for the AI ship. Choose this action plus another action that is available in the list.
   The AI ship loses the "free" target lock at the end of its turn.

NOTE: The AI ship must be able to perform actions on its turn to be able to use the "free" Target Lock action. If it is unable to perform any actions (due to performing a RED maneuver, collision, or presence of a stress token, for example), it may not take the "free" Target Lock action this turn.

The "free" Target Lock for the AI (on ships that can perform a Target Lock) provides for more of a challenge to the player.
Feel free to ignore this rule if you like, but play consistently through the game no matter whether you choose to use AI "free" Target Locks or not.

5. Engagement Phase:

1. Select the Attack Target for the AI ship to attack, if possible, using the priorities listed on the app under Attack Priorities.
   Note that the Attack Target might not be the same target that was used for maneuver selection! That is perfectly fine.
2. Conduct engagement using X-Wing 2nd edition or 2.5 Edition rules depending upon which version you are playing.

6. End Phase:

1. Remove all circular tokens. AI ships MUST remove any unused Target Lock(s). AI ships carry out any actions listed under the End Phase header on the app.

## Notes:

- ALWAYS choose the human controlled ship(s) maneuvers before choosing AI maneuvers.Set your dials before using x-wing-ai to perform AI maneuvers.
- AI ships NEVER get a stress token as a result of executing a difficult maneuver, but may not perform any actions after a RED maneuver.
- AI ships can get a stress token as a result of interacting with an obstacle (for example, space debris) or executing a RED action.
- Always use secondary weapons, upgrade functions or optional pilot skills for each AI ship, when and as applicable. The Attack Priorities should help remind you of what weapons the AI ship can use (if equipped).
- Have fun and use XWingAI2 to help you improve your X-Wing TMG skills! It's a tool, so use it however it fits your play style.