It's not really thinking like that. It would be something like:
An Altarian fighter is sitting in a sector. The human player moves a ship into the same sector, within sensor range of the Alatarian ship. A series of if statements are run:
If it's a foe:
Can the fighter defeat it in battle?
If yes:
Can the fighter "out run" the enemy ship?
If yes:
The computer will designate the Altarian ship to move on its turn to attack the ship.
If it's a friend:
Continue with auto explore/auto survey/sentry/guard.
The decision is set as soon as the human player ship moves into range of any ship, starbase, or planet. Once the human player makes a change, such as move that ship out of sensor range, the computer might determine where it went, and opt for a pursuit. If it notices that it's transports, and the direction the transports are going are towards a planet, it will ready that planet for defense.
If that Altarian fighter pursues, and winds up in sensor range of a Drengin fighter, the process for the Drengin continues. The computer would already know the outcome when you move a ship, as to what the Drengin and the Altarians are going to do in the situation.
Say you're at war with the Altarians, but are allied with the Drengin. The above scenario occurs, you have an unarmed construction ship moving to a position to setup a forward base to help you push into Altarian territory. The constructor ship moves out of sensor range of the Altarian fighter, but passes into (or thorugh) the sensor range of a Drengin fighter fleet. The computer decides that the Altarians will pursue, and wind up passing through the Drengin fleet sensor range in the process. The computer then decides that the Drengin will attack the Altarian fighter when it passes through. So, it plays out, you move, the Altarians move in pursuit, and the Drengin follow and attack the Altarian fighter.
If you walk away for 30 minutes, the outcome will still be the same. The Altarian process might keep running to see if it's the appropriate course of action, and the Drengin process will keep running to see if it's the appropriate course of action as well. But, the outcome will likely stay the same.