smgstudio / risk-dice

Dice code used in RISK: Global Domination
20 stars 7 forks source link

Accurate Nv1 Dice rolls for BB #1

Closed xOuchx0x closed 2 months ago

xOuchx0x commented 2 months ago

The polyinomial regression techinque that is used to generate the true random vector used for balance blitz dice rolls is significantly inaccurate over 70 troops. While I understand that SMG is looking for a comprehesive solution we know that may take some time. Given that roughly half of all attacks in ranked matches are large stacks hitting single troop territories I think a short term solution would help alot in reducing excess troop loss and excessive slidering.

Copied below is C code that runs in O(N) time. It takes an input for number of attacking troops and assumes there is only 1 defender It outputs an attack vector where the indice of the array is number of troops lost.

int A = 10; //Number of attacking troops
float Att[A]; // Attacking vector
for(int k = 0; k < A+1; k++) {
    Att[k] = 1;
}

for(int B=0; B<A-3 && A>3; B++)
{
    Att[B]=Att[B]*(95.0/144); //Probablity to win
    Att[B+1]=Att[B+1]*(49.0/144); //Probablity to lose    
    Att[B+2]=Att[B+1]; //Carry this value forwards
    Att[B+3]=Att[B+1]; //Carry this value forwards

}
Att[A-3]=Att[A-3]*(125.0/216); //Probablity to win a 2v1
Att[A-2]=Att[A-2]*(91.0/216); //Probablity to lose a 2v1
Att[A-1]=Att[A-1]*(91.0/216); //Probablity to lose a 2v1
Att[A-2]=Att[A-2]*(5.0/12); //Probablity to win a 1v1
Att[A-1]=Att[A-1]*(7.0/12); //Probablity to lose a 1v1

Note I did not make a PR since this code is not in the repository Note I also did not add the trivial solution of 1v1 which I guess is techinically a 2v1 SMG please let me know if this works, doesn't work or isn't worth the effort to update.

goteamsmg commented 2 months ago

Thank you for the suggestion, that we have been reviewing.

We need to see who this would work with A vs. D where D = 2,3,....,N. It also will fail where A=2 (or 1, as you note, but you can't attack 1 v 1 anyway as you need to leave a troop behind). We also need to check performance where A is in the 100,000's - which can happen with progressive cards and long games.

As this is not a direct comment on the repo, we'll close this issue and add this to the suggestions list. We will review this when we review the dice code. Thanks.