How is that a major spoiler? I think the UFOPaedia should be updated with this information. Even without providing code figures, it could at least have a paragraph that explains that the Mind Shields reduce detection rate by 1/2, 2/3, 3/4 and so on depending on how many you have at the base, and that furthermore the more facility squares you have used up, the higher chance the base will be detected. It is difficult to make a strategic decision on whether or not they should be used when you have no idea how they work. The vague "reduces chance of detection" means little, especially when you're putting your trust on the math skills of MicroProse, who have utterly failed in that department a number of times, as have countless other game developers. In some games there have been similar vague helper items that "improve your luck" but have been demonstrated to be either completely ineffective or actually detrimental. Across many games I have seen a distinct pattern: even if such helper items do help, it's usually too little to be worth the time or resource cost of the item, and certainly not worth putting your trust into. The times they work is the exception, not the norm. Also, not knowing how they work prevents the player from understanding how many should be used. They wonder if one is enough, maybe they don't stack so one is the max effect, or maybe they have an additive effect and there's a critical number that reach max efficiency, do they have a diminishing return, or do their effects get individually stronger the more you have? These questions aren't answered in the UFOPedia or the website, and so players are just trusting this "improves your luck" promise with little to go on.
Sorry for the wall of rant, I just feel it's REALLY important to explain things like this, even if you just provide the player with the most basic explanation of its functionality.
Thanks for providing the code, I see how it works, mostly. There is a base chance of detection at 15%, plus 1/6th of a percent per facility square used, maxing at 21% chance. It is finally divided by (mind shields +1). You said the chance increases as the UFO gets closer to the base. How does this increase happen? I don't see it in the code you provided.