In case generalized actions gets delayed to post 3.1

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
sveinung
Elite
Posts: 459
Joined: Wed Feb 20, 2013 4:50 pm

In case generalized actions gets delayed to post 3.1

Postby sveinung » Fri Nov 22, 2019 2:52 pm

Actions are currently hard coded. Generalized actions moves them to the ruleset. The advantage of generalized actions is that you can have more than one action with the same result. Those variants can then have different ruleset defined properties like enablers, ui name, cost and, in the case of "Bombard", range.

I had hoped to generalize actions them self in time for 3.0. I didn't. My contingency plan in case the same happens for 3.1 is to fake generalized actions. This can be done by including hard coded actions that would be redundant with generalized actions. I'm not planning to include redundant copies of each and every action. If you feel that a specific action should get fake generalization point it out below or (better) in the ticket and explain how a fake generalization for that action would make your life easier.

Blank actions:
"User Action vs city" "User Action vs unit" "User Action vs unit stack" "User Action vs tile"
Does nothing at all in their action performers. The ruleset is responsible for everything. The ruleset can do that via Lua and Action requirements.

Duplication of existing actions:
"Bombard 2" "Bombard 3" - Copies of "Bombard". Separate bombard_max_range. Additional difference can be done via Lua and Action requirements.

Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: In case generalized actions gets delayed to post 3.1

Postby Ignatus » Fri Nov 22, 2019 7:08 pm

Great challenge! Are you going to give AI any hints on using these actions?

sveinung
Elite
Posts: 459
Joined: Wed Feb 20, 2013 4:50 pm

Re: In case generalized actions gets delayed to post 3.1

Postby sveinung » Sun Nov 24, 2019 2:28 pm

Ignatus wrote:Great challenge! Are you going to give AI any hints on using these actions?


Thank you. Could you clarify what part you are asking for AI hints about?

Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: In case generalized actions gets delayed to post 3.1

Postby Ignatus » Sun Nov 24, 2019 9:20 pm

sveinung wrote:Could you clarify what part you are asking for AI hints about?

Just, will AI be able to use this action and if yes, how it gets the idea of when it is necessary?

sveinung
Elite
Posts: 459
Joined: Wed Feb 20, 2013 4:50 pm

Re: In case generalized actions gets delayed to post 3.1

Postby sveinung » Mon Nov 25, 2019 7:32 am

Ignatus wrote:
sveinung wrote:Could you clarify what part you are asking for AI hints about?

Just, will AI be able to use this action and if yes, how it gets the idea of when it is necessary?

I'll just assume you were asking about all parts: generalized actions, actions that fake being generalized by duplication and blank actions.

A blank action will only have the AI hints provided by the declarative ruleset format. At the moment the declarative action data doesn't say much. What exists, like movement cost for some situations, range and Casus Belli, isn't used as far as I can recall. Blank actions will therefore not be used by the AI in the beginning.

A generalized action will have a result unless it is blank. A duplicate action will fake a generalized action by being a duplicate of what would be its result were generalized actions done. A generalized action will be treated like its result. So "Bombard 2" would be treated like "Bombard".

Should the AI start to understand stuff like movement cost effects and "Bombard" has a different movement cost from "Bombard 2" the AI should take that into consideration. The AI may start to understand movement cost effect in patches related to Feature #847256 and Feature #848684. Probably not as a part of them. I don't like AI behavior changes in a patch that changes the ruleset format. It prevents testing that the patch doesn't accidentally change the rules via an autogame.

On a semi related note: the AI's current support for actions is extremely hard coded. Even small changes like replacing a hard coded order of actions to try with action selection based on utility value, the Freeciv AI's typical mechanism for choosing, would be a huge improvement.
Update: I did Feature #849343 as a minimal example of converting from hard coded "try this than try that" to a utility function. It is just a port of the old behavior that no longer depends on that actions aren't generalized. I also added movement cost and Casus Belli consideration. This is a foundation better action support can be built on later.

sveinung
Elite
Posts: 459
Joined: Wed Feb 20, 2013 4:50 pm

Re: In case generalized actions gets delayed to post 3.1

Postby sveinung » Mon Dec 02, 2019 7:17 am

I am considering to fake generalize "Transport Board" and/or "Transport Embark" by duplication if someone requests it.