I did some statistical analysis to address the issue of the information a player gains by building an improvement with the described scheme, which subsequently fails to do anything because of an underlying unseen resource or bonus, giving the player unintended inferential power. I propose using the "randomly discover [bonus]" behaviour in the base game in order to baffle a player's exploitive attempts, and provide hard bounds on his certainty about information that is designed to be hidden.
Looking at it in terms of data-driven architecture, the fact that the game enforces the rule: { 'Forest' has three variations with nonidentical latitude ranges where each is legal } is a proper possession of the game and not the data of this terraforming improvement tech. So the data should not contain any element of this fact, but the game should drive forest-correction.
(Also, just for ease of reference, in the rest of this post I refer to improvements which have nonempty tags of <FeatureChange> or <BonusChange> as Terramorphous Improvements, Terramorphs, or TMIs)
Also, about Terramorphs placed on tiles with hidden bonus resources: We have the technology to do the following. Make the TMI have a "random chance" to discover the bonus it is actually intended to reveal, which is nearly equal to 1. But then also script it not to work when there is a "real" bonus under there.
If the chance that the TMI
doesn't fail randomly is
x, the event of which is independent of bonuses under the tile, then the probability that the TMI will fail (event 'F') is given by
Code:
P(F) = (1-x)(y) + (x)(1-y) + (1-x)(1-y) = y - xy + x - xy + 1 - x - y + xy
= 1 - xy = complement(xy)
where y is the complement of the prevalence of the incompatible bonus
(i.e. the chance that a tile doesn't have the bonus). This is the complement of the chance that neither reason for failure comes to pass, which is as well should be.
Now suppose the terramorph fails and we wonder if we now have conditional knowledge about the probability of a certain bonus being under it in truth. We want to know if P(-Y|F) = P(-Y), Y is the event "the other bonus is not present"
(and F is "The improvement failed to produce a bonus").
Code:
P(-Y & F)/P(F) = P(-Y)/P(F) [I](since -Y --> F)[/I]
which clearly gives conditional knowledge if failure is not 1. However, let's now consider a player who is eager to assume a certain bonus resource is present. We want him to be wrong enough of the time that the scripting described is not a reliable visor into hidden information. Consider the chances of both type I error and type II error. What we can control is the fact the player only gets one sample of the tile. We're already talking about a player who gets nothing and is suspicious of a hidden resource, so obviously type II error we don't care about (the player is rejecting the null hypothesis). We want to
magnify type I error. However, we also want the effect of random failure to be minimized.
We can't really control the player's hypothesis, and we already proved they are going to be a little bit right, so let's look at possible ways to introduce doubt.
y is a constant, and x is something the player will know too. So the chances P(-Y|F) and P(Y|F) are both known to him. Y^F = Y^-X, so P(Y|F) = P(-X&Y|F) .
These are complements, so P(-X&Y|F) = 1 - P(-Y|F) . Suppose what we really want is for the hypothesis that the failure is the result of random chance to be as good as the hypothesis that it was because of a hidden resource. (This is still a lot of knowledge about the tile - 50% right is better than (1-y) probability right.) This is when P(-X&Y|F) = P(-Y|F). Since they are complements, it is when they are 0.5.
Thus, solve the equation:
Code:
0.5 = P(-X&Y|F) = P(-X&Y&F)/P(F) = P(-X&Y)/P(F)
= P(-X)P(Y)/P(F) = (1-x)y/(1-xy) = (y - xy)/(1-xy)
The delightful app at Mathway.com solves this reciprocal equation because I can't work fractions (or radicals) a damn, and x = 2 - 1/y
Notice that to bound x in [0,1], 1/y must be in [1,2] or equivalently, y is in [0.5,1]. So the incidence of incompatible resources must be no greater than a half, which is certainly doable. Recall x,y were the probabilities of non-failure, so y is the complement of the incidence of the incompatible resource. Also, xy =/ 0, xy =/ 1, and y is certainly in (0,1), so the real bounds are x in (0,1) and y in (0.5, 1) .
So, if, say, the resource occurs on 15% of tiles, y = 0.85, and x =~ 0.82 . So the terramorphous improvement should be configured to "randomly" reveal its intended bonus 82.35% of the time.
Actually, this is a maximum bound on x, since we don't care if the hidden resource turns out not to be there even more than half the time. We wanted to keep x as large as possible though, as it just interferes with gameplay.
Suppose instead we want the chance of a guess of a resource to be minimally more accurate than without the sample of the TMI. That is, we want a type I error as close as possible to the naked chance (y) of there being nothing there. So we want the chance of observing F and asserting --X to be wrong as much as possible.
H0 is the hypothesis the TMI randomly failed, which has probability P(-X|F)
(as an explanation of event F which is already known). How can we vary this in relation to P(Y)?
Our eager Civizen is rejecting H0, so he is wrong with probability P(-X|F) = (1-x) /(1-xy) . I just studied a function like this a week ago: u/(1 - y + uy) .
(u=1-x) . Here is a link to a Mathway that graphs this function for y of 0.9, 0.85, and 0.51 (recall y is bounded by 0.5)
http://www.mathway.com/graph/NDI5MjM {after loading, click a colored square next to an equation and set the color to make the app draw the graphs}
Focusing on the region (0,1), it's clear this function is bounded below by f(u)=u, and is strictly increasing in y. We want to minimize
u to impact gameplay the least, but still have a large error chance. Let's have a "good enough" condition on the error chance and minimize u. Either we're comparing to the chance of guessing the hidden bonus is present and we're wrong, or the chance of guessing that and we're right : Y and -Y , respectively. To relate to values for u, find the intersection with the constant function f(u) = y
Again, solving an equation gives u = y/(y+1) . With y in (0.5,1), u is somewhere between 1/3 and 1/2 . So the more prevalent the resource is, the easier this masking task is (unintuitive).
Combining the two results, we want u > y/y+1, which is to say x < 1/(y+1) , and also we want x < 2 - 1/y (not strict inequalities). The largest x satisfying both , rounded to fit a computer simulation, is thus
round[down]( min{1/(y+1), 2 - 1/y} )
x is the probability of the improvement "randomly" revealing what it is supposed to add. y is the complement of the prevalence of incompatible resources (that will interdict the improvement's scripted effect). If the incompatible resource(s) occur on half the tiles or more, this technology does not work.