scotsdezmond: TIE Fighter definitely has better goals checking, e.g. if a transport that needs to be disabled escapes into hyperspace, the mission fails immediately. I very much doubt (though have not tested) that it would check for circular logic failures though.
As you mentioned, a requirements graph is a potential solution. Thinking out loud, using the mission goals as a starting point, building a list of mission crifitical craft, and then checking spawn conditions against all flightgroups and graphing the results might go some way to implementing this, with circular logic detection.
In the event of circular logic, what would be the best way to handle it? Display a message before mission start saying that the mission is uncompletable, and starting the mission anyway in a fail state? Or refusing to load the mission at all?
What I have programmed also accounts for simple things like that, when a transport that needs to be disabled escapes to hyperspace, it is easy to detect.
What is not so easy are those, more complex, examples I described in my previous post.
For example, when a transport needs to be disabled, but the only ship that can disable it is destroyed. If the mission goal list only accounts for "Transport needs to be disabled" and not for "Y-Wing Blue needs to complete mission", then the destruction of the Y-Wing leads to a not easy to detect walking dead situation, where the mission is at the same time not failed, but not completable.
A requirement graph is easier said that done, though. It can be done, but my first attempts to model it showed deeper implications.
My initial solution was an algorithm involving hidden goals. A hidden goal is a goal that counts for the failure or success of the mission, but is not shown to the player.
1 - For every goal in the mission, inspect the related flight group's arrival condition. If the arrival of the flight group depends on another flight group meeting some condition, add that condition as a hidden goal.
2 - Repeat 1 for every hidden goal added.
3 - Repeat 2 until there are no more hidden goals added.
That would solve the case of flight groups that have goals attached not arriving because some other flight group never meets their arrival condition. And so on and on.
A quick cycle detection mechanism would be as simple as checking that you aren't adding a goal that is already on the goal list.
Unfortunately, it doesn't fix many other cases.
For example, transport Sigma needs to be disabled. That is the goal. The transport doesn't depend on any other flight group to arrive, so there are no dependecies to anyone else. However, the only ion bearing ships are Y-W Blue that arrive only after all of T/A Alpha have been destroyed.
Even when we can trace a dependecy between Y-W Blue and T/A Alpha, we cannot trace any between Y-W Blue and
Transport Sigma.
Unless we start tracing dependencies between the goal of being disabled and the fact of carrying ion weapons. But then that could trace dependencies with all rebel Y-Wings in the mission (and B-Wings, and rebel Transports), even those that have other objectives and goals and are totally unrelated!
We could still end in a situation that after some T/A Alpha escapes, and so, Y-W Blue will never come, and so Epsilon won't be disabled, the mission will not detect this as a fail, because there could be other ion carrying ships around, that won't actually attempt to disable the transport, but they might, perhaps? So we are again at square one.
You could say, "Discard all other ion carrying ships that don't have Epsilon as primary or secondary target and 'disable' as orders".
Yes, perhaps. But the logic is getting more and more complex, and takes months to implement and debug. :D
I just wonder if all this is worth the effort, or most of the time the developers made sure that all critical craft were marked as mission goals.
I like you idea of the game warning or rejecting a mission when it detects a goal requirement cycle. I wouldn't enable that for all situations. Sometimes you are building a mission, and you do it in several stages, where you check how ships behave and most of the time don't have the whole goal list ready, or even designed.
So it would be disabled for testing. But if you want to "publish" your mission, you need to have a valid, complete-able goal list.
PS:
Just thinking on another case that isn't trivial to detect and actually happens on the test mission in XWVM.
In the mission, the goals are:
- The special ship in SHU group Epsilon must be boarded.
- SHU Hasti needs to complete its mission.
SHU Hasti comes when you first identify any ship in SHU group Epsilon. Then it starts boarding the first shuttle belonging to Epsilon group that you disable.
What if you disable any of the non-special ships in group Epsilon?
Hasti boards that ship and hypers out completing its mission.
However the mission is not completed because the special ship in Epsilon hasn't being boarded.
But the mission isn't failed either. It's just in "walking dead" state.
How you detect that "The special ship in Epsilon" cannot be boarded anymore?
As you can see, it becomes trickier and trickier.