godip
godip copied to clipboard
[bug] Convoy order options for redundant fleets
Same setup like in #120. I thought this would go into a separate issue.
In my opinion it doesn't make sense that mid is able to convoy something to london from wal as this would only need eng. Or is this defined otherwise in the rules?
Convoy orders are not only legal when unnecessary, they can sometimes even be weirdly necessary (e.g. if two units want to switch places, then one gives a "move" and the other a "move via convoy" supported by an actual convoy order).
Ok, I understand. But the fleet in mid has nothing to do with the convoy of eng.
Ah, now I see what you mean.
What other fleets are there on that map? If there exists a convoy route, of any kind, from wal to lon, then the option will appear for the fleet.
Fleets are in eng
and in mid
.
func scaffoldVariant(t *testing.T, variantName string) (s *state.State) {
variant, found := variants.Variants[variantName]
if !found {
t.Fatal("Variant", variantName, "not found")
}
s, err := variant.Start()
if err != nil {
t.Fatal(err.Error())
}
fleet := godip.Unit{
Type: godip.Fleet,
Nation: godip.France,
}
army := godip.Unit{
Type: godip.Army,
Nation: godip.France,
}
s.SetUnit("eng", fleet)
s.SetUnit("mid", fleet)
s.SetUnit("wal", army)
s.SetUnit("pic", army)
s.SetUnit("bur", army)
s.SetUnit("ruh", army)
return
}
Hah, yes, then you have found a bug. I contend it's pretty minor, but still :D
Right now the graph search that finds convoy routes for this purpose doesn't check that the convoying fleet isn't a dead end, or that it is a redundant loop of the path, it just finds all fleets with a connection to any valid convoy path...
The code is in https://github.com/zond/godip/blob/master/orders/convoy.go#L355 (it basically finds a path from src to the fleet, and then from the fleet to dst), if you are interested in patching it :D
I will look into it when I have some spare time.