Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfathomable surface dweller randomness seems potentially bugged #1199

Open
cbondurant opened this issue Sep 11, 2024 · 0 comments
Open

Unfathomable surface dweller randomness seems potentially bugged #1199

cbondurant opened this issue Sep 11, 2024 · 0 comments

Comments

@cbondurant
Copy link

I was looking through the code in the name of trying to get a better sense of how the thrall capturing, psychic energy generation, etc. Function, since the numbers are significantly less clear for these mechanics than a lot of other ones are.

While doing so I noticed the following code for calculating if another surface dweller should be captured:

if (usedCap < global.city.captive_housing.raceCap && Math.rand(0,(catchVar * usedCap) - hunt) <= 0){
    let k = Math.rand(0,global.city.surfaceDwellers.length);
    global.city.captive_housing[`jailrace${k}`]++;
}

Notable is the Math.rand(0,(catchVar * usedCap) - hunt) <= 0 portion. Since .rand is an integer random value, this does always have a chance of being true, however its a 1 in (catchVar * usedCap) - hunt chance. The standard value for catchVar is 50, and its not modified by the tier of the Ancient Nightmare achievement.

I did some simulations to see just how weird and slow the behavior of this is, and across 1,000 trials of simulating 10,000 days of catch attempts, (using the value in my current save for the hunt constant) it took on average 760 days to obtain the first 10 prisoners, 5900 days for the next 10, and 30 was only ever reached 2% of the time, averaging 9200 days for the attempts that did not fail to reach 30. No run ever made it to 40 thralls. Meanwhile I am easily able to build over 120 thrall capacity.

I suspect the intention was actually to write Math.rand(0, catchVar*usedCap) - hunt <= 0 instead? This creates a far more forgiving capture rate that can actually reach the capacity of thrall storage.

I am willing to write up the pull request for this, but I wanted to confirm this was a bug and not intended behavior before doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant