The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: jameskuyper on November 29, 2022, 06:58:52 AM

Title: get_successors(): none?
Post by: jameskuyper on November 29, 2022, 06:58:52 AM
As I understand it, in a vehicle's *.dat file:
1. If any of a vehicle's Constraint[Next] values is "none", the vehicle is permitted to have no vehicles behind it.
2. If the only Constraint[Next] values is "none", the vehicle is required to have no vehicles behind it.
3. If there are no Constraint[Next] values, the vehicle may be followed by any vehicle whose Constraint[Prev] values allow it.
As far as I can tell from my experiments, the last two cases both result in vehicle_desc_x.get_successors() returning an empty list. How may I distinguish them?
Title: Re: get_successors(): none?
Post by: Dwachs on November 29, 2022, 08:35:13 AM
In case (2) the returned list should not be empty but contain a null element.

I have to check this.

Edit: it does not. The null element is explicitly thrown away.
Title: Re: get_successors(): none?
Post by: jameskuyper on November 30, 2022, 08:05:18 AM
Hypothesis: can_be_last() tests whether any of Constraint[Next] was "none". Therefore:

get_successors() non-empty, can_be_last() false: must be one of the items on the list.
get_successors() non-empty, can_be_last() true: can be one of the items on the list, or no successor at all.
get_successors() empty, can_be_last() false: can be any vehicle whose one predecessor list allows it.
get_successors() empty, can_be_last() true: must be last.

This seems to be consistent with the cases I checked. Is it correct?
Title: Re: get_successors(): none?
Post by: Dwachs on November 30, 2022, 08:20:32 AM
Looks correct. Then the docs are wrong: if the list is empty and can_be_last is true then it has to be the last vehicle.