[freeciv-ai] (PR#6595) Optimize/reimplement CM
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6595 >
> I don't favor such a way. Maybe this produce better results in the
> long run the maintainability is reduced by such huge amount of
> interconnected code which also will have to hold state. IMHO one
> reason why the adaption of the CMA/CM to the server was rather quick
> and painless that it doesn't hold state and has a simple
> you-ask-I-answer interface.
> So build another module on top of CM which adjusts the weights in a
> smart way to use the foodbox as buffer.
If we can assume (or if we choose to ignore other possibilities) that
the optimal solution is a combination of only two sets of tile usages,
one of which has negative food growth, then we can get away with a
simple trick. We simply use the set with negative food growth as long as
this will not result in starvation. At this point we switch to the
other, and then switch back. If we feel this is risky (what if the
available tiles suddenly changes and we don't have those food producing
tiles available when we need to change?), we can to it the other way
round. Use the set with positive food growth as long as it doesn't make
the city grown, at that point switch the the other, and then switch back.
For example, in the above example, use 3f/3t + 0f/5t as long as the city
doesn't starve, then switch to 3f/3t + 5f/0t, and then switch back. Or
the other way round.
I would prefer to remember the "other" set of tiles to use rather than
recalculate them whenever we want to switch, but this is not a big deal.
Maybe we need to recalculate anyway because some tiles have changed.
If such an approach can work with more than two sets of tiles for
optimal usage, I'm not sure. I would have to think about that a bit, if
we feel it is worth considering.