Main Menu

News:

Please be aware of the Forum Rules of Conduct.

Caravans - what is the logic for allowed routes?

Started by Jens Namtrah, August 16, 2011, 09:58:29 AM

Previous topic - Next topic

Jens Namtrah

As the title says - in the dropdown for where I can send food, what is the rule that populates this?

I am Baron of Melmoor - I can see all of my Duchy, all of the MI duchy of York, but only Shiverwood in neighboring Brackhead Duchy.

Anaris

Timothy Collett

"The only thing you can't trade for your heart's desire...is your heart." "You are what you do.  Choose again, and change." "One of these days, someone's gonna plug you, and you're going to die saying, 'What did I say? What did I say?'"  ~ Miles Naismith Vorkosigan

Jens Namtrah

Nope -

Brackhead is 180 miles (14hrs/4 turns)

Rotherthorpe (for example) is 264 (20hrs/5 turns)

Indirik

Umm... Tim wrote the code. I think he knows how it works.

But for a bit of explanation: It is not the travel distance, it is the straight-line distance between the region "centers" that counts. Melmoor > Rotherthorpe is an extremely long journey because of the round-about road you have to take to get there. Caravans are not obliged to follow the roads.
If at first you don't succeed, don't take up skydiving.

Anaris

What Indirik said :-)

Also, you can't trade with people you're at war with.
Timothy Collett

"The only thing you can't trade for your heart's desire...is your heart." "You are what you do.  Choose again, and change." "One of these days, someone's gonna plug you, and you're going to die saying, 'What did I say? What did I say?'"  ~ Miles Naismith Vorkosigan

Jens Namtrah

Quote from: Indirik on August 16, 2011, 02:30:57 PM
Umm... Tim wrote the code. I think he knows how it works.

But for a bit of explanation: It is not the travel distance, it is the straight-line distance between the region "centers" that counts. Melmoor > Rotherthorpe is an extremely long journey because of the round-about road you have to take to get there. Caravans are not obliged to follow the roads.


Hmmm...didn't realize the game used image hit points in that way. Makes caravan travel a little strange, if you look at the map itself.

Anyway, thanks for the explanation.

Anaris

Quote from: Jens Namtrah on August 17, 2011, 12:55:03 AM

Hmmm...didn't realize the game used image hit points in that way. Makes caravan travel a little strange, if you look at the map itself.

Yeah, we know.  However, route calculation is one of the most expensive operations.  We don't want to do it very often.
Timothy Collett

"The only thing you can't trade for your heart's desire...is your heart." "You are what you do.  Choose again, and change." "One of these days, someone's gonna plug you, and you're going to die saying, 'What did I say? What did I say?'"  ~ Miles Naismith Vorkosigan

Chenier

Quote from: Anaris on August 17, 2011, 01:25:10 AM
Yeah, we know.  However, route calculation is one of the most expensive operations.  We don't want to do it very often.

What do you mean expensive?
Dit donc camarade soleil / Ne trouves-tu ça pas plutôt con / De donner une journée pareil / À un patron

De-Legro

computational, in other words it eats up server resources, which as we already know have been taxed in the past.
Previously of the De-Legro Family
Now of representation unknown.

Chenier

Quote from: De-Legro on August 17, 2011, 05:45:41 AM
computational, in other words it eats up server resources, which as we already know have been taxed in the past.

It calculates it every time?

If they were all pre-calculated, would that not help?
Dit donc camarade soleil / Ne trouves-tu ça pas plutôt con / De donner une journée pareil / À un patron

De-Legro

Quote from: Chénier on August 17, 2011, 05:58:37 AM
It calculates it every time?

If they were all pre-calculated, would that not help?

Indeed, then you would only need to update the database when things change, like a region going rogue, a war being declared or a region changing hands.
Previously of the De-Legro Family
Now of representation unknown.

Chenier

Quote from: De-Legro on August 17, 2011, 06:19:58 AM
Indeed, then you would only need to update the database when things change, like a region going rogue, a war being declared or a region changing hands.

Is this sarcastic?

What exactly is taxing about the calculations anyways? Is it because it's on an image, or just any calculations at all is taxing?
Dit donc camarade soleil / Ne trouves-tu ça pas plutôt con / De donner une journée pareil / À un patron

Jens Namtrah

Quote from: Chénier on August 17, 2011, 06:33:26 AM
Is this sarcastic?

What exactly is taxing about the calculations anyways? Is it because it's on an image, or just any calculations at all is taxing?

The calculations bit has to do with the Dykstra algorithm used in the travel code, to find the shortest route. It uses a lot of resources to test all the variable paths for time AND distance; these generally need to be rerun each time, because so many things can affect the routes' times even from turn to turn.

Anaris is explaining that INSTEAD of using this expensive function, they chose a simple point to point way of calculating which regions are close enough, but that choice has a few quirks.

You COULD run all the routes calculations to get mileage and create a table from it, but the benefits are pretty small and I personally think time is better spent elsewhere.

De-Legro

Quote from: Chénier on August 17, 2011, 06:33:26 AM
Is this sarcastic?

What exactly is taxing about the calculations anyways? Is it because it's on an image, or just any calculations at all is taxing?

Nope, just pointing out that since the table varies given the state of the regions, calculations of some sort would be required when things change. I would imagine one way would be to generate a table for each region that lists all regions within range, and records the path they take. Then when we query the list for the page it could filter out regions that for any reason are not acceptable destinations right now, either that or keep a second updated list of which regions are currently acceptable. However the current system works in a fashion, so the time would probably be better spent coding in other area's.
Previously of the De-Legro Family
Now of representation unknown.

cjnodell

Quote from: Jens Namtrah on August 17, 2011, 06:50:50 AM
The calculations bit has to do with the Dykstra algorithm used in the travel code, to find the shortest route.

So are we using OSPF or IS-IS to make these calculations? They both utilize Dijkstra's algorithm though, being American I am much more comfortable with OSPF. Perhaps we could switch to EIGRP and utilize DUAL. It is much less computationally intensive though I am sure Cisco would charge too much for it's use...


Sorry. I could not help it. It never dawned on me that computing the patch between regions in BattleMaster would be a lot like computing paths between routers in a network. Sounds like BM has it's own link-state routing protocol. Who would have guessed!

On a serious note, someone who knew a lot more about coding than I do might be able to gain some ideas on how to optimize these calculations by peeking at these routing protocols. Not sure if it would really be worth the effort though. Regardless, I will continue chuckling to myself as I work today and pretend that I am determining the best path between Rettleville and Giask instead of R1 and R2!!! Hmmm... now that could make for an interesting network device naming convention...

LOL!!!