Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 1971

Lua Labs • Re: Proposed micro_ai logic sanity check

$
0
0
I've still got a fair amount of research to do, e.g. not currently sure how to implement:
...The evaluation phase of the custom candidate action needs to inform the RCA when it decides there is nothing for the MicroAI to do...
[/code]
It informs the RCA by returning a score of 0. This also allows it to be called again if, after a move from the default move CA, there is something new that the MicroAI can do. If it returns a non-zero score but then doesn't do anything, the RCA won't call it again until the next turn.
However with a better grasp of the fundamentals I'm sure when I look for examples I'll be able to work out how to do that. :fingers_crossed:
E.g. at first glance my understanding of the code below is:
If units subject to this micro_ai with moves>0 exist, movement will be considered to have taken place; return ca_score as specified in custom micro_ai otherwise return 0 (thereby reducing this CA's priority below the default CA score?).
Pretty much, except that If units subject to this micro_ai with moves>0 exist can be whatever condition you want. If you want the units to only ever be controlled by the MicroAI, then that condition is fine. If you want the units to be controlled by the default AI in certain circumstances, your condition would need to be such that it returns 0 in that circumstance.

Code:

function ca_forest_animals_move:evaluation(cfg)    if get_forest_animals(cfg)[1] then return cfg.ca_score end    return 0end
This works, assuming get_forest_animals filters out units that cannot move.

Statistics: Posted by Celtic_Minstrel — Yesterday, 6:32 pm



Viewing all articles
Browse latest Browse all 1971

Trending Articles