Relations syntax

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Relations syntax

Post by Ignatus »

In the rulesets, requirements mostly test properties of a specific game object (e.g. if unit vetranship is at least 2), or, rarely, relations between game objects of different nature within the context (e.g. if the tile is the center of the city). The exception is Local-ranged "DiplRel" that tests states between the player and another player.

I propose to generalize the concept of relation as a rule that tests a boolean/tristate function of two contexts. Mostly it is for use in action enablers but also for effects (the 2nd context has the player filled) and probably somewhere else. Relations shall live in "rels" vectors that behave mostly like "reqs" vectors.

Columns in "rels" should have captions "type" (the type of relation, e.g. "Dipl" or "MapDist"), "value" (that what is confusingly "name" for reqs - e.g. "War" or 10), "op" (comparison operator, defaults to "=", negation is made switching "=" to "!=", ">" to "<=" etc.), and two columns of the source entities, that in action enablers are naturally "actor_range" and "target_range" (maybe "range" is also an obscure word that should be changed).

The ranges should be more specific and developed than ranges of requirements. The base of them shall be the fields of context object ("Player", "Unit", "Extra" etc.) but functions should be possible like "Player.PrimaryCapital" or "Unit.Tile.City.Nationalities", I have described stuff like that in an old proposal. Each function spawns either an entity or an array of entities of some type (that should conform for actor and target sources).

Types of realations may be:
Dipl (Player)
What is local "DiplRel". You may use comparison to test that the players have e.g. at least armistice.

MapDist, RealMapDist, DistSq (Tile)
To e.g. unhardcode minimal trading distance.

Size, Veteran, Score... (various)
Integer parameters, "value" considered to be a difference. Maybe we can compare culture of a nation to culture of a city?

Idem (value dependent?)
If the source objects are similar on some criterium. E.g., "value"="City" means that the source cities are the same city (to make visible the ban of establishing trade route to home city etc.), and "value"="NationGroup" means that the players belong to the same nation group. Comparison operators may specify should all source objects in actor source array have identical pair in the target source array, or only some of them, or something of the set-theory operations.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: Relations syntax

Post by cazfi »

Ignatus wrote: Mon May 15, 2023 9:18 amMapDist, RealMapDist, DistSq (Tile)
To e.g. unhardcode minimal trading distance.

Size, Veteran, Score... (various)
Integer parameters, "value" considered to be a difference. Maybe we can compare culture of a nation to culture of a city?
These kinds of integer relations are going close to what the counters should do in the future. Maybe we need both, but need to think what things belong to which concept.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Relations syntax

Post by Ignatus »

cazfi wrote: Mon May 15, 2023 9:54 am These kinds of integer relations are going close to what the counters should do in the future. Maybe we need both, but need to think what things belong to which concept.
Well, it seems to incorporate both: there could be a rule like "take counters from two objects and compare their difference with a global counter, if it is smaller then...". I don't follow counters plans and progress closely though. Surely, the way of arbitrary breaks in linearity is a headache that should be maintained in a compact fashion.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: Relations syntax

Post by nef »

Ignatus wrote: Mon May 15, 2023 9:18 am
MapDist, RealMapDist, DistSq (Tile)
To e.g. unhardcode minimal trading distance.
This would be an opportunity to implement parametric metrics.

I have never liked presumptive names like RealMapDist. There is no such thing as a "real map distance". It is ALWAYS a matter of what metric you use.
Post Reply