C7-Game / Prototype

An early-stage, open-source 4X strategy game
https://c7-game.github.io/
MIT License
32 stars 9 forks source link

Settler AI - Consider tiles in the BFC, and potential yield improvements #94

Open QuintillusCFC opened 2 years ago

QuintillusCFC commented 2 years ago

This is a more advanced one, after #92 and #91 . Currently, the AI only considers tiles immediately next to cities. This is pretty much okay early on since those will be the tiles that the city works. However, there should be some consideration of the tiles in the BFC (big fat cross) as well, and the AI should also consider whether tile improvements can increase the yield - notably, Hills and Mountains get +2 shields with a mine, versus +1 for other tiles, which is worth something, whereas tundra cannot be irrigated, and volcanoes cannot be mined; volcanoes should be considered less valuable than mountains despite the same initial tile yield.

The improvement weights should likely be considerably less than the base yields, to avoid the AI hamstringing itself by choosing tiles with low yields early on. Desert can be improved just as much as grassland, but is a much inferior choice early on, for example. The AI should also likely consider an either/or for food/shield improvement, since you cannot make both. Intuitively, I'm thinking 1/3 the weight of base yields, although that may be too high or too low. Make it configurable.

BFC weights should also be considerably less; we don't want the AI choosing locations because there are a bunch of cows right outside the new city's borders. But if there are two locations the AI is considering and one has Game outside the borders and the other doesn't, it's a tiebreaker.

It may be necessary to bump the base yields to make these lower weights feasible, e.g. the value of a base commerce might be 20 instead of 2. Alternately, we could use floats so we have decimal weights when dividing.

benskywalker commented 9 months ago

I'm taking a look at this, and I think it also makes sense to consider defensive bonus as a factor, rather than hard-coding a bonus for hills (as currently happens here). I can calibrate it so hills will retain a similar advantage, and this will help if the defense values change. Also, is there any reason not to make scores a double? I'll look into it

benskywalker commented 9 months ago

I can't see any negative consequences of changing the score to a double, so I'm doing that locally. The only downside is the change propagated into other AI Scores, but maybe those should be doubles anyway for precision?

The change means we don't have to recalibrate scores constantly as we addc7 lower-order score factors. I'm thinking outer ring can be 1/3 as important for now. Maybe 1/5? I've got an algorithm to calculate Bfc outer tiles, and it shouldn't be hard to calculate tile improvability once I find where that data is stored.