Follow-up Comment #1, patch #4887 (project freeciv): On AI use of sliders: In the event that slider value changes are limited to once per turn (players can change as much as they want, whenever they want, but the effect of having done so only takes effect on turn change), the the AI can call into a valuation routine at end-of-turn to set appropriate values. For each multiplier, iterate over the effects (probably makes sense to add multipliers as a source in the ruleset cache for performance reasons), and call dai_effect_value() to determine the relative interest in the effect. Then compute the total valuation of any possible slider position, and select the best one (or a random one of the best in the case of equivalent valuation). Note that doing it this way will cause any bugs in dai_effect_value() to become more obvious if they happen to match effects for which multipliers are applied.
In the event that slider values take effect in realtime, a lightweight target optimisation routine could be added for in-turn relative effects (e.g. unit move rates, attack/defense bonuses, etc.), which has a cache of multipliers relative to specific activities/conditions, which is checked when those conditions apply. In such cases, the AI would push the slider all the way for that effect at that moment, so the sliders move about over the course of the turn (if relevant), and and end of turn, the routine described above is called to set sensible values for turn change. If this is needed, it may make sense to have it be a different patch than the once/turn calculation, as it would be nice to call into some of the code written for that during the cache population. I haven't investigated the call stack, but it may be that the AI will need to set the multipliers to some neutral value (e.g. 1.0) before calculating best values, so as not to end up in a feedback loop: yes this won't be optimal, but calculating true multivariate optimums without succumbing to local maxima takes more processing than the classic AI should be permitted. _______________________________________________________ Reply to this item at: <http://gna.org/patch/?4887> _______________________________________________ Message sent via/by Gna! http://gna.org/ _______________________________________________ Freeciv-dev mailing list Freecivfirstname.lastname@example.org https://mail.gna.org/listinfo/freeciv-dev