godip icon indicating copy to clipboard operation
godip copied to clipboard

[bug] Convoy order options for redundant fleets

Open Wulfheart opened this issue 4 years ago • 6 comments

Same setup like in #120. I thought this would go into a separate issue. grafik

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?

Wulfheart avatar Nov 30 '20 10:11 Wulfheart

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).

zond avatar Nov 30 '20 12:11 zond

Ok, I understand. But the fleet in mid has nothing to do with the convoy of eng.

Wulfheart avatar Nov 30 '20 14:11 Wulfheart

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.

zond avatar Nov 30 '20 14:11 zond

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
}

Wulfheart avatar Nov 30 '20 14:11 Wulfheart

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

zond avatar Nov 30 '20 14:11 zond

I will look into it when I have some spare time.

Wulfheart avatar Nov 30 '20 14:11 Wulfheart