Wednesday, October 17, 2012

Trouble, Please Be Kind!

"I don't want no fight, and I haven't got a lot of time." — Cat Stevens

I'm still wrestling with how to identify transient objects in sectors. The game doesn't provide much help, as the closest thing a ship or planet has to a UUID or primary key is its numerical ID, and that isn't included in the sector display. Any number of ships and planets can have the same name, and when one is destroyed, its numerical ID is reused. Ships can be uniquely identified by a combination of their ID and build timestamp, but you have to be sitting in them to see the the timestamp. To top it off, traders and ships can be renamed.

This brings back bad memories of the project that began and ended my brief career as a programmer. A wireless telco had a customer database with no primary keys, and they couldn't modify the schema because their point-of-sale systems were contracted out to some other company. They were trying to use a combination of customer name, address, and phone number to identify accounts for the purpose of paying their commissioned employees. But more than one of these fields could change at the same time, and they frequently did. Worse, canceled phone numbers were simply thrown back into the pool of unused numbers, so a new customer would often get a number that belonged to someone else the day before, and thus show up in the reports as a name/address change instead of a new account. It was madness. Nobody was getting paid what they were owed, and I couldn't fix it.

I looked to the source code of Kokua for inspiration, but it appears that its developers struggled with the same problems, and their solutions were ones that I've already rejected. In a few cases, they simply left it as a to-do. I understand now why SWATH often has duplicate planets in its database. It seems to err on the side of caution when it's unclear whether a planet is the same one in a new location or a different one with the same name. And it's not uncommon for players to create numerous planets with identical names. I always wrote it off as laziness, but it could be an attempt at confusing helpers and scripts. Depending on the helper, it probably works.

I have some vague ideas about resolving identities through some kind of "best guess" algorithm, but I need to do more research and a lot more thinking. I will solve this problem; I must. But if I don't come up with something in the next four days, I may fall behind schedule.

No comments:

Post a Comment