AaronGullickson / system_generation

Generate solar system data for Battletech universe using Campaign Operations rules
2 stars 1 forks source link

Invisible planets in HPG network #2

Closed AaronGullickson closed 5 years ago

AaronGullickson commented 5 years ago

When setting the time frame to star league (e.g. 2640) the HPG network is showing some links to invisible planets that have no faction. This suggests HPGs are being assigned prior to the founding date.

AaronGullickson commented 5 years ago

An example in current build would be Howrah. its first faction event is 2750 (FWL). So that should be the founding date. But the first evens are from 2613, suggesting that we are using a different founding date for some reason.

AaronGullickson commented 5 years ago

So the problem is that we are re-distributing the founding years of cases like this with heaping (in this case on 2750), but we are not updating the faction change event table. I actually wrote myself a TODO about this at one point:

#TODO: Ultimately, we will will also need to correct the faction change event and mark
  # it as non-canon

So now is probably a good time to address that TODO. Adjusting the data of the first faction event probably shouldn't be too difficult. We should probably just make the change to our faction table and then use that for creating faction change events and ignore the ones in the planetevents file.

Marking it as non-canon is more difficult because we don't actually track founding year as a data item. But we probably should so lets add that to the base planet social data.

AaronGullickson commented 5 years ago

OK, I have made changes (not committed) that should fix all of this and the XML looks well formatted but now even more planets are missing in MHQ. Looking through the code, I believe a planets events are kept in a hash where the key is DateTime. I haven't looked thoroughly yet but it may be that events with the same date probably overwrite one another. This will always be the case on founding date because faction, SIC, and population all have an entry for founding date. I think it wasn't showing up as an issue before because faction events were added last so they were overwriting initial SIC and pop codes which was less easy to see.

The reason it was done this way, I believe was because the idea was to combine events with the same date into one node. So faction, sic, and pop codes could all be assigned at the same time. I could probably figure out how to do that on the system_generation side, although it would be a pain. Initial founding would be straightforward but I would have to watch out for duplicates elsewhere.

Probably the best way to handle this would be to put all events initially into a giant dataframe with system id, system position, date, event type, event. The HPG stuff could be added to this as well.

Then for loop through all the unique ids in that dataframe (and sys_pos), sort a planet's events by date and then loop through events. If you hit another event with the same date, stay in the same node and otherwise create a new node. This would have the advantage of chronologically sorting all of the events in the events file.

The alternative would be to change how MHQ tracks them, but that could also be difficult.

AaronGullickson commented 5 years ago

Added the commit for the previous comment at c48e99283ac570f759a245ea8e3a153c61d39c56.

AaronGullickson commented 5 years ago

I have switched the way system events are written so that ones with the same date are written to the same event in commit c0884568638cff7b983246fdd7b2d539b043485f. This has fixed most of the problems I was having before, but I am still noting a few invisible planets. Looking at them, it appears to be cases with an HPG event before the founding of the planet. So, I need to check the code and see why that is happening.

AaronGullickson commented 5 years ago

This has now been fully fixed with 80f48c7b67a288ae7c033058c5bc43716db84115.