Based on Murphy's law I'm sure that this post about logic contains logical mistakes.
Introduction to logic
A statement can be true or false. Examples of statements are
Code: Select all
Socrates is a man
Code: Select all
"MinSize", "2", "City"
Code: Select all
X = "MinSize", "2", "City"
Code: Select all
X
Code: Select all
"MinSize", "2", "City"
Code: Select all
X = Y && Z
Code: Select all
X = Y || Z
Code: Select all
X = !Y
Simple requirements
The Freeciv requirement vector
Code: Select all
{ "type", "name", "range"
"DiplRel", "War", "Local"
"UnitFlag", "Spy", "Local"
}
Code: Select all
("DiplRel", "War", "Local") && ("UnitFlag", "Spy", "Local")
The requirement vector
Code: Select all
{ "type", "name", "range", "present"
"DiplRel", "War", "Local", TRUE
"UnitFlag", "Spy", "Local", FALSE
}
Code: Select all
("DiplRel", "War", "Local") && !("UnitFlag", "Spy", "Local")
More than one requirement vector
Some effect typed only care if their value is above 0 or not. Unless the rule set author have used negative numbers as effect values translating an effect like that to logic is simple. Say that there are two effects of the same type. The requirement vector of the first is
Code: Select all
{ "type", "name", "range"
"Gov", "Republic", "Player"
}
Code: Select all
{ "type", "name", "range", "present"
"Gov", "Democracy", "Player", TRUE
"DiplRel", "War", "Local", FALSE
}
Code: Select all
("Gov", "Republic", "Player") || (("Gov", "Democracy", "Player") && !("DiplRel", "War", "Local"))
How to use this for conversion
An effect, let us call it No_Incite, makes it impossible to incide a city to change side. The action enabler "Incite City" has target requirements that test if a city can be incited. The goal is to make the action enabler behave like the effect.
The first step is to transform all No_Incite effects to logic. Say that there are two effects that both have exactly one requirement. The requirement of the first effect is Republic. The requirement of the second is Democracy. The result is
Code: Select all
No_Incite = ("Gov", "Republic", "Player") || ("Gov", "Democracy", "Player")
The second step is to translate the action enabler to formal logic. Since this effect was about the target city and not the attacker only the target requirement vector need translation. Say it is
Code: Select all
{ "type", "name", "range", "present"
"DiplRel", "Alliance", "Local", FALSE
"DiplRel", "Team", "Local", FALSE
}
Code: Select all
target = (!("DiplRel", "Alliance", "Local") && !("DiplRel", "Team", "Local", FALSE))
Code: Select all
merged_target = target && !No_Incite
The final step is to convert everything back to something Freeciv understands. I will here do it by hand.
Code: Select all
merged_target = target && !No_Incite
Code: Select all
merged_target = (!("DiplRel", "Alliance", "Local") && !("DiplRel", "Team", "Local", FALSE)) && !(("Gov", "Republic", "Player") || ("Gov", "Democracy", "Player"))
Code: Select all
merged_target = !("DiplRel", "Alliance", "Local") && !("DiplRel", "Team", "Local", FALSE) && !(("Gov", "Republic", "Player") || ("Gov", "Democracy", "Player"))
Code: Select all
merged_target = !("DiplRel", "Alliance", "Local") && !("DiplRel", "Team", "Local", FALSE) && !("Gov", "Republic", "Player") && !("Gov", "Democracy", "Player")
Code: Select all
{ "type", "name", "range", "present"
"DiplRel", "Alliance", "Local", FALSE
"DiplRel", "Team", "Local", FALSE
"Gov", "Democracy", "Player", FALSE
"Gov", "Republic", "Player", FALSE
}