Code: Select all
Give each system a string array, "producedItemTypes", and another array, "demandedItemTypes". Upon generation, when adding a station to a system, add every item trait it will sell for below market price to the first array, and every item trait it will buy for above market price to the latter array. For example, when a hotel is added to a system, "Luxury" and "Food" would be added to demandedItemTypes. Finally, check over the arrays for common traits. If any trait is in both lists, reduce the deviation from the market price at all stations in the system that produce or buy it by a factor of 5. OPTIONAL: Reduce the deviation of buying price of items produced in neighboring systems by a factor of 2, and vice versa.