Advanced ranges for requirements

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:

Advanced ranges for requirements

Post by Ignatus »

This is development of my older idea and intended to be combined with advanced present. Currently, we have very narrow (and often obscure) set of ranges that requirements may be tested for: "Local", "CAdjacent", "Adjacent", "City", "Traderoute", "Continent", "Player", "Team", "Alliance", "World" (specenum req_ranges in common/requirements.h). I suppose that we could produce simple queries which will test a requirement to several object in a range that is derived from target objects with other requirements. The requirements are tested by are_reqs_active(), we just modify it so that if it encounters a requirement with a range not in the enum it runs a specific query and tests the requirement to each its result, and the final interpretation depends on present field. Parameters of the function that specify target will provide the data source for the query.

The queries we may describe in a file like technical.ruleset that will be parsed before all game-related ones, or in special sections [range_*] within each file. This mechanism may disallow nesting, or allow nesting only with previously defined derived ranges, to avoid endless recursion. Example of a range that unhardcodes "Alliance":

Code: Select all

[range_alliance]
id = "Alliance"
source = "World"
domain = "Players"
reqs = {"type", "name", "range"
	"DiplRel", "Alliance", "Player"
}
This does not look unsolvable problem for AI programming. The table of possible domains see here.
Post Reply