I'm trying to recreate a single player version of a dice game called Dudo. The most relevant information is that six players have six hidden dice, and the point of the game is to guess how many of a certain kind of die are on the table in total (e.g. If there are ten 4s, or twelve 5s etc).
To make some AI, I'm using binomial distributions where the computer guesses the probability of there being a certain number of a certain kind of die, based on how many of that kind of die it already has in its hand. I saved this equation in the variable chance:
chance = ((1/3) ** (i - player_dice_type[turn][active_type])) * ((2/3) ** (total_count - i - player_count[turn] + player_dice_type[turn][active_type]))
i is the number of that kind of die (e.g. six 5s, or seven 5s, or eight 5s etc.). I have a list of how many of each kind of die a player has (
player_dice_type) and I can select a specific die for a specific player by subsetting
active_type. The 1/3 has to do with the rules of the game (normally it'd be 1/6 for dice), but that doesn't have to do with my issue anyway.
When I call chance, it ONLY gives me the value for if
player_dice_type[turn][active_type] = 0, and
i = 6, so the probability that 6 of that die are on the table when the computer has 0 of it.
I can call
player_dice_type[turn][active_type] and see that they do NOT equal 6 or 0. The thing is though, if I copy and paste the equation, it works perfectly fine. It only defaults to 6 and 0 when I call chance.
I've also tried making a
chancefun(i) function that returns the original equation, and then said
chance = chancefun(i). I can change i in the environment to whatever I want and
chancefun(i) will react accordingly, but once again, the variable
chance does not.
I've included scoping as a tag just because I think it might somehow be related but I can't think of how. I've also tried change the variable name from
chance to a bunch of other things and still no luck.