Skip to content

Commit

Permalink
WIP Schema for the AI WML
Browse files Browse the repository at this point in the history
Pretty much all working, except for the [aspect] tag
Also, [modify_ai] is not yet specified (needs new schema features)
  • Loading branch information
CelticMinstrel committed Mar 31, 2018
1 parent 9d54f99 commit 0444c8a
Show file tree
Hide file tree
Showing 10 changed files with 606 additions and 29 deletions.
53 changes: 53 additions & 0 deletions data/schema/ai/_main.cfg
@@ -0,0 +1,53 @@

#define AI_ASPECT_FILTERS
{SIMPLE_KEY turns range_list}
{SIMPLE_KEY time_of_day string_list}
#enddef

#define AI_ASPECT_INVALIDATE
{SIMPLE_KEY invalidate_on_* bool}
#enddef

[tag]
name="ais"
min=1
[tag]
name="ai"
max=infinite
super="$ai"
{REQUIRED_KEY id string}
{SIMPLE_KEY name t_string}
{SIMPLE_KEY description t_string}
{DEFAULT_KEY hidden bool no}
[/tag]
[tag]
name="default_config"
min=1
[link]
name="$ai/aspect"
[/link]
[/tag]
[/tag]

[tag]
name="$ai"
max=0
{SIMPLE_KEY ai_algorithm string}
[tag]
name="$component"
{SIMPLE_KEY id string}
{SIMPLE_KEY name string}
{SIMPLE_KEY engine ai_engine}
[/tag]
[tag]
name="$generic_lua_component"
engine=lua
{SIMPLE_KEY code string}
{DATA_TAG args 0 1}
[/tag]
{./engine.cfg}
{./aspect_complex.cfg}
{./aspect_simple.cfg}
{./goal.cfg}
{./stage.cfg}
[/tag]
293 changes: 293 additions & 0 deletions data/schema/ai/aspect_complex.cfg
@@ -0,0 +1,293 @@

#define AI_ASPECT_FILTER_STANDARD
engine=cpp
name=standard_aspect
[or]
engine=
name=standard_aspect
[/or]
#enddef

#define AI_ASPECT_FILTER_COMPOSITE
engine=cpp
name=composite_aspect
[or]
engine=
name=composite_aspect
[/or]
#enddef

#define AI_ASPECT_FILTER_DEFAULT
[or]
engine=cpp
name=
[/or]
#enddef

#define AI_ASPECT_FILTER_ATTACKS
engine=cpp
name=ai_default_rca::aspect_attacks
id=attacks
[or]
engine=
name=ai_default_rca::aspect_attacks
id=attacks
[/or]
[or]
engine=cpp
name=
id=attacks
[/or]
[or]
engine=
name=
id=attacks
[/or]
#enddef

#define AI_ASPECT_FILTER_LUA
engine=lua
name=lua_aspect
[or]
engine=lua
name=
[/or]
[or]
engine=
name=lua_aspect
[/or]
#enddef

#define AI_ASPECT_SWITCH BASE
[switch]
key=id
[case]
value=aggression,caution,leader_aggression,leader_value,scout_village_targeting,village_value,recruitment_diversity
super="{BASE}~real"
[/case]
[case]
value=leader_ignores_keep,passive_leader,passive_leader_shares_keep,simple_targeting,support_villages
super="{BASE}~bool"
[/case]
[case]
value=villages_per_scout,attack_depth,recruitment_randomness
super="{BASE}~int"
[/case]
[case]
value=grouping
super="{BASE}~ai_grouping"
[/case]
[case]
value=advancements,recruitment_more,recruitment_pattern
super="{BASE}~string_list"
[/case]
[case]
value=avoid
super="{BASE}~avoid"
[/case]
[case]
value=leader_goal
super="{BASE}~leader_goal"
[/case]
[case]
value=recruitment_instructions
super="{BASE}~recruitment_instructions"
[/case]
[case]
value=recruitment_save_gold
super="{BASE}~recruitment_save_gold"
[/case]
[/switch]
#enddef

[tag]
name="aspect"
super="$ai/$component"
{AI_ASPECT_INVALIDATE}
[if]
{AI_ASPECT_FILTER_STANDARD}
[then]
{AI_ASPECT_SWITCH $ai/standard_aspect}
[/then]
[elseif]
{AI_ASPECT_FILTER_COMPOSITE}
{AI_ASPECT_FILTER_DEFAULT}
[then]
{AI_ASPECT_SWITCH $ai/composite_aspect}
[/then]
[/elseif]
[elseif]
{AI_ASPECT_FILTER_ATTACKS}
[then]
super="$ai/facet~attacks"
[/then]
[/elseif]
[elseif]
{AI_ASPECT_FILTER_LUA}
[then]
super="$ai/facet~lua"
[/then]
[/elseif]
# TODO: Somehow give an error for any other combination
[/if]
[/tag]

[tag]
name="$facet_base"
super="$ai/$component"
{AI_ASPECT_INVALIDATE}
{AI_ASPECT_FILTERS}
[/tag]

[tag]
name="facet~lua"
super="$ai/$generic_lua_component"
{SIMPLE_KEY value string}
[/tag]

#define AI_ASPECT NAME VALUE
[tag]
# This defines the valid content of an aspect with name=standard_aspect
# and the specified ID
name="standard_aspect~{NAME}"
{VALUE}
[/tag]
[tag]
# This defines the valid content of an aspect with name=composite_aspect
# and the specified ID
name="composite_aspect~{NAME}"
[tag]
name="facet"
max=infinite
super="$ai/facet~{NAME}"
[/tag]
[tag]
name="default"
super="$ai/facet~{NAME}"
[/tag]
[/tag]
#enddef

#define AI_FACET NAME VALUE
{AI_ASPECT {NAME} {VALUE}}
[tag]
name="facet~{NAME}"
super="$ai/$facet_base"
[if]
{AI_ASPECT_FILTER_STANDARD}
{AI_ASPECT_FILTER_DEFAULT}
[then]
super="$ai/standard_aspect~{NAME}"
[/then]
[elseif]
{AI_ASPECT_FILTER_COMPOSITE}
[then]
super="$ai/composite_aspect~{NAME}"
[/then]
[/elseif]
[elseif]
{AI_ASPECT_FILTER_LUA}
[then]
super="$ai/facet~lua"
[/then]
[/elseif]
[else]
# This required key is just a hack to get an error here.
# It's not actually valid.
{REQUIRED_KEY invalid_engine_name_combo_in_aspect bool}
[/else]
[/if]
[/tag]
#enddef

#define AI_FACET_SCALAR TYPE
{AI_FACET {TYPE} {SIMPLE_KEY value {TYPE}}}
#enddef

#define AI_FACET_TAG TAG CONTENTS
{AI_FACET {TAG} (
[tag]
name="value"
{CONTENTS}
[/tag]
)}
#enddef

{AI_FACET_SCALAR real}
{AI_FACET_SCALAR int}
{AI_FACET_SCALAR bool}
{AI_FACET_SCALAR string_list}
{AI_FACET_SCALAR ai_grouping}
{AI_FACET avoid {FILTER_TAG value location ()}}

{AI_FACET_TAG leader_goal (
{SIMPLE_KEY x int}
{SIMPLE_KEY y int}
{SIMPLE_KEY max_risk real}
{SIMPLE_KEY auto_remove bool}
)}

{AI_FACET_TAG recruitment_save_gold (
{SIMPLE_KEY active int}
{SIMPLE_KEY begin real}
{SIMPLE_KEY end real}
{SIMPLE_KEY spend_all_gold int}
{SIMPLE_KEY save_on_negative_income bool}
)}

{AI_FACET_TAG recruitment_instructions (
[tag]
name="recruit"
max=infinite
super="$ai/$recruit"
[/tag]
[tag]
name="total"
max=infinite
super="$ai/$recruit_base"
[/tag]
[tag]
name="pattern"
max=infinite
super="$ai/$recruit_base"
[/tag]
[tag]
name="limit"
max=infinite
super="$ai/$recruit_limit"
[/tag]
)}

{AI_ASPECT attacks (
{FILTER_TAG filter_own unit ()}
{FILTER_TAG filter_enemy unit ()}
)}

[tag]
name="facet~attacks"
super="$ai/$facet_base"
[if]
{AI_ASPECT_FILTER_ATTACKS}
{AI_ASPECT_FILTER_DEFAULT}
[then]
super="$ai/standard_aspect~attacks"
[/then]
[elseif]
{AI_ASPECT_FILTER_COMPOSITE}
[then]
super="$ai/composite_aspect~attacks"
[/then]
[/elseif]
[elseif]
{AI_ASPECT_FILTER_LUA}
[then]
super="$ai/facet~lua"
[/then]
[/elseif]
[else]
# This required key is just a hack to get an error here.
# It's not actually valid.
{REQUIRED_KEY invalid_engine_name_combo_in_aspect bool}
[/else]
[/if]
[/tag]

0 comments on commit 0444c8a

Please sign in to comment.